Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. CreateWindowEx is stupid and nonsensical

CreateWindowEx is stupid and nonsensical

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++
8 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    super_matt
    wrote on last edited by
    #1

    Hello, i am having some trouble writing a simple wrapper (in c++) for c windowing code, i have been trying to sort it out for a while and have figured out the class members as callbacks using setWindowLong and all that , but my main proble lies in CreateWindowEx, i have my code set up for error checking and creation of a WNDCLASSEX object goes fine and RegisterClassEx goes fine but when i call CreateWindowEx, it returns the error code 0, which means ERROR_SUCCESS, my createWindowEx call looks like this: m_hWnd is an HWND that is set to NULL until this call, m_hInstance is set with GetModuleHandle(NULL) emsg is just a file for collecting error messages m_StrTitle is a string containing my window/class name (it isn't NULL) if (!(m_hWnd=CreateWindowEx(dwExStyle, m_StrTitle, m_StrTitle, dwStyle | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, 0, 0, WindowRect.right-WindowRect.left, WindowRect.bottom-WindowRect.top, NULL, NULL, m_hInstance, this))) { emsg << "create glWindow: " << GetLastError(); emsg.close(); this->KillGLWindow(); MessageBox(NULL,"Window Creation Error","ERROR",MB_OK|MB_ICONEXCLAMATION); return false; } my WNDCLASSEX creation looks like this: WndProc is a static class member WNDCLASSEX l_wc = { sizeof(WNDCLASSEX), CS_GLOBALCLASS | CS_HREDRAW | CS_VREDRAW | CS_OWNDC, (WNDPROC) WndProc, 0, 0, m_hInstance, LoadIcon(NULL, IDI_WINLOGO), LoadCursor(NULL, IDC_ARROW), NULL, NULL, m_StrTitle, LoadIcon(NULL, IDI_WINLOGO), }; once again the error code returned with GetLastError() after my call to CreateWindowEx returns zero which enumerates to ERROR_SUCCESS and i really don't know what to do, i have spent a lot of time building this code, any help would be very much appreciated, thank you in advance -Matthew

    A 1 Reply Last reply
    0
    • S super_matt

      Hello, i am having some trouble writing a simple wrapper (in c++) for c windowing code, i have been trying to sort it out for a while and have figured out the class members as callbacks using setWindowLong and all that , but my main proble lies in CreateWindowEx, i have my code set up for error checking and creation of a WNDCLASSEX object goes fine and RegisterClassEx goes fine but when i call CreateWindowEx, it returns the error code 0, which means ERROR_SUCCESS, my createWindowEx call looks like this: m_hWnd is an HWND that is set to NULL until this call, m_hInstance is set with GetModuleHandle(NULL) emsg is just a file for collecting error messages m_StrTitle is a string containing my window/class name (it isn't NULL) if (!(m_hWnd=CreateWindowEx(dwExStyle, m_StrTitle, m_StrTitle, dwStyle | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, 0, 0, WindowRect.right-WindowRect.left, WindowRect.bottom-WindowRect.top, NULL, NULL, m_hInstance, this))) { emsg << "create glWindow: " << GetLastError(); emsg.close(); this->KillGLWindow(); MessageBox(NULL,"Window Creation Error","ERROR",MB_OK|MB_ICONEXCLAMATION); return false; } my WNDCLASSEX creation looks like this: WndProc is a static class member WNDCLASSEX l_wc = { sizeof(WNDCLASSEX), CS_GLOBALCLASS | CS_HREDRAW | CS_VREDRAW | CS_OWNDC, (WNDPROC) WndProc, 0, 0, m_hInstance, LoadIcon(NULL, IDI_WINLOGO), LoadCursor(NULL, IDC_ARROW), NULL, NULL, m_StrTitle, LoadIcon(NULL, IDI_WINLOGO), }; once again the error code returned with GetLastError() after my call to CreateWindowEx returns zero which enumerates to ERROR_SUCCESS and i really don't know what to do, i have spent a lot of time building this code, any help would be very much appreciated, thank you in advance -Matthew

      A Offline
      A Offline
      alex barylski
      wrote on last edited by
      #2

      http://www.codeproject.com/win32/win32windowwrapperclass.asp?print=true[^] I'm drinking triples, seeing double and acting single :cool:

      S 1 Reply Last reply
      0
      • A alex barylski

        http://www.codeproject.com/win32/win32windowwrapperclass.asp?print=true[^] I'm drinking triples, seeing double and acting single :cool:

        S Offline
        S Offline
        super_matt
        wrote on last edited by
        #3

        I have looked there earlier this week, i have examined there code, and i have found no allusion to what the answer to my problem is, i am doing everything that they do very similarly and it isn't working, i don't know why, and i don't know why i would be getting the ERROR_SUCCESS thing. if you could help me with that, it would be greatly appreciated -Matthew

        S D 2 Replies Last reply
        0
        • S super_matt

          I have looked there earlier this week, i have examined there code, and i have found no allusion to what the answer to my problem is, i am doing everything that they do very similarly and it isn't working, i don't know why, and i don't know why i would be getting the ERROR_SUCCESS thing. if you could help me with that, it would be greatly appreciated -Matthew

          S Offline
          S Offline
          Steve S
          wrote on last edited by
          #4

          Have you tried calling GetLastError after the failure point? In the same way that UN*X and MS-DOS library/system calls set errno to indicate a specific cause for error, this might lead you somewhere, even if it's only "invalid argument" Steve S

          D 1 Reply Last reply
          0
          • S Steve S

            Have you tried calling GetLastError after the failure point? In the same way that UN*X and MS-DOS library/system calls set errno to indicate a specific cause for error, this might lead you somewhere, even if it's only "invalid argument" Steve S

            D Offline
            D Offline
            David Crow
            wrote on last edited by
            #5

            Did you not see that? The first thing happening after CreateWindowEx() fails is GetLastError() gets called.


            Five birds are sitting on a fence. Three of them decide to fly off. How many are left?

            S 1 Reply Last reply
            0
            • S super_matt

              I have looked there earlier this week, i have examined there code, and i have found no allusion to what the answer to my problem is, i am doing everything that they do very similarly and it isn't working, i don't know why, and i don't know why i would be getting the ERROR_SUCCESS thing. if you could help me with that, it would be greatly appreciated -Matthew

              D Offline
              D Offline
              David Crow
              wrote on last edited by
              #6

              super_matt wrote: i am doing everything that they do very similarly and it isn't working I realize it's only two words, but therein could lie the answer. I've not looked at the referenced Web site, but perhaps it would be worth your time to compile that project to make sure it works, and then retrofit it with some of your code until the problem surfaces.


              Five birds are sitting on a fence. Three of them decide to fly off. How many are left?

              S 1 Reply Last reply
              0
              • D David Crow

                Did you not see that? The first thing happening after CreateWindowEx() fails is GetLastError() gets called.


                Five birds are sitting on a fence. Three of them decide to fly off. How many are left?

                S Offline
                S Offline
                Steve S
                wrote on last edited by
                #7

                Not until after I'd written my reply :( I should've reread the whole thread from the root message first! Steve S

                1 Reply Last reply
                0
                • D David Crow

                  super_matt wrote: i am doing everything that they do very similarly and it isn't working I realize it's only two words, but therein could lie the answer. I've not looked at the referenced Web site, but perhaps it would be worth your time to compile that project to make sure it works, and then retrofit it with some of your code until the problem surfaces.


                  Five birds are sitting on a fence. Three of them decide to fly off. How many are left?

                  S Offline
                  S Offline
                  super_matt
                  wrote on last edited by
                  #8

                  I have taken working procedural code and tried to object orient it, all i really changed was instead of executing global methods i execute class members. i have made sure that works, i have tried procedural code executing those class members, it works. the only thing i really changed was making my WndProc static, and passing (void* this) to it as the LPVOID param, then casting it back. i think my problem is maybe in my WndProc method, but i don't know what it is. I have tried making my WndProc call MessageBox() and create a message box that tells that it was entered, i read that WndProc is called before CreateWindowEx or CreateWindow returns so, those messageboxes should appear, but they aren't so i can only assume that therin lies my problem. here is my WndProc: LRESULT CALLBACK GLWindow::WndProc(HWND hWnd, LPARAM lParam, WPARAM wParam, UINT uMsg) { // GLWindow is my window class, i am trying to create a wrapper to create openGL windows GLWindow* pWnd; if (uMsg == WM_NCCREATE) { MessageBox(hWnd,"WM_NCCREATE","WndProc Message",MB_OK | MB_ICONINFORMATION); assert(((LPCREATESTRUCT(lParam))->lpCreateParams)); SetWindowLong(hWnd, GWL_USERDATA, (long)((LPCREATESTRUCT(lParam))->lpCreateParams)); } else if (uMsg == WM_CREATE) { MessageBox(hWnd,"WM_CREATE","WndProc Message",MB_OK | MB_ICONINFORMATION); assert(((LPCREATESTRUCT(lParam))->lpCreateParams)); SetWindowLong(hWnd, GWL_USERDATA, (long)((LPCREATESTRUCT(lParam))->CreateParams)); } pWnd = GetGLWindowPtr(hWnd); if (pWnd != NULL) return pWnd->MsgHandler(hWnd, uMsg, wParam, lParam, pWnd); else return DefWindowProc(hWnd, uMsg, wParam, lParam); } can you see my problem? -Matt

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups