Hi Leute. Ich krieg die Krise. Das ist das erste Programm aus dem Buch "Win98 programmieren für Dummies" und es klappt nit. Es soll einfach ein Fenster erzeugt werden, in dem "Hello World " steht. Aber irgendwas geht bei CreateWindow schief. Hier ist das Programm
#include "windows.h"
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow );
LRESULT CALLBACK WindowProc(HWND hWnd,
UINT uMsgId,
WPARAM wParam,
LPARAM lParam);
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow )
{
static char szAppName[]= "Prog1";
HWND hWnd;
MSG msg;
WNDCLASSEX wndClass;
wndClass.style=0;
wndClass.lpfnWndProc=WindowProc;
wndClass.cbClsExtra=0;
wndClass.cbWndExtra=0;
wndClass.hInstance=hInstance;
wndClass.hIcon=LoadIcon(hInstance,szAppName);
wndClass.hCursor=LoadCursor(NULL,IDC_ARROW);
wndClass.hbrBackground= (HBRUSH) GetStockObject(WHITE_BRUSH);
wndClass.lpszMenuName=NULL;
wndClass.lpszClassName=szAppName;
wndClass.hIconSm=wndClass.hIcon;
if(RegisterClassEx(&wndClass)==0)
return 0;
hWnd=CreateWindow(szAppName,
szAppName,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL);
if(hWnd==NULL)
return 0;
ShowWindow(hWnd,nCmdShow);
UpdateWindow(hWnd);
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
LRESULT CALLBACK WindowProc(HWND hWnd,
UINT uMsgId,
WPARAM wParam,
LPARAM lParam)
{
static char *pszHello = " Hello World";
switch(uMsgId)
{
case WM_PAINT:
{
HDC hDC;
PAINTSTRUCT paintStruct;
hDC =BeginPaint (hWnd,&paintStruct);
TextOut(hDC,
0,
0,
pszHello,
lstrlen(pszHello));
EndPaint(hWnd,&paintStruct);
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default: return DefWindowProc(hWnd,uMsgId,wParam,lParam);
}
return 0;
}
Ich wäre sehr dankbar,wenn mir jemand helfen könnte!