Print Page | Close Window

AfxRegisterClass issue

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=11261
Printed Date: 15 November 2025 at 6:43am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: AfxRegisterClass issue
Posted By: dennisV
Subject: AfxRegisterClass issue
Date Posted: 30 June 2008 at 5:43pm
Hello all,

I'd like to change the class name of the main frame to be able to find it later on, but when I do an AfxRegisterClass() in PreCreateWindow, the window is screwed up - the menu/toolbars are not updated and the client area is not updated as well. Am I doing something wrong or does CodeJock override it on its own? My code is below:


BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
    if( !CXTPMDIFrameWnd::PreCreateWindow(cs) )
        return FALSE;

    WNDCLASS wnd;
    HINSTANCE hInst = AfxGetInstanceHandle();

    if (!(::GetClassInfo(hInst, _T("My window class"), &wnd)))
    {
        // we have to register the window class
        wnd.style            = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW;
        wnd.lpfnWndProc      = ::DefWindowProcW;
        wnd.cbClsExtra       = wnd.cbWndExtra = 0;
        wnd.hInstance        = hInst;
        wnd.hIcon            = NULL;
        wnd.hCursor          = AfxGetApp()->LoadStandardCursor(IDC_ARROW);
        wnd.hbrBackground    = (HBRUSH) (COLOR_3DFACE + 1);
        wnd.lpszMenuName     = NULL;
        wnd.lpszClassName    = _T("My window class");

        AfxRegisterClass( &wnd );
    } 

    cs.lpszClass = _T("My window class");

    return TRUE;
}


Thanks in advance!

   Dennis


-------------
// W7 64 Ultimate SP1
// VS 2008
// CodeJock 16.2.3 (MFC)



Replies:
Posted By: Oleg
Date Posted: 01 July 2008 at 1:40am
Hi,
 
Tried with our sample and it works.
 
 
try replace it all to
 
 cs.lpszClass = _T("MyWindowClass");
 CXTPDrawHelpers::RegisterWndClass(AfxGetInstanceHandle(), cs.lpszClass, 
  CS_DBLCLKS, AfxGetApp()->LoadIcon(IDR_MAINFRAME));
return TRUE;


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: dennisV
Date Posted: 01 July 2008 at 1:43am
Originally posted by oleg oleg wrote:

Hi,
 
Tried with our sample and it works.
 
 
try replace it all to
 
 cs.lpszClass = _T("MyWindowClass");
 CXTPDrawHelpers::RegisterWndClass(AfxGetInstanceHandle(), cs.lpszClass, 
  CS_DBLCLKS, AfxGetApp()->LoadIcon(IDR_MAINFRAME));
return TRUE;

That works Thanks!



-------------
// W7 64 Ultimate SP1
// VS 2008
// CodeJock 16.2.3 (MFC)



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net