daydreamerz
September 26th, 2006, 07:11 PM
I want to start learning how to make windows applications using visual c++ express so I downloaded the microsoft platform sdk. I found this sample code on a website and I tried to run it just to see if I did eveything right.
#include <windows.h>
LRESULT WndProcedure(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
WNDCLASSEX WndClsEx;
WndClsEx.cbSize = sizeof(WNDCLASSEX);
WndClsEx.style = CS_HREDRAW | CS_VREDRAW;
WndClsEx.lpfnWndProc = WndProcedure;
WndClsEx.cbClsExtra = 0;
WndClsEx.cbWndExtra = 0;
WndClsEx.hInstance = hInstance;
return 0;
}
LRESULT CALLBACK WndProcedure(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
switch(Msg)
{
case WM_DESTROY:
PostQuitMessage(WM_QUIT);
break;
default:
return DefWindowProc(hWnd, Msg, wParam, lParam);
}
return 0;
}
and I got these errors
.\win.cpp(12) : error C2440: '=' : cannot convert from 'LRESULT (__cdecl *)(HWND,UINT,WPARAM,LPARAM)' to 'WNDPROC'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
.\win.cpp(21) : error C2373: 'WndProcedure' : redefinition; different type modifiers
.\win.cpp(3) : see declaration of 'WndProcedure'
so, I just wanted to know if there's something wrong within the program or did I not download everything right.
#include <windows.h>
LRESULT WndProcedure(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
WNDCLASSEX WndClsEx;
WndClsEx.cbSize = sizeof(WNDCLASSEX);
WndClsEx.style = CS_HREDRAW | CS_VREDRAW;
WndClsEx.lpfnWndProc = WndProcedure;
WndClsEx.cbClsExtra = 0;
WndClsEx.cbWndExtra = 0;
WndClsEx.hInstance = hInstance;
return 0;
}
LRESULT CALLBACK WndProcedure(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
switch(Msg)
{
case WM_DESTROY:
PostQuitMessage(WM_QUIT);
break;
default:
return DefWindowProc(hWnd, Msg, wParam, lParam);
}
return 0;
}
and I got these errors
.\win.cpp(12) : error C2440: '=' : cannot convert from 'LRESULT (__cdecl *)(HWND,UINT,WPARAM,LPARAM)' to 'WNDPROC'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
.\win.cpp(21) : error C2373: 'WndProcedure' : redefinition; different type modifiers
.\win.cpp(3) : see declaration of 'WndProcedure'
so, I just wanted to know if there's something wrong within the program or did I not download everything right.