Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - AfxRegisterClass issue
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

AfxRegisterClass issue

 Post Reply Post Reply
Author
Message
dennisV View Drop Down
Senior Member
Senior Member
Avatar

Joined: 07 October 2004
Location: Australia
Status: Offline
Points: 242
Post Options Post Options   Thanks (0) Thanks(0)   Quote dennisV Quote  Post ReplyReply Direct Link To This Post Topic: AfxRegisterClass issue
    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)
Back to Top
Oleg View Drop Down
Senior Member
Senior Member


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
dennisV View Drop Down
Senior Member
Senior Member
Avatar

Joined: 07 October 2004
Location: Australia
Status: Offline
Points: 242
Post Options Post Options   Thanks (0) Thanks(0)   Quote dennisV Quote  Post ReplyReply Direct Link To This Post 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)
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.031 seconds.