Nu virker det
Men jeg har et lille problem med min kode jeg får fejlen:
error C2065: 'MainWndProc' : undeclared identifier
error C2365: 'MainWndProc' : redefinition; previous definition was 'formerly unknown identifier'
Og en warning:
warning C4244: 'return' : conversion from 'WPARAM' to 'int', possible loss of data
med denne kode:
#include "windows.h"
HINSTANCE InstanceHandle;
HWND MainWindow;
HWND CreateMainWindow ()
{
WNDCLASS wc;
memset(&wc, 0, sizeof(WNDCLASS));
wc.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
wc.lpfnWndProc = (WNDPROC)MainWndProc;
wc.hInstance = InstanceHandle;
wc.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1);
wc.lpszClassName = "SimpleWinWndClass";
wc.lpszMenuName = 0;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
if (!RegisterClass(&wc))
return 0;
return CreateWindow ("SimpleWinWndClass",
"Simple-window",
WS_MINIMIZEBOX | WS_VISIBLE |
WS_CLIPSIBLINGS | WS_CLIPCHILDREN |
WS_MAXIMIZEBOX | WS_CAPTION |
WS_BORDER | WS_SYSMENU | WS_THICKFRAME,
CW_USEDEFAULT, 0, CW_USEDEFAULT, 0,
0,
0,
InstanceHandle,
0);
}
LRESULT CALLBACK MainWndProc (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;
}
int WINAPI WinMain (HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
INT nCmdShow)
{
InstanceHandle = hInstance;
if ((MainWindow = CreateMainWindow()) == (HWND) 0)
{
MessageBox (0,
"Failed to create MainWindow!",
"Warning",
MB_OK);
return 0;
}
ShowWindow(MainWindow, SW_SHOW);
MSG Msg;
while (GetMessage(&Msg, 0, 0, 0))
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
return Msg.wParam;
}
- php-4ever
[Redigeret d. 08/02-05 13:21:06 af php-4ever]