hi...
My Code:
#include <windows.h>
#include <d3d8.h>
#include <iostream>
using namespace std;
LRESULT CALLBACK MainMsg(HWND, UINT, LPARAM, WPARAM);
bool RegisterWinClass(HINSTANCE, WNDPROC, LPSTR);
bool CreateWin(HWND&, HINSTANCE, LPSTR, LPSTR);
WPARAM MainLoop();
bool Inti(HWND&);
bool DestroyWin();
void ClearUp();
void Render();
HWND g_hWnd = NULL;
HDC g_hDc = NULL;
LPDIRECT3D8 g_pD3d = NULL;
LPDIRECT3DDEVICE8 g_pD3ddevice = NULL;
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpstrCmdLine, int iCmdShow)
{
if(!RegisterWinClass(hInstance, MainMsg, "DXTest"))
{
return -1;
}
CreateWin(g_hWnd, hInstance, "DXTest", "Direct X Test");
Inti(g_hWnd);
ShowWindow(g_hWnd, SW_SHOWDEFAULT);
UpdateWindow(g_hWnd);
return (int)MainLoop();
}
LRESULT CALLBACK MainMsg(HWND hWnd, UINT uiMsg, LPARAM lParam,
WPARAM wParam)
{
switch(uiMsg)
{
case WM_PAINT:
{
Render();
ValidateRect(g_hWnd, NULL);
break;
}
case WM_CREATE:
{
break;
}
case WM_CLOSE:
{
PostQuitMessage(0);
break;
}
case WM_DESTROY:
{
break;
}
default:
{
break;
}
}
return DefWindowProc(hWnd, uiMsg, lParam, wParam);
}
bool RegisterWinClass(HINSTANCE hInstance, WNDPROC wndProc, LPSTR className)
{
WNDCLASSEX wcx;
wcx.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
wcx.cbSize = sizeof(WNDCLASSEX);
wcx.hInstance = hInstance;
wcx.lpfnWndProc = wndProc;
wcx.lpszClassName = className;
wcx.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wcx.hCursor = LoadCursor(NULL, IDC_ARROW);
wcx.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wcx.hIconSm = LoadIcon(NULL, IDI_WINLOGO);
wcx.cbClsExtra = NULL;
wcx.cbWndExtra = NULL;
wcx.lpszMenuName = NULL;
if(!RegisterClassEx(&wcx))
{
return false;
}
return true;
}
bool CreateWin(HWND &hWnd, HINSTANCE hInstance, LPSTR className,
LPSTR winCaption)
{
hWnd = CreateWindowEx(NULL,
className,
winCaption,
WS_OVERLAPPEDWINDOW,
0,
0,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL);
if(!hWnd)
{
return false;
}
return true;
}
WPARAM MainLoop()
{
MSG msg;
bool done = false;
while(!done)
{
if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
if(msg.message == WM_QUIT)
{
done = true;
break;
}
TranslateMessage(&msg);
DispatchMessage(&msg);
}
else
{
}
}
ClearUp();
return msg.wParam;
}
Error:
c:\Dev\WinDXTest\main.cpp(25): error C2664: 'RegisterWinClass' : cannot convert parameter 2 from 'LRESULT (HWND,UINT,LPARAM,WPARAM)' to 'WNDPROC'
So far as I program it never happen before.......
[edited by - johnc82 on November 15, 2003 12:46:42 PM]