Click here to Skip to main content
15,921,941 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How to read a cookie in C++ Pin
David Crow12-Mar-04 5:07
David Crow12-Mar-04 5:07 
GeneralRe: How to read a cookie in C++ Pin
black97610-May-04 3:50
black97610-May-04 3:50 
GeneralRe: How to read a cookie in C++ Pin
David Crow10-May-04 3:59
David Crow10-May-04 3:59 
Questiondid u use video memory before? Pin
includeh1012-Mar-04 3:55
includeh1012-Mar-04 3:55 
AnswerRe: did u use video memory before? Pin
antlers12-Mar-04 5:49
antlers12-Mar-04 5:49 
GeneralRe: did u use video memory before? Pin
includeh1012-Mar-04 16:13
includeh1012-Mar-04 16:13 
Generaldebug problem Pin
star fish12-Mar-04 3:13
star fish12-Mar-04 3:13 
GeneralRe: debug problem Pin
Tim Smith12-Mar-04 4:03
Tim Smith12-Mar-04 4:03 
GeneralRe: debug problem Pin
star fish12-Mar-04 4:25
star fish12-Mar-04 4:25 
GeneralTitle bar.. Pin
Dennis L12-Mar-04 3:12
Dennis L12-Mar-04 3:12 
GeneralRe: Title bar.. Pin
Prakash Nadar12-Mar-04 3:29
Prakash Nadar12-Mar-04 3:29 
GeneralRe: Title bar.. Pin
Gary Wheeler12-Mar-04 4:24
Gary Wheeler12-Mar-04 4:24 
QuestionHow to insert a picture inmy dialog box Pin
Deepak Samuel12-Mar-04 2:18
Deepak Samuel12-Mar-04 2:18 
AnswerRe: How to insert a picture inmy dialog box Pin
David Crow12-Mar-04 2:23
David Crow12-Mar-04 2:23 
GeneralRe: How to insert a picture inmy dialog box Pin
Deepak Samuel12-Mar-04 2:28
Deepak Samuel12-Mar-04 2:28 
GeneralRe: How to insert a picture inmy dialog box Pin
george ivanov12-Mar-04 4:18
george ivanov12-Mar-04 4:18 
Generalreflecting value of one propertypage in another Pin
mymauve2112-Mar-04 1:45
mymauve2112-Mar-04 1:45 
GeneralRe: reflecting value of one propertypage in another Pin
Navin12-Mar-04 2:40
Navin12-Mar-04 2:40 
Generalupgrading VS6 to VS.NET2003, MFC linkage Pin
berndg12-Mar-04 1:40
berndg12-Mar-04 1:40 
GeneralRe: upgrading VS6 to VS.NET2003, MFC linkage Pin
Gary Wheeler12-Mar-04 2:00
Gary Wheeler12-Mar-04 2:00 
GeneralRe: upgrading VS6 to VS.NET2003, MFC linkage Pin
berndg12-Mar-04 2:16
berndg12-Mar-04 2:16 
GeneralRe: upgrading VS6 to VS.NET2003, MFC linkage Pin
Gary Wheeler12-Mar-04 3:08
Gary Wheeler12-Mar-04 3:08 
GeneralRe: upgrading VS6 to VS.NET2003, MFC linkage Pin
Navin12-Mar-04 2:42
Navin12-Mar-04 2:42 
GeneralDo not work DoModal() for font change: Pin
vgrigor12-Mar-04 0:14
vgrigor12-Mar-04 0:14 
Idea:
to compensate font change by inverse change of CDialog's font,
to make controls look same.

It wors for modeLess Creation,
but for Modal - ActiveX - in my case Windowless
ActiveX- do not created after ew template use.

Where is error or bot made some work?

Private members get in Macro defining CDialog function,

that called GetDoModalData() to get Them,

Functionality of creation Cdialog with font change
placed in inheritable class
class CDlgHead : public CBitmapDialog , public CDialogCreatorHelper <cdlghead>//CDialog

All works except for ActiveX-Windowless - as I tested:

<br />
//Call as:<br />
          CDlgHead dlg;<br />
        dlg.GetDoModalData();<br />
        dlg.Create_WithFont(IDD_Form_1,pParent,0,-1);<br />
//0 - Create ModeLess, 1 Modal, <br />
//-1 - compensate font size automatically<br />
<br />
class CDlgHead : public CBitmapDialog , public CDialogCreatorHelper <CDlgHead>//CDialog<br />
{<br />
<br />
public:<br />
//-------------------------------------------<br />
<br />
//Definitions:<br />
    DEFINE_DoModalData;<br />
}<br />
<br />
<br />
#define DEFINE_DoModalData                            \<br />
virtual void GetDoModalData()    {                    \<br />
    pCopy_m_lpszTemplateName = &m_lpszTemplateName; \<br />
    pCopy_m_hDialogTemplate  = &m_hDialogTemplate;  \<br />
    pCopy_m_lpDialogTemplate = &m_lpDialogTemplate; \<br />
    pCopy_m_nIDHelp  =    &m_nIDHelp;                    \<br />
    pCopy_m_pParentWnd = &m_pParentWnd;                \<br />
    pCopy_m_hWndTop = &m_hWndTop;                    \<br />
};<br />
<br />
class CDoModalData <br />
{<br />
public:<br />
    CDoModalData()<br />
    {<br />
        //GetDoModalData();<br />
    };<br />
<br />
    LPCTSTR* pCopy_m_lpszTemplateName;                <br />
    HGLOBAL* pCopy_m_hDialogTemplate;                <br />
    LPCDLGTEMPLATE* pCopy_m_lpDialogTemplate;    <br />
    UINT* pCopy_m_nIDHelp; <br />
    CWnd** pCopy_m_pParentWnd;<br />
    HWND* pCopy_m_hWndTop ;<br />
    <br />
    virtual void GetDoModalData()=0; <br />
};<br />
<br />
/*<br />
    pCopy_m_lpszTemplateName = &m_lpszTemplateName;     // name or MAKEINTRESOURCE<br />
    pCopy_m_hDialogTemplate  = &m_hDialogTemplate;      // indirect (m_lpDialogTemplate == NULL)<br />
    pCopy_m_lpDialogTemplate = &m_lpDialogTemplate;  // indirect if (m_lpszTemplateName == NULL)<br />
<br />
*/<br />
<br />
<br />
template <class dlg_T><br />
class CDialogCreatorHelper :public CDoModalData <br />
{<br />
public:<br />
    CDialogCreatorHelper(void)<br />
    { <br />
        //dlg_T::GetDoModalData();<br />
    };<br />
    ~CDialogCreatorHelper(void){};<br />
<br />
    virtual void GetDoModalData() =0 ;<br />
<br />
    CString m_FontName;<br />
    int m_FontSize;<br />
    <br />
    //CDialog* pDialog;<br />
<br />
    //int Create(int IDD,CDialog* pDialog, CWnd* pParentWnd, int isModal);<br />
    int SetFont_OnHelper( int size, CString FontName = "Tahoma")<br />
    {<br />
        m_FontName = FontName ;<br />
        m_FontSize = size;<br />
    };<br />
<br />
    int Create_WithFont(int IDD, CWnd* pParentWnd, int isModal, int size = -1, CString FontName = "" )//;<br />
    {<br />
        //dlg_T pDialog = arg_pDialog;<br />
<br />
        int sys_FontSize= <br />
        GetDeviceCaps(::GetDC(0), LOGPIXELSY ); <br />
<br />
        if(size == -1)<br />
        {<br />
            <br />
            if(sys_FontSize == 96)<br />
            {<br />
                size =10;<br />
            }<br />
            else<br />
            if(sys_FontSize == 120)<br />
            {<br />
                size =8;<br />
            }<br />
            else<br />
            {<br />
                ASSERT(0);// For else fonts- is not precise transformation, due to 9/10 is 10 precision lost, not 96/120<br />
                           //but system font is float precisioned sytem panel font choose.<br />
                size =8;<br />
            }<br />
<br />
        }    <br />
<br />
//------------------------------------<br />
        if(1)<br />
        //if(!isModal)<br />
        {<br />
            LPSTR lpszTemplateName = <br />
                            MAKEINTRESOURCE(IDD);<br />
<br />
            ASSERT(IS_INTRESOURCE(lpszTemplateName) ||<br />
                AfxIsValidString(lpszTemplateName));<br />
<br />
            //m_lpszTemplateName = lpszTemplateName;  // used for help<br />
            *pCopy_m_lpszTemplateName = lpszTemplateName;<br />
            <br />
            //if (IS_INTRESOURCE(m_lpszTemplateName) && m_nIDHelp == 0)<br />
            if (IS_INTRESOURCE(*pCopy_m_lpszTemplateName) && *pCopy_m_nIDHelp == 0)<br />
                <br />
                //m_nIDHelp = LOWORD((DWORD_PTR)m_lpszTemplateName);<br />
                *pCopy_m_nIDHelp= LOWORD((DWORD_PTR)*pCopy_m_lpszTemplateName);<br />
                    <br />
            //        #ifdef _DEBUG<br />
            //            if (!_AfxCheckDialogTemplate(lpszTemplateName, FALSE))<br />
            //            {<br />
            //                ASSERT(FALSE);          // invalid dialog template name<br />
            //                PostNcDestroy();        // cleanup if Create fails too soon<br />
            //                return FALSE;<br />
            //            }<br />
            //        #endif //_DEBUG<br />
                    <br />
            HINSTANCE hInst = AfxFindResourceHandle(lpszTemplateName, RT_DIALOG);<br />
            HRSRC hResource = ::FindResource(hInst, lpszTemplateName, RT_DIALOG);<br />
            HGLOBAL hTemplate = LoadResource(hInst, hResource);<br />
        //    BOOL bResult = CreateIndirect(hTemplate, pParentWnd, hInst);<br />
            <br />
            HGLOBAL hDialogTemplate  = hTemplate;<br />
<br />
            ASSERT(hDialogTemplate != NULL);<br />
<br />
            LPCDLGTEMPLATE lpDialogTemplate = (LPCDLGTEMPLATE)LockResource(hDialogTemplate);<br />
        //-------------      <br />
            CDialogTemplate dlgTemp(lpDialogTemplate);<br />
<br />
      //dlgTemp.SetSystemFont(size);<br />
            WORD w_size = size;<br />
            dlgTemp.GetFont(FontName, w_size);<br />
                <br />
            dlgTemp.SetFont(FontName,size);<br />
            hTemplate = dlgTemp.m_hTemplate;//Detach();<br />
<br />
//-------------      <br />
<br />
    //lpDialogTemplate->SetFont(FontName, size);<br />
<br />
      BOOL bResult =0;<br />
    //bResult =     CreateIndirect(lpDialogTemplate, pParentWnd, NULL, hInst);<br />
    <br />
      if(!isModal)<br />
      {<br />
          bResult =   <br />
              //pDialog-><br />
              ((dlg_T*)this)->CreateIndirect(hTemplate );<br />
      }<br />
      else<br />
      {<br />
          <br />
           //Make Cdialog know that Create by supplied Template<br />
              *pCopy_m_lpszTemplateName = NULL;<br />
              *pCopy_m_hDialogTemplate = hTemplate;<br />
          //pDialog->hTemplate<br />
         // *pCopy_m_lpDialogTemplate = lpDialogTemplate;<br />
          bResult =      <br />
              //pDialog-><br />
              ((dlg_T*)this)->DoModal();<br />
<br />
<br />
      }<br />
    <br />
    UnlockResource(hDialogTemplate);<br />
<br />
<br />
    FreeResource(hTemplate);<br />
<br />
    return bResult;        <br />
        <br />
        }<br />
//Old method:<br />
//============================<br />
            CDialogTemplate dlt;<br />
            int     nResult;<br />
<br />
        // load dialog template<br />
        if (!dlt.Load(MAKEINTRESOURCE(IDD))) return -1;<br />
<br />
        // set your own font, for example "Arial", 10 pts. <br />
<br />
            dlt.SetFont(FontName, size);    <br />
        // get pointer to the modified dialog template<br />
        LPSTR pdata = (LPSTR)GlobalLock(dlt.m_hTemplate);<br />
            <br />
        // let MFC know that you are using your own template<br />
           <br />
        //dlg_T::<br />
            //pDialog-><br />
                *pCopy_m_lpszTemplateName = NULL;<br />
<br />
        HINSTANCE hInst = AfxFindResourceHandle(MAKEINTRESOURCE(IDD), RT_DIALOG);<br />
            <br />
            BOOL bResult ;<br />
<br />
//----------------------------<br />
<br />
//---------------------------<br />
<br />
            //pDialog-><br />
                *pCopy_m_hDialogTemplate = dlt.m_hTemplate;<br />
<br />
            <br />
            <br />
            if(isModal)    <br />
            {<br />
                nResult = <br />
                    //pDialog-><br />
                    ((dlg_T*)this)-><br />
                    DoModal();<br />
            }<br />
            else<br />
            {<br />
                bResult = <br />
                    //pDialog-><br />
                    ((dlg_T*)this)-><br />
                    CreateIndirect(  dlt.m_hTemplate, pParentWnd);<br />
            }<br />
            <br />
<br />
<br />
            GlobalUnlock(dlt.m_hTemplate);<br />
<br />
            //if(m_hWnd == 0 )<br />
            //    ASSERT(0);//for test<br />
<br />
            //bResult = CreateIndirect(hTemplate, pParentWnd, hInst);<br />
            //FreeResource(hTemplate);<br />
<br />
            return bResult;    <br />
    <br />
    };<br />
    //{<br />
    //return 1;<br />
    //};<br />
<br />
<br />
<br />
};<br />
 <br />

Generalinvoke an application when starting the pc Pin
Rubin Boban11-Mar-04 23:54
Rubin Boban11-Mar-04 23:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.