What's wrong with my GUI code?
Code:
#include <windows.h>
/* Declare Windows procedure */
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
static char gszClassName[ ] = "SecSuite";
static HINSTANCE ghInstance=NULL;
int WINAPI WinMain (HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
WNDCLASSEX wincl; /* Data structure for the windowclass */
HWND hwnd; /* This is the handle for our window */
MSG Msg; /* Here messages to the application are saved */
ghInstance=hInstance;
/* The Window structure */
wincl.cbSize=sizeof (WNDCLASSEX);
wincl.style=CS_DBLCLKS;/* Catch double-clicks */
wincl.lpfnWndProc=WndProc;/* This function is called by windows */
wincl.cbClsExtra=0;/* No extra bytes after the window class */
wincl.cbWndExtra=0;/* structure or the window instance */
wincl.hInstance=ghInstance;
wincl.hIcon=LoadIcon(NULL,IDI_APPLICATION);
wincl.hCursor=LoadCursor(NULL,IDC_ARROW);
wincl.hbrBackground=(HBRUSH)(COLOR_WINDOW+1);
wincl.lpszMenuName=NULL;/* No menu */
wincl.lpszClassName=gszClassName;
wincl.hIconSm=LoadIcon(NULL,IDI_APPLICATION);
/* Register the window class, and if it fails quit the program */
if (!RegisterClassEx (&wincl))
{
MessageBox(0,"Error registering window!","Error",MB_ICONSTOP|MB_OK);
return 0;
}
/* The class is registered, let's create the program*/
hwnd = CreateWindowEx (
WS_EX_STATICEDGE, /* Extended possibilites for variation */
gszClassName, /* Classname */
"Woot", /* Title Text */
WS_OVERLAPPEDWINDOW, /* default window */
CW_USEDEFAULT, /* Windows decides the position */
CW_USEDEFAULT, /* where the window ends up on the screen */
320, /* The programs width */
240, /* and height in pixels */
NULL, /* The window is a child-window to desktop */
NULL, /* No menu */
ghInstance, /* Program Instance handler */
NULL /* No Window Creation data */
);
if(hwnd==NULL)
{
MessageBox(0,"Window creation failed!","Error",MB_ICONSTOP|MB_OK);
return 0;
}
/* Make the window visible on the screen */
ShowWindow (hwnd, nCmdShow);
UpdateWindow(hwnd);
while(GetMessage(&Msg,NULL,0,0))
{
TranslateMessage(&Msg);/* Translate virtual-key msgs into char msgs */
DispatchMessage(&Msg);/* Send message to WindowProcedure */
}
return Msg.wParam;
}
LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
HWND hButton,hCombo,hEdit,hList,hScroll,hStatic;
HDC hdc;
PAINTSTRUCT ps;
LPSTR szMessage="^_^";
switch (Message)/* handle the messages */
{
case WM_CREATE:
hButton=CreateWindowEx(NULL,"Button","Button Example",WS_BORDER|
WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON,0,0,100,30,hwnd,NULL,
ghInstance,NULL);
hCombo=CreateWindowEx(NULL,"ComboBox","Cj is the ........",WS_BORDER|
WS_CHILD,WS_VISIBLE,CBS_DROPDOWNLIST,0,30,100,100,hwnd,NULL,
ghInstance,NULL);
hEdit=CreateWindowEx(NULL,"Edit","edit box example",WS_BORDER|
WS_CHILD|WS_VISIBLE,0,60,100,30,hwnd,NULL,ghInstance,NULL);
hList=CreateWindowEx(NULL,"ListBox",">.<",WS_BORDER|WS_CHILD|
WS_VISIBLE,100,0,100,200,hwnd,NULL,ghInstance,NULL);
hScroll=CreateWindowEx(NULL,"ScrollBar","",WS_BORDER|WS_CHILD|
WS_VISIBLE|SBS_VERT,210,0,100,200,hwnd,NULL,ghInstance,NULL);
hStatic=CreateWindowEx(NULL,"Static","",WS_BORDER|WS_CHILD|
WS_VISIBLE|SS_BLACKRECT,0,90,100,30,hwnd,NULL,ghInstance,NULL);
break;
case WM_PAINT:
hdc=BeginPaint(hwnd,&ps);
TextOut(hdc,70,50,szMessage,strlen(szMessage));
EndPaint(hwnd,&ps);
break;
case WM_CLOSE:
DestroyWindow(hwnd);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:/* for messages that we don't deal with */
return DefWindowProc(hwnd, Message, wParam, lParam);
}
return 0;
}
All the errors are happining when It gets to case WM_CREATE (near the end) it's making no sense to me... I did the tutorial exactly how it told me to