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
S

super_matt

@super_matt
About
Posts
10
Topics
3
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • CreateWindowEx is stupid and nonsensical
    S super_matt

    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

    C / C++ / MFC help c++

  • CreateWindowEx is stupid and nonsensical
    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

    C / C++ / MFC help c++

  • CreateWindowEx is stupid and nonsensical
    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

    C / C++ / MFC help c++

  • wm_create problems
    S super_matt

    this is my create window method: bool GLWindow::CreateGLWindow(HINSTANCE hInstance //this is hInstance passed by WinMain) { ofstream emsg ("ERROR.txt"); //this is where i have been putting my errors GLuint PixelFormat; DWORD dwExStyle; DWORD dwStyle; RECT WindowRect; WindowRect.left = (long)0; WindowRect.right = (long)m_aResolution[0]; WindowRect.top = (long)0; WindowRect.bottom = (long)m_aResolution[1]; m_hInstance = hInstance; 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), }; if (!RegisterClassEx(&l_wc)) { emsg << GetLastError(); MessageBox(NULL,"Failed To Register The Window Class.","ERROR",MB_OK|MB_ICONEXCLAMATION); return FALSE; } /*********************************my class registers fine, no problem at all*********************/ dwExStyle=WS_EX_APPWINDOW | WS_EX_WINDOWEDGE; dwStyle=WS_OVERLAPPEDWINDOW; AdjustWindowRectEx(&WindowRect, dwStyle, FALSE, dwExStyle); 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))) { /************************************************************************************************* this is where the failure is, but the error code that gets printed is zero (which is enumerated as ERROR_SUCCESS) which i don't get at all, i don't know if i am somehow getting the wrong error code or what!! *************************************************************************************************/ emsg << GetLastError(); emsg.close(); this->KillGLWindow(); MessageBox(NULL,"Window Creation Error","ERROR",MB_OK|MB_ICONEXCLAMATION); return false; } ****NOTE: i nocked off the rest of the code because it works, and it doesn't do anything but take up a lot of space in this post. Your help so far has been great, thank you for your continued support -Matthew

    C / C++ / MFC help graphics game-dev question learning

  • wm_create problems
    S super_matt

    CS_GLOBAL isn't a field in style, i can't set it to that, it tells me 'CS_GLOBAL': undeclared identifier also, for some reason, i am being told that the paramter is incorrect when i try and register my class

    C / C++ / MFC help graphics game-dev question learning

  • wm_create problems
    S super_matt

    I've been working really hard on this now and i have finally figured out that my real problem is in CreateWindowEx it is giving a return error of 6, which i found out is 'invalid handle' i think that is pointing at my hinstance, to instantiate my hinstance i call GetModuleHandle(NULL) and that is in a cpp file that is compiled into a static library, if this helps, that's great, i really need a fix for this problem, Thank you very much in advance if you can tell me what to do.

    C / C++ / MFC help graphics game-dev question learning

  • wm_create problems
    S super_matt

    Thanks for the help, i applied all the stuff that was in that article, and it still didn't work, i also started to use WNDCLASSEX instead of WNDCLASS, but all that has done is stopped me from being able to register my class. i type: RegisterClassEx(&myWndClassEx); and it throws an error, i printed the error with GetLastError, and the code is dec 87 or 0x57 and i don't know what that is or where to find the definition, this is becomming a major dilemna, any more help would be greatly appreciated

    C / C++ / MFC help graphics game-dev question learning

  • wm_create problems
    S super_matt

    sorry, just to add on, i have also used GWL_USERDATA instead of DWL_USER if that makes a difference, thanks

    C / C++ / MFC help graphics game-dev question learning

  • wm_create problems
    S super_matt

    Hello, I am trying to write a simple little oo windowing library for opengl (mainly a wrapper for the c based windowing code); of course i had the standard wndproc callback as a class member problem, but i found a way around that, what i did was simple enough, i made WndProc static, but that meant i couldn't get at class members and then I noticed that the last paramater of CreateWindowEx was passed as the LPARAM of your wndproc callback on WM_CREATE. So, i passed 'this': CreateWindowEx(blah...., this); then in WM_CREATE: SetWindowLong(hWnd, DWL_USER, lParam); then whenever i have a WM_* callback i acces my class through ((MyClass*)GetWindowLong(hWnd, DWL_USER))->junkMyClassPointsTo... but CreateWindowEx is always failing, none of the paramaters are bad, the only thing i can think of is 'this' and i don't know if WndProc-WM_CREATE is called then and if it is what is giving me the problem. if anyone could help me with this, it would be most appreciated. thank you, -Matt

    C / C++ / MFC help graphics game-dev question learning

  • WinMain as a member function
    S super_matt

    Hello, i am fairly new to c++ (worked mainly with java 'til now) and i was wondering if anybody could help me with with a certain linker error i am getting, the error that tells me i have unresolved externals (lnk2001, lnk2019) specifically in "_WinMain" in "_CRTstartup@16" i think this has something to do with my WinMain method be a member function (it is static so there is no hidden "this" parameter) but don't don't know what else to do, is my WinMain declaration: static int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nCmdShow) thanks to anyone who can help me.

    C / C++ / MFC help c++ java
  • Login

  • Don't have an account? Register

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