Click here to Skip to main content
15,918,596 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Need small explanation about this kind of syntax Pin
JMelsi29-Jun-06 7:32
JMelsi29-Jun-06 7:32 
AnswerRe: Need small explanation about this kind of syntax Pin
led mike29-Jun-06 6:34
led mike29-Jun-06 6:34 
GeneralRe: Need small explanation about this kind of syntax Pin
JMelsi30-Jun-06 0:53
JMelsi30-Jun-06 0:53 
Questioniterator Pin
knoxplusplus29-Jun-06 5:54
knoxplusplus29-Jun-06 5:54 
AnswerRe: iterator Pin
Sarath C29-Jun-06 6:01
Sarath C29-Jun-06 6:01 
AnswerRe: iterator Pin
Zac Howland29-Jun-06 6:34
Zac Howland29-Jun-06 6:34 
GeneralRe: iterator [modified] Pin
knoxplusplus29-Jun-06 7:38
knoxplusplus29-Jun-06 7:38 
GeneralRe: iterator Pin
Zac Howland29-Jun-06 8:12
Zac Howland29-Jun-06 8:12 
QuestionScope Pin
Jay0329-Jun-06 5:26
Jay0329-Jun-06 5:26 
AnswerRe: Scope Pin
Chris Losinger29-Jun-06 5:33
professionalChris Losinger29-Jun-06 5:33 
AnswerRe: Scope Pin
Zac Howland29-Jun-06 6:38
Zac Howland29-Jun-06 6:38 
GeneralRe: Scope Pin
Jay0329-Jun-06 7:40
Jay0329-Jun-06 7:40 
GeneralRe: Scope Pin
Blake Miller30-Jun-06 10:25
Blake Miller30-Jun-06 10:25 
QuestionHow to dynamically change a window class name? Pin
yjzh29-Jun-06 5:12
yjzh29-Jun-06 5:12 
AnswerRe: How to dynamically change a window class name? Pin
ovidiucucu29-Jun-06 5:24
ovidiucucu29-Jun-06 5:24 
GeneralRe: How to dynamically change a window class name? Pin
Tara1429-Jun-06 5:45
Tara1429-Jun-06 5:45 
AnswerRe: How to dynamically change a window class name? [modified] Pin
ovidiucucu29-Jun-06 6:08
ovidiucucu29-Jun-06 6:08 
GeneralRe: How to dynamically change a window class name? Pin
Tara1429-Jun-06 7:15
Tara1429-Jun-06 7:15 
QuestionRe: How to dynamically change a window class name? Pin
yjzh29-Jun-06 16:51
yjzh29-Jun-06 16:51 
QuestionRe: How to dynamically change a window class name? Pin
yjzh29-Jun-06 15:33
yjzh29-Jun-06 15:33 
AnswerRe: How to dynamically change a window class name? [modified] Pin
ovidiucucu29-Jun-06 23:34
ovidiucucu29-Jun-06 23:34 
QuestionRe: How to dynamically change a window class name? Pin
yjzh30-Jun-06 21:04
yjzh30-Jun-06 21:04 
AnswerRe: How to dynamically change a window class name? [modified] Pin
ovidiucucu1-Jul-06 22:38
ovidiucucu1-Jul-06 22:38 
How nasty! Roll eyes | :rolleyes: No virtual, no override... Smile | :)

Well, no problem. Write your own Create function as well:
class CMyDialog : public CDialog
{
// ...
   BOOL Create(UINT nResID, CWnd* pParent)
      { return Create(MAKEINTRESOURCE(nResID), pParent);}
   BOOL Create(LPCTSTR lpszTemplateName, CWnd* pParentWnd);
// ...
}; 

#include <AFXIMPL.H>
// ...
BOOL CMyDialog::Create(LPCTSTR lpszTemplateName, CWnd* pParentWnd)
{
   ASSERT(HIWORD(lpszTemplateName) == 0 ||
      AfxIsValidString(lpszTemplateName));
   
   m_lpszTemplateName = lpszTemplateName;  // used for help
   if (HIWORD(m_lpszTemplateName) == 0 && m_nIDHelp == 0)
      m_nIDHelp = LOWORD((DWORD)m_lpszTemplateName);
   
   HINSTANCE hInst = AfxFindResourceHandle(lpszTemplateName, RT_DIALOG);
   HRSRC hResource = ::FindResource(hInst, lpszTemplateName, RT_DIALOG);
   HGLOBAL hTemplate = LoadResource(hInst, hResource);
   
   ASSERT(hTemplate != NULL);
   
   DLGTEMPLATEEX* lpDialogTemplate = (DLGTEMPLATEEX*)LockResource(hTemplate);
   
   WCHAR* pClassName = ((WCHAR*)lpDialogTemplate 
                        // skip DLGTEMPLATEEX structure
                        + sizeof(DLGTEMPLATEEX) / sizeof(WCHAR) 
                        // skip menu
                        + 2 * sizeof(WORD) / sizeof(WCHAR));
   
   wcscpy(pClassName, L"Tata Leone"); // replace "Mama Leone".
   
   BOOL bResult = CreateIndirect((LPCDLGTEMPLATE)lpDialogTemplate, 
                                                   pParentWnd, NULL, hInst);
   UnlockResource(hTemplate);
   FreeResource(hTemplate);
   return bResult;
}



Ovidiu Cucu
Microsoft MVP - Visual C++

-- modified at 4:39 Sunday 2nd July, 2006
GeneralRe: How to dynamically change a window class name? Pin
yjzh3-Jul-06 18:16
yjzh3-Jul-06 18:16 
QuestionRe: How to dynamically change a window class name? Pin
yjzh3-Jul-06 19:03
yjzh3-Jul-06 19:03 

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.