I thought wparam was an int? I get the following warning from MSVC.net:
...cpp(127): warning C4244: 'return' : conversion from 'WPARAM' to 'int', possible loss of data
Here is a snippet of my code. What am I doing wrong?
Code:
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR lpszCmdLine, int iCmdShow)
{
HWND hwnd;
MSG msg ;
WNDCLASS wndclass ;
wndclass.style = CS_HREDRAW | CS_VREDRAW ;
wndclass.lpfnWndProc = WndProc ;
wndclass.cbClsExtra = 0 ;
wndclass.cbWndExtra = 0 ;
wndclass.hInstance = hInstance ;
wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION);
wndclass.hCursor = LoadCursor (NULL, IDC_CROSS);
wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH);
wndclass.lpszMenuName = szAppName ;
wndclass.lpszClassName = szAppName ;
RegisterClass (&wndclass);
hMenu = LoadMenu (hInstance, MAKEINTRESOURCE(IDR_MENU1));
///////////////////////////////////////////////////////////////////////////////////////////////////
// Allow only one instance of program!
void* hMapping = CreateFileMapping(INVALID_HANDLE_VALUE, NULL,PAGE_READONLY, 0, 32, szAppName);
if (hMapping)// Check to see if app is already running
{
if (GetLastError() == ERROR_ALREADY_EXISTS)
{
SetForegroundWindow(FindWindow(szAppName, NULL));
{
CloseHandle(hMapping);
ExitProcess(1);
}
}
}
else
{
MessageBox(NULL, "Error creating file mapping.", "Error",MB_ICONERROR| MB_OK);
ExitProcess(1);
}
// End allow only one instance of program.
///////////////////////////////////////////////////////////////////////////////////////////////////
hwnd = CreateWindow (szAppName, szAppName, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT
, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, hMenu, hInstance, NULL);
if (!hwnd)
{
MessageBox(NULL, "failed window creation", "error", NULL);
return 0;
}
ShowWindow (hwnd, iCmdShow);
UpdateWindow (hwnd);
while (GetMessage (&msg, NULL, 0, 0))
{
TranslateMessage (&msg);
DispatchMessage (&msg);
}
return msg.wParam ;
}