CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2003
    Location
    New Hampshire
    Posts
    2

    Angry CWnd::CreateEx issue

    [FONT=arial]
    I am working on creating an application that requires a full-screen window. In order to do this I am using MFC's CWnd::CreateEx within a class that inherits from CWnd. However, when I attempt to create a window over 640x480 (more specifically using the system metrics), it creates the window for a brief second and then just flashes away!!!

    Here is the code i am using (this is in CMyWindow::Create):
    [FONT=courier new]
    // get system metrics
    nScreenX = GetSystemMetrics(SM_CXSCREEN);
    nScreenY = GetSystemMetrics(SM_CYSCREEN);

    // create (for DEBUG mode, we don't want it to be on top, because then it will show up over our DEBUG windows)
    #ifdef _DEBUG
    bRes = CWnd::CreateEx(0,pszClassName,"",WS_POPUP|WS_VISIBLE,20,20,nScreenX,nScreenY,NULL,NULL);
    #else
    bRes = CWnd::CreateEx(WS_EX_TOPMOST,pszClassName,"",WS_POPUP|WS_VISIBLE,0,0,nScreenX,nScreenY,NULL,NULL);
    #endif

    [FONT=arial]
    Can anyone tell me what I am doing wrong? Thank you.
    ~ Joe

  2. #2
    Join Date
    Apr 1999
    Posts
    3,585
    From the looks of your code, you're creating the window on the stack (locally). You have not defined a CWnd or HWND to hold the result of the create method. When the code is out of scope, the window is destroyed.
    Gort...Klaatu, Barada Nikto!

  3. #3
    Join Date
    Mar 2003
    Location
    New Hampshire
    Posts
    2

    Question ok...

    I was assuming the CWnd-derived class would handle that by itself. Do you have any immediate recommentations on how to go about that?

    The reason I ask is because when the window size is under or at 640 by 480 (example below) the window WILL stay and operate properly. I would guess that you are suggesting using the internal this->CreateEx for creation.

    I attempted running the code with my screen size down to 640 x 480 (as horrifying as it was) and everything worked just fine, which is what has me so baffled.

    Functional code example:
    bRes = CWnd::CreateEx(0,pszClassName,"",WS_POPUP|WS_VISIBLE,20,20,400,400,NULL,NULL);
    Last edited by revof11; March 19th, 2003 at 08:29 PM.
    ~ Joe

  4. #4
    Join Date
    Apr 1999
    Posts
    3,585
    Can you post more of the relevant code that creates the window. It's hard to determine the cause from the snippet you have provided.
    Gort...Klaatu, Barada Nikto!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured