Thank you rocky for your undying support, here is some snippets from the calling code and dll.
test.cpp (calling code)
----------------------------------------
Code:
#include "ArkCore.h"
ArkCore *AC;
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
{
if( !AC->ArkCreateWindow(hInstance, "test"))
return 0;
if( !AC->InitD3D(true, 640, 800))
return 0;
return AC->StartLoop();
}
ArkCore.dll - ArkCore.h
-----------------------------------------
Code:
#ifndef INC_ARKCORE_H
#define INC_ARKCORE_H
#include <d3d9.h>
#include <d3dx9.h>
#include <windows.h>
class __declspec(dllexport) ArkCore
{
protected:
HWND wndHandle;
HINSTANCE hInst;
LPDIRECT3D9 d3d;
LPDIRECT3DDEVICE9 device;
public:
HWND *GetHWND() { return &wndHandle; }
HINSTANCE *GetHINST() { return &hInst; }
bool ArkCreateWindow(HINSTANCE hInstance, char* Title); // Creates the window
bool InitD3D( bool Windowed, int BackBufferHeight, int BackBufferWidth ); // Initializes DirectX
int StartLoop(); // Controls the message loop
void Render();
void ShutDown();
static LRESULT CALLBACK MsgProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
{
//Check any available messages from the queue
switch(message)
{
case WM_CLOSE:
PostQuitMessage(WM_QUIT);
break;
case WM_DESTROY:
PostQuitMessage(WM_QUIT);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
};
#endif
ArkCore.dll - ArkCore.cpp (ArkCreateWindow)
-----------------------------------------------
Code:
bool ArkCore::ArkCreateWindow(HINSTANCE hInstance, char* Title)
{
hInst = hInstance;
WNDCLASSEX wcex;
/////Fill in the Window class structure - Describes how the window will look
wcex.cbSize = sizeof( WNDCLASSEX ); //size of the structure
wcex.style = CS_HREDRAW | CS_VREDRAW; //the class style
wcex.lpfnWndProc = (WNDPROC)MsgProc; //Window procedure callback
wcex.cbClsExtra = 0; //Extra class bytes
wcex.cbWndExtra = 0; //Extra window bytes
wcex.hInstance = hInstance; //Handle to the app instance
wcex.hIcon = NULL; // icon
wcex.hCursor = LoadCursor(NULL, IDC_ARROW); //cursor
wcex.hbrBackground = (HBRUSH)GetStockObject(GRAY_BRUSH); //bgcolor
wcex.lpszMenuName = NULL; //resource name for the menu
wcex.lpszClassName = "Arkhana"; //class name being created
wcex.hIconSm = NULL; //Small icon handle
RegisterClassEx( &wcex );
//Create the window
wndHandle = CreateWindow( "Arkhana", // Class name to use
Title, // Title bar text
WS_OVERLAPPEDWINDOW, //The window style
0, // The starting x coord
0, // The starting y coord
800, // The pixel height
600, // The pixel width
NULL, // The parent window, null for desktop
NULL, // The menu for the app - null for none
hInstance, // The handle to the app instance
NULL); // No values passed to the window
if( !wndHandle )
return false;
ShowWindow( wndHandle, SW_SHOW );
UpdateWindow( wndHandle );
return true;
}