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