Okay men jeg får disse fejl i min kode:
C:\\BORLAND\\BCC55\\BIN>makeobj test
Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
test.cpp:
Error E2268 test.cpp 94: Call to undefined function 'GET_X_LPARAM' in function _
_stdcall MainWndProc(HWND__ *,unsigned int,unsigned int,long)
Error E2268 test.cpp 95: Call to undefined function 'GET_Y_LPARAM' in function _
_stdcall MainWndProc(HWND__ *,unsigned int,unsigned int,long)
*** 2 errors in Compile ***
kode
#include <windows.h>
#include <string>
HINSTANCE InstanceHandle;
HWND MainWindow;
HBITMAP SigteKorn;
UINT SigteWidth, SigteHeight;
int xPos;
int yPos;
LRESULT CALLBACK MainWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
HBITMAP LoadBMP(const char *FileName, UINT *Width, UINT *Height)
{
HBITMAP BitMap = (HBITMAP )LoadImage(0, FileName, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
if(!BitMap)
{
std::string Msg = "Failed to load image" + std::string(FileName);
MessageBox(0, Msg.c_str(), "BitMap", MB_OK);
}
else
{
BITMAP BitmapInfo;
GetObject(BitMap, sizeof(BITMAP), &BitmapInfo);
*Width = BitmapInfo.bmWidth;
*Height = BitmapInfo.bmHeight;
}
return BitMap;
}
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_BTNFACE + 1);
wc.lpszClassName = "SimpleWinWndClass";
wc.lpszMenuName = 0;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
if(!RegisterClass(&wc))
return 0;
SigteKorn = LoadBMP("sigte.bmp", &SigteWidth, &SigteHeight);
return CreateWindow("SimpleWinWndClass",
"Shooting",
WS_MINIMIZEBOX | WS_VISIBLE |
WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_MAXIMIZEBOX |
WS_CAPTION | WS_BORDER | WS_SYSMENU | WS_THICKFRAME,
100, 100, 720, 400,
0,
0,
InstanceHandle,
0);
}
void OnPaint(HWND hwnd)
{
PAINTSTRUCT PaintStruct;
HDC dc = BeginPaint(hwnd, &PaintStruct);
HDC MemDC = CreateCompatibleDC(dc);
HBITMAP OldBitmap = (HBITMAP )SelectObject(MemDC, SigteKorn);
BitBlt(dc, xPos, yPos, SigteWidth, SigteHeight, MemDC, 0, 0, SRCCOPY);
SelectObject(MemDC, OldBitmap);
DeleteObject(MemDC);
EndPaint(hwnd, &PaintStruct);
}
LRESULT CALLBACK MainWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg)
{
case WM_MOUSEMOVE:
xPos = GET_X_LPARAM(lParam);
yPos = GET_Y_LPARAM(lParam);
break;
case WM_PAINT:
OnPaint(hwnd);
break;
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;
}