Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Fredric

Windows Skeleton- Sex, drugs and a run-time error

This topic is 6935 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''m having trouble with this windows skeleton that I made.. it compiles without any errors or warnings, but when I ry to run it, it simply doesn''t show up. Can anyone help a poor white fool like myself? // a windows skeleton #include ''windows.h'' LRESULT CALLBACK WinProc(HWND, UINT, WPARAM, LPARAM); char szWinName[] = "MyWin"; // name of window class int WINAPI WinMain(HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgs, int nWinMode) { HWND hwnd; WNDCLASSEX wcl; MSG msg; // define the window class wcl.cbSize = sizeof(WNDCLASSEX); wcl.lpszClassName = szWinName; wcl.lpfnWndProc = WinProc; wcl.style = 0; wcl.hIcon = LoadIcon(NULL, IDI_APPLICATION); wcl.hIconSm = NULL; wcl.hCursor = LoadCursor(NULL, IDC_ARROW); wcl.lpszMenuName = NULL; // no menu wcl.cbClsExtra = 0; wcl.cbWndExtra = 0; // make the background of the window black wcl.hbrBackground = (HBRUSH) GetStockObject(BLACK_BRUSH); // register the window class if(!RegisterClassEx(&wcl)) return 0; // if the class doesn''t register, break it // the window has been defined and registered, // but now it''s time to create it hwnd = CreateWindow(szWinName, // name of window class "Windows Skeleton", //title WS_OVERLAPPEDWINDOW, //style CW_USEDEFAULT, // x CW_USEDEFAULT, // y CW_USEDEFAULT, // width CW_USEDEFAULT, // height NULL, // no parent window NULL, // no menu hThisInstance, //instance handle NULL // no additional arguments ); // diplay the window ShowWindow(hwnd, nWinMode); UpdateWindow(hwnd); // create a message loop while(GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return msg.wParam; } // the message handler LRESULT CALLBACK WinProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { switch(message){ case WM_DESTROY: // terminate the program PostQuitMessage(0); break; default: return DefWindowProc(hwnd, message, wParam, lParam); } return 0; } GO LEAFS GO!

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
I''m not an expert in Windows-programming, but I think you forgot to set the instance-handle:

wcl.hInstance = hThisInstance;

Hope this helps.

Share this post


Link to post
Share on other sites
In the CreateWindow function, the fourth argument(the style argument) must be: WS_OVERLAPPEDWINDOW / WS_VISIBLE

Also setting wcl.hInstance = hThisInstance is correct.

That should do it, good luck!

Edited by - isolier on 4/21/00 8:28:19 PM

Share this post


Link to post
Share on other sites
You don''t have to explicitly specify WS_VISIBLE, as you''re calling ShowWindow(). It might even be implicit, but I couldn''t say for sure.

-------------------
Revolver, aka Brian Smith
MIS Programmer Analyst
brian.smith@realpage.com
RealPage >> www.realpage.com

My views aren't even mine, much less my employers. =)

Share this post


Link to post
Share on other sites
quote:
Original post by Isolier
In the CreateWindow function, the fourth argument(the style argument) must be: WS_OVERLAPPEDWINDOW / WS_VISIBLE

Also setting wcl.hInstance = hThisInstance is correct.

That should do it, good luck!



I thought that WS_VISIBLE was unnessary when you call
ShowWindow(hwnd, nCmdShow), because in ShowWindow(..) your are telling the window how to show in the nCmdShow-parameter.
But perhaps I got all this wrong, who knows...

Share this post


Link to post
Share on other sites
Yay! Thanks, I got it.. I''m new to windows programming, so I have no idea why I would even include that in the class definition, but thanks for the people who helped! I got it running with:

wcl.hInstance = hThisInstance;

GO LEAFS GO!

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!