Window appears in a flash! But also disappears as fast...
Hey, so I got round to making a non-compile-time error framework for a window to hold my DX applications later on in my programming life... BUT I've came across a problem, as most coders do, life isn't life without problems. :P Anyways, I build and debug my application, but it disappears as soon as it has executed... I've came across this in pure C++ programming, but never in Win32... I suppose I'll post the relevant code now:
DXEngine.h
Code:
#include "D3D.h"
#ifndef DXENGINE_H /*Inclusion guards*/
#define DXENGINE_H
namespace DXE /*Create a namespace to hold our functions and class*/
{
LRESULT CALLBACK lcWindowProc(HWND, UINT, WPARAM, LPARAM); /*Function to handle events that our window recieves*/
class DXEngine: public D3D
{
public:
DXEngine(); /*Constructor*/
void vSetWindowCharacteristics(HINSTANCE); /*Function to fill out windows class parameters*/
bool bCreateWindow(HINSTANCE); /*Function for creating the window*/
void vShowWindow(int); /*Function for showing the window*/
void vUpdateWindow(); /*Function for updating the window*/
bool bRegisterClass(); /*Function to register the window class*/
int iRunMessageLoop(); /*Function to wrap the message loop*/
private:
WNDCLASSEX m_WndClassEx; /*Private member variable*/
};
}
#endif /*DXENGINE_H*/
All of the above functions were defined in a separate source file.
WinMain.cpp
Code:
#include "DXEngine.h"
int WINAPI WinMain(HINSTANCE TemphInstance, /*Window instance*/
HINSTANCE hPrevIntance, /*Isn't used in Win32 programming*/
LPSTR CmdLine,
int nShowCmd)
{
DXE::DXEngine EngineInstance;
EngineInstance.vSetWindowCharacteristics(TemphInstance); /*Set the windows characteristics*/
EngineInstance.bRegisterClass(); /*Register the windows class*/
EngineInstance.bCreateWindow(TemphInstance); /*Create the window*/
EngineInstance.vShowWindow(nShowCmd); /*Show the window*/
EngineInstance.vUpdateWindow(); /*Update the window*/
return EngineInstance.iRunMessageLoop();
}
I'm not sure if I need to post the definition of my class, so I'll leave it out for now. Although holla if I need to. :P