Click here to Skip to main content
15,895,084 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
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 
AnswerRe: How to dynamically change a window class name? Pin
ovidiucucu3-Jul-06 22:33
ovidiucucu3-Jul-06 22:33 
GeneralRe: How to dynamically change a window class name? Pin
yjzh3-Jul-06 23:06
yjzh3-Jul-06 23:06 
GeneralRe: How to dynamically change a window class name? Pin
yjzh3-Jul-06 23:07
yjzh3-Jul-06 23:07 
QuestionRe: How to dynamically change a window class name? Pin
yjzh4-Jul-06 18:10
yjzh4-Jul-06 18:10 
AnswerRe: How to dynamically change a window class name? [modified] Pin
ovidiucucu4-Jul-06 21:08
ovidiucucu4-Jul-06 21:08 
QuestionRe: How to dynamically change a window class name? Pin
yjzh4-Jul-06 23:40
yjzh4-Jul-06 23:40 
AnswerRe: How to dynamically change a window class name? Pin
ovidiucucu5-Jul-06 2:42
ovidiucucu5-Jul-06 2:42 
QuestionRe: How to dynamically change a window class name? Pin
yjzh5-Jul-06 20:31
yjzh5-Jul-06 20:31 
Questionwhat is wrong Pin
Tara1429-Jun-06 4:56
Tara1429-Jun-06 4:56 
AnswerRe: what is wrong Pin
cje29-Jun-06 5:04
cje29-Jun-06 5:04 
GeneralRe: what is wrong Pin
Tara1429-Jun-06 5:07
Tara1429-Jun-06 5:07 
AnswerRe: what is wrong Pin
Viorel.29-Jun-06 5:23
Viorel.29-Jun-06 5:23 
GeneralRe: what is wrong Pin
Tara1429-Jun-06 5:27
Tara1429-Jun-06 5:27 
AnswerRe: what is wrong Pin
Zac Howland29-Jun-06 6:48
Zac Howland29-Jun-06 6:48 
GeneralRe: what is wrong Pin
Viorel.29-Jun-06 5:38
Viorel.29-Jun-06 5:38 

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.