I am learning windows programming via the tutorials here and ....
If i hit refresh it cant find.. i hit refresh again and its back.... where can i find tutorials?(besides here, flipcode, Gametutorials...)
TheNerd Tk421, I fixed your code. It works for me with the MinGW compiler which is the same that Dev-C++ uses.
#define WIN32_LEAN_AND_MEAN#include <windows.h>const char className[] = "Sample Class";const char windowName[] = "Sample Window";LRESULT CALLBACK MsgHandler(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);int WINAPI WinMain( HINSTANCE hinstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow){ WNDCLASSEX sampleClass; MSG msg; HWND hwnd; sampleClass.cbSize = sizeof(WNDCLASSEX); sampleClass.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; sampleClass.lpfnWndProc = MsgHandler; sampleClass.cbClsExtra = 0; sampleClass.cbWndExtra = 0; sampleClass.hInstance = hinstance; sampleClass.hIcon = LoadIcon(NULL, IDI_WINLOGO); sampleClass.hCursor = LoadCursor(NULL, IDC_ARROW); sampleClass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); sampleClass.lpszMenuName = NULL; sampleClass.lpszClassName = className; sampleClass.hIconSm = LoadIcon(NULL, IDI_WINLOGO); if(!RegisterClassEx(&sampleClass)) { MessageBox(NULL, "Could not register window class.", "ERROR", MB_OK); return 0; } hwnd = CreateWindowEx( 0, className, windowName, WS_POPUP | WS_VISIBLE, 0, 0, 800, 600, NULL, NULL, hinstance, NULL); if(hwnd == NULL) { MessageBox(NULL, "Could not create window.", "ERROR", MB_OK); return 0; } ShowWindow(hwnd, nCmdShow); UpdateWindow(hwnd); while(1) { if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); } else if(msg.message == WM_QUIT) { break; } } UnregisterClass(className, hinstance); return msg.wParam;}LRESULT CALLBACK MsgHandler(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam){ switch(msg) { case WM_DESTROY: { PostQuitMessage(0); } break; default: { return DefWindowProc(hwnd, msg, wparam, lparam); } } return 0;}
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement