1
C - C++ / Re: Program Is Not Compiling But It Should!
« on: March 04, 2013, 08:51:45 pm »Thanks.
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
#include <windows.h>
LRESULT CALLBACK WindowFunc(HWND, UINT, WPARAM, LPARAM);
char szWinName[] = "MyWin"; //window clss name
int WINAPI WinMain(HINSTANCE hThisInst, HINSTANCE hPrevInts, LPSTR lpszArgs, int nWinMode){
HWND hwnd;
MSG msg;
WNDCLASSEX wcl;
/*define window clss*/
wcl.cbSize = sizeof(WNDCLASSEX); //size of WNDCLASSEX
wcl.hInstance = hThisInst; //Handle to this instance
wcl.lpszClassName = szWinName; //window class name
wcl.lpfnWndProc = WindowFunc; //window function
wcl.style = 0; //default style
wcl.hIcon = LoadIcon(NULL, IDI_APPLICATION); //icon style
wcl.hIconSm = LoadIcon(NULL, IDI_WINLOGO); //small icon style
wcl.hCursor = LoadCursor(NULL, IDC_ARROW); //Cursor style
wcl.lpszMenuName = NULL; //as no menu
wcl.cbClsExtra = 0; //as no extra
wcl.cbWndExtra = 0; //information needed
wcl.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH); //Window Background: White
if(!RegisterClassEx(&wcl)) return 0;
/*Now a window class has been registered, a window can be created*/
hwnd = CreateWindow(
szWinName, //name of window class as prmtr
"Window Skeleton", //Title
WS_OVERLAPPEDWINDOW, // Window Style: Normal
CW_USEDEFAULT, // X coordinate: Let Window Choose
CW_USEDEFAULT, // Y coordinate: Let Window Choose
CW_USEDEFAULT, // Width: Let Window Choose
CW_USEDEFAULT, // Height: Let Window Choose
HWND_DESKTOP, // No parent window
NULL, // As No Menu
hThisInst, // Handle to this Instance of the program
NULL // No Additional Arguments
);
/*Display The Window*/
ShowWindow(hwnd, nWinMode);
UpdateWindow(hwnd);
/*Creat The Message Loop*/
while(GetMessage(&msg, NULL, 0, 0)){
TranslateMessage(&msg); // Translate Keyboard Message
DispatchMessage(&msg); // Return Control To Window
}
return msg.wParam;
}
/*This Function Called By Window And Is Passed Message from queue*/
LRESULT CALLBACK WindowFunc(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); //Let window process message
}
return 0;
}