GameLogic - Fixed the window class
This commit is contained in:
parent
b35ffdecfd
commit
1cb880a66e
|
@ -249,7 +249,4 @@ Global
|
|||
{52380DAA-0F4A-4D97-8E57-98DF39319CAF} = {20720CA7-795C-45AD-A302-9383A6DD503A}
|
||||
{8690FDDF-C5B7-4C42-A337-BD5243F29B85} = {20720CA7-795C-45AD-A302-9383A6DD503A}
|
||||
EndGlobalSection
|
||||
GlobalSection(Performance) = preSolution
|
||||
HasPerformanceSessions = true
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
#define NOMINMAX
|
||||
#include <Windows.h>
|
||||
|
||||
//#define DANBIAS_SERVER
|
||||
#define DANBIAS_CLIENT
|
||||
#define DANBIAS_SERVER
|
||||
//#define DANBIAS_CLIENT
|
||||
|
||||
|
||||
#if defined(DANBIAS_SERVER)
|
||||
|
|
|
@ -34,8 +34,14 @@ WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|||
((MINMAXINFO*)lParam)->ptMinTrackSize.y = 100;
|
||||
break;
|
||||
|
||||
case WM_KEYDOWN:
|
||||
if(wParam == VK_ESCAPE)
|
||||
PostQuitMessage(0);
|
||||
break;
|
||||
|
||||
default:
|
||||
return DefWindowProc(hwnd, msg, wParam, lParam);
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -84,39 +90,18 @@ int WINAPI WinMain( HINSTANCE hInst, HINSTANCE prevInst, PSTR cmdLine, int cmdSh
|
|||
{
|
||||
_CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
|
||||
|
||||
|
||||
|
||||
/********************************************
|
||||
* Description of a window *
|
||||
*******************************************/
|
||||
WindowShell::INIT_DESC_WINDOW wDesc;
|
||||
wDesc.hInstance = hInst;
|
||||
wDesc.windowName = L"Glare";
|
||||
wDesc.windowPosition = Point2D(50);
|
||||
wDesc.windowSize = Point2D(1024, 800);
|
||||
WindowShell::WINDOW_INIT_DESC wDesc;
|
||||
//wDesc.hInstance = hInst;
|
||||
wDesc.windowPosition.x = 50;
|
||||
wDesc.windowPosition.y = 50;
|
||||
wDesc.windowSize.x = 1024;
|
||||
wDesc.windowSize.x = 800;
|
||||
wDesc.windowProcCallback = WndProc;
|
||||
|
||||
|
||||
|
||||
/********************************************
|
||||
* Description of a child window *
|
||||
*******************************************/
|
||||
WindowShell::INIT_DESC_CHILD_WINDOW cDesc;
|
||||
cDesc.name = L"Child";
|
||||
cDesc.style = WS_EX_RIGHTSCROLLBAR;
|
||||
cDesc.topLeftPos = Point2D();
|
||||
cDesc.windowProcCallback = ChildWndProc;
|
||||
cDesc.windowSize = Point2D(80);
|
||||
|
||||
|
||||
|
||||
/************************************************************
|
||||
* Initializing main window and several children *
|
||||
************************************************************/
|
||||
WindowShell::self()->createWin(wDesc);
|
||||
WindowShell::self()->createChildWin(cDesc);
|
||||
WindowShell::self()->createChildWin(cDesc);
|
||||
WindowShell::self()->createChildWin(cDesc);
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -24,30 +24,30 @@
|
|||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v110</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v110</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v110</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v110</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
|
@ -138,6 +138,10 @@
|
|||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="WindowShell.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="WindowShell.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
|
|
|
@ -14,4 +14,14 @@
|
|||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="WindowShell.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="WindowShell.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -56,7 +56,7 @@ WindowShell::~WindowShell()
|
|||
|
||||
|
||||
|
||||
bool WindowShell::createWin(INIT_DESC_WINDOW &desc)
|
||||
bool WindowShell::createWin(WINDOW_INIT_DESC &desc)
|
||||
{
|
||||
if(pData->hWnd)
|
||||
{
|
||||
|
@ -68,14 +68,15 @@ bool WindowShell::createWin(INIT_DESC_WINDOW &desc)
|
|||
MessageBox(0, L"No callback function for window messages was found!" ,L"Error", 0);
|
||||
return false;
|
||||
}
|
||||
if(!desc.hInstance)
|
||||
{
|
||||
MessageBox(0, L"No HINSTANCE was specified!" ,L"Error", 0);
|
||||
return false;
|
||||
}
|
||||
if(desc.windowSize < 0)
|
||||
if(desc.windowSize.x < 0 || desc.windowSize.y < 0)
|
||||
{
|
||||
MessageBox(0, L"Size specified for window is invalid!" ,L"Error", 0);
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!desc.hInstance)
|
||||
{
|
||||
desc.hInstance = GetModuleHandle(0);
|
||||
}
|
||||
|
||||
|
||||
|
@ -87,7 +88,7 @@ bool WindowShell::createWin(INIT_DESC_WINDOW &desc)
|
|||
WNDCLASSEX wc;
|
||||
wc.cbSize = sizeof(WNDCLASSEX);
|
||||
wc.hIconSm = NULL;
|
||||
wc.style = CS_HREDRAW | CS_VREDRAW;
|
||||
wc.style = desc.windowClassStyle;
|
||||
wc.lpfnWndProc = desc.windowProcCallback;
|
||||
wc.cbClsExtra = 0;
|
||||
wc.cbWndExtra = 0;
|
||||
|
@ -112,7 +113,7 @@ bool WindowShell::createWin(INIT_DESC_WINDOW &desc)
|
|||
pData->hWnd = CreateWindow(
|
||||
L"MainWindowClass" ,
|
||||
desc.windowName.c_str(),
|
||||
WS_OVERLAPPEDWINDOW,
|
||||
desc.windowStyle,
|
||||
desc.windowPosition.x,
|
||||
desc.windowPosition.y,
|
||||
desc.windowSize.x,
|
||||
|
@ -138,7 +139,7 @@ bool WindowShell::createWin(INIT_DESC_WINDOW &desc)
|
|||
|
||||
return true;
|
||||
}
|
||||
int WindowShell::createChildWin(INIT_DESC_CHILD_WINDOW &desc)
|
||||
int WindowShell::createChildWin(CHILD_WINDOW_INIT_DESC &desc)
|
||||
{
|
||||
ChildWin win;
|
||||
|
||||
|
|
|
@ -5,72 +5,45 @@
|
|||
#include <string>
|
||||
|
||||
|
||||
struct Point2D
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
Point2D()
|
||||
{
|
||||
x = 0;
|
||||
y = 0;
|
||||
}
|
||||
Point2D(int _x, int _y)
|
||||
{
|
||||
x = _x;
|
||||
y = _y;
|
||||
}
|
||||
Point2D(int _p)
|
||||
{
|
||||
x = _p;
|
||||
y = _p;
|
||||
}
|
||||
operator POINT() const
|
||||
{
|
||||
return Point2D(x, y);
|
||||
}
|
||||
bool operator<(int i)
|
||||
{
|
||||
bool a = x<i;
|
||||
bool b = y<i;
|
||||
return (a || b);
|
||||
}
|
||||
};
|
||||
|
||||
class WindowShell
|
||||
{
|
||||
public:
|
||||
struct INIT_DESC_WINDOW
|
||||
struct WINDOW_INIT_DESC
|
||||
{
|
||||
HINSTANCE hInstance;
|
||||
std::wstring windowName;
|
||||
Point2D windowSize;
|
||||
Point2D windowPosition;
|
||||
POINT windowSize;
|
||||
POINT windowPosition;
|
||||
WNDPROC windowProcCallback;
|
||||
UINT windowClassStyle;
|
||||
UINT windowStyle;
|
||||
|
||||
INIT_DESC_WINDOW()
|
||||
WINDOW_INIT_DESC()
|
||||
{
|
||||
hInstance = NULL;
|
||||
windowName = L"Child window";
|
||||
windowName = L"MADAFACKA";
|
||||
windowSize.x = 800;
|
||||
windowSize.y = 600;
|
||||
windowPosition.x = 0;
|
||||
windowPosition.y = 0;
|
||||
windowProcCallback = NULL;
|
||||
windowClassStyle = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
|
||||
windowStyle = WS_OVERLAPPEDWINDOW;
|
||||
}
|
||||
};
|
||||
struct INIT_DESC_CHILD_WINDOW
|
||||
struct CHILD_WINDOW_INIT_DESC
|
||||
{
|
||||
std::wstring name;
|
||||
DWORD style;
|
||||
Point2D topLeftPos;
|
||||
Point2D windowSize;
|
||||
POINT topLeftPos;
|
||||
POINT windowSize;
|
||||
WNDPROC windowProcCallback;
|
||||
|
||||
INIT_DESC_CHILD_WINDOW()
|
||||
CHILD_WINDOW_INIT_DESC()
|
||||
{
|
||||
name = L"Child Window";
|
||||
style = WS_CHILD;
|
||||
topLeftPos = Point2D(0,0);
|
||||
memset(&topLeftPos, 0, sizeof(POINT));
|
||||
windowSize.x = 300;
|
||||
windowSize.y = 200;
|
||||
windowProcCallback = NULL;
|
||||
|
@ -94,9 +67,9 @@ class WindowShell
|
|||
const int getChildID (HWND hwnd) const;
|
||||
|
||||
/* Creates an empty window */
|
||||
bool createWin (INIT_DESC_WINDOW&);
|
||||
bool createWin (WINDOW_INIT_DESC&);
|
||||
/*Creates a child window and returns the id of child window or -1 if failed*/
|
||||
int createChildWin (INIT_DESC_CHILD_WINDOW&);
|
||||
int createChildWin (CHILD_WINDOW_INIT_DESC&);
|
||||
/* Removes a child window */
|
||||
bool removeChild (int id);
|
||||
/* Removes a child window */
|
||||
|
|
Loading…
Reference in New Issue