Original Post
Hey guys, Hope you guys can give me some assistance here. What I need to do is 'somehow' reference the function 'WinProc' for 'myWindow.lpfnWndProc' structure. The class 'Direct3DUtility' is separate from my main window class, hence I can't just easily reference the function name. I'm not sure how to do it. My idea is to pass in a 'WinProc' pointer to the function and use it but I'm so confused on this topic I just don't how to implement it. Main class Direct3DUtility interface class Direct3DUtility implementation class I understand that function pointers follow the syntax like so, 'return type (*functionName) (parameters)' but I'm having hard time understanding how to implement it. I've read heaps of stuff on the web and have a textbook which I've read also but I am still fuzzy. Some are just beyond my knowledge and not what I need and some are just brief. Can you guys give me some suggestions maybe... any help is appreciated guys :)
#include <Windows.h>
/* This function processes messages that the window recieves. */
LRESULT WINAPI WinProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
return DefWindowProc (hWnd, msg, wParam, lParam);
}
/* Equivalent to the 'main(){}' funtion in a console program. */
int WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
return 0;
}
#include <Windows.h>
class Direct3DUtility {
public:
void init3D( HINSTANCE hInstance );
};
#include "Direct3DUtility.h"
void Direct3DUtility::init3D( HINSTANCE hInstance ) {
WNDCLASSEX myWindow;
ZeroMemory( &myWindow, sizeof( WNDCLASSEX ));
myWindow.cbSize = sizeof( WNDCLASSEX );
myWindow.style = CS_CLASSDC;
myWindow.lpfnWndProc = &WinProc
myWindow.hInstance = hInstance;
myWindow.lpszClassName = "Star Fleet";
HWND hWnd = CreateWindow(
"Star Fleet",
"Prototype",
WS_OVERLAPPEDWINDOW,
100, 100,
300, 300,
GetDesktopWindow(),
NULL,
myWindow.hInstance,
NULL
);
}