Thread: WS POPUP and Windows 2000

  1. #1
    Registered User
    Join Date
    Aug 2002
    Posts
    22

    WS POPUP and Windows 2000

    I'm writing a 3D viewer using OpenGL, which uses a fullscreen window. I'm using the WS_POPUP style to get a window with no boarders or title bar. This works fine on my Win98SE system, but when I took the code to Win2k box (and recompiled it with the same version of my compiler, MSVC++ 6.0 - no service packs) the program would crash. CreateWindowEx failed outright (it didn't even give me a NULL return). Remove WS_POPUP from the style and everything works.

    As such, are their any issues I need to be aware with WS_POPUP on Win2k? MSDN didn't list anything. I can also post the code later if it would help.

    Thanks.
    Last edited by Arrow Mk 84; 08-21-2002 at 06:23 PM.
    Never give an Ewok a thermial detonator

  2. #2
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571

    Re: WS POPUP and Windows 2000

    Originally posted by Arrow Mk 84
    I'm writing a 3D viewer using OpenGL, which uses a fullscreen window. I'm using the WS_POPUP style to get a window with no boarders or title bar. This works fine on my Win98SE system, but when I took the code to Win2k box (and recompiled it with the same version of my compiler, MSVC++ 6.0 - no service packs) the program would crash. CreateWindowEx failed outright (it didn't even give me a NULL return). Remove WS_POPUP from the style and everything works.

    As such, are their any issues I need to be aware with WS_POPUP on Win2k? MSDN didn't list anything. I can also post the code later if it would help.

    Thanks.
    That's what I've always used, well with WS_EX_TOPMOST also. Post the code and I'll see if it works on my win2k.
    "...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers

  3. #3
    Registered User
    Join Date
    Aug 2002
    Posts
    22
    Here it is. If it works, you should see a three color triangle (red, blue, green) 'orbiting' a point in the top half of the screen (I'm still learning OpenGL; Win32 for that matter...).

    I've also set my compile to search for header files in my include directory. Methods of interest are OpenGLWindow::CreateOGLWindow and BaseWindow::CreateBaseWindow.

    Thanks for the look.
    Never give an Ewok a thermial detonator

  4. #4
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    Unfortunately I do not have the OpenGL libraries installed on this machine so I cannot compile. Also I don't have Visual Studio installed. One suggestion though is this. I usually just pass NULL for the last 4 params of CreateWindowEx. I don't know if that is the problem but I never pass the stuff you did.
    "...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers

  5. #5
    Registered User
    Join Date
    Aug 2002
    Posts
    22
    Passing NULL as the last parameter causes an access violation. NULL works fine for the other three parameters. If no one else can think of anything I guess I just have to get more time on that Win2k box and play with it some more. Thanks (and if anyone can add anything or try this code out on their Win2k/XP box, I'd be grateful). Also, this is using OpenGL 1.1 (doing it old school, mainly because I can't find the SDKs for the newer versions)
    Never give an Ewok a thermial detonator

  6. #6
    Registered User xds4lx's Avatar
    Join Date
    Nov 2001
    Posts
    630
    Your program crashed right away under XP right when i hit the run command. Ill look through your code and see whats up b/c ive never had a problem with the WS_POPUP style
    "only two things are infinite, the universe and human stupidity, and im not sure about the former." - albert einstein

  7. #7
    Registered User
    Join Date
    Aug 2002
    Posts
    22
    Did it work if you commented out WS_POPUP?
    Never give an Ewok a thermial detonator

  8. #8
    Ken Fitlike
    Guest
    Stepping through the code reveals the following (win2k):

    1. ErrorMsg: errmsg: unable to create window->cannot make rendering context current

    which seems fairly explicit. The crash occurs because you are not checking the validity of the 'Render' object prior to attempting to access it; when wnd creation fails your code doesn't exit gracefully it attempt to 'violate' this unitialised object.

    To kill that error do this:
    Code:
    void Engine::Run()
    {
        if(render)
    	render ->Draw(window_hDC);
    }
    Although there is probably a better way to do this - like quitting without initialising/accessing any objects.

    Also your 'errorlog' is useless in that it didn't write this error to the error log.

    This, of course, doesn't solve the problem of wnd creation failure.

  9. #9
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    ...and that last was me...logged in...yet not logged in....

    Actually, that last suggestion is probably a bad idea: you need to sort out your exception handling so that the application quits gracefully when window creation etc fails.

    Although what I have suggested will prevent the access violation as described, the application 'process' is not killed.

    Also if you are aiming for a full screen window as described the only window style that is required is WS_POPUP; you seem to have added WS_SYSMENU too which is redundant for your needs.
    Last edited by Ken Fitlike; 08-22-2002 at 11:35 AM.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  10. #10
    Registered User
    Join Date
    Aug 2002
    Posts
    22
    Ok, I stripped out all of the window styles except WS_POPUP. Hopefully this will work better. And I also added exception catching for errors from the render. The error log should pick up anything that goes 'boom' in the code (I hadn't updated the exception catch in the last code post).

    Again, this does work on my 98SE box (I wonder if it works on any others...). Also, ALT-TAB is not supported at this time (which makes for some interesting screen effects!).

    Thanks and hopefully this will get closer to the problem.
    Never give an Ewok a thermial detonator

  11. #11
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    >>I wonder if it works on any others...)<<

    Yes it does; as did the original version.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  12. #12
    Registered User
    Join Date
    Aug 2002
    Posts
    22
    Good to know 98SE works. Any success with 2k/XP? (I gotta get another box...)
    Never give an Ewok a thermial detonator

  13. #13
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Sorry, Arrow Mk84, but I think i'm going to have to concede defeat on this one.

    In win2k, CreateWindowEx is failing (kernel says *ouch*) as you have already identified.

    Since the failure occurs during system processing of CreateWindowEx the only thing I can suggest is taking a closer look at your MessageHandler class thingy: it may be that some messages sent during CreateWindowEx processing are being processed/handled in an 'incorrect' fashion. I know that 'incorrect' is very vague and ambiguous but it's the best I can do. Sorry.

    Things to possibly try are to put handlers in for those messages and track what happens eg WM_NCCREATE, WM_NCCALCSIZE, WM_CREATE etc.

    On the up-side, the error log works great now and the application quits just fine on error ( a messagebox saying it's failed and is closing would be handy ).

    Good luck anyway.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  14. #14
    Registered User
    Join Date
    Aug 2002
    Posts
    22
    (Hopefully this thing will log me in...)

    Now that I have more access to the Win2k box, hopefully we can figure this thing out.

    I traced through the code and found that the problem is in my WNDPROC function with WM_NCCREATE. What happens is that when currentWindow -> window_hWnd = hWnd is called, an error code of INVALID_HANDLE (= 6) is generated. Time to add the error queue to the WNDPROC (this is what I get for starting on the deep end ).

    Thanks for the msg box idea. I'm gonna implement that.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Dialog Box Problems
    By Morgul in forum Windows Programming
    Replies: 21
    Last Post: 05-31-2005, 05:48 PM
  2. Automatic popup windows in IE
    By bennyandthejets in forum Windows Programming
    Replies: 8
    Last Post: 09-09-2004, 10:39 AM
  3. Help with editor windows with win api
    By NightStalker in forum Windows Programming
    Replies: 1
    Last Post: 03-13-2003, 03:53 AM
  4. Popup windows with CFrameWnd
    By Arrow Mk 84 in forum Windows Programming
    Replies: 0
    Last Post: 10-26-2002, 11:40 AM