Add main dialog

This commit is contained in:
Grayson Riffe 2023-08-30 14:50:34 -05:00
parent ba68c396d2
commit a0437093fb
8 changed files with 58 additions and 1 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
.vs/
build/
version.h
*.aps

BIN
WinChat/WinChat.rc Normal file

Binary file not shown.

View File

@ -94,8 +94,12 @@
<ClCompile Include="src\main.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="resource.h" />
<ClInclude Include="src\Application.h" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="WinChat.rc" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>

View File

@ -26,5 +26,13 @@
<ClInclude Include="src\Application.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="resource.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="WinChat.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
</Project>

17
WinChat/resource.h Normal file
View File

@ -0,0 +1,17 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by WinChat.rc
//
#define IDD_MAINDIALOG 101
#define IDC_STATICTITLE 1001
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 103
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1002
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

View File

@ -1,5 +1,7 @@
#include "Application.h"
#include "../resource.h"
namespace wc {
Application::Application(std::string& appName, std::string& appVersion)
: m_appName(appName)
@ -8,6 +10,25 @@ namespace wc {
std::printf("%s %s\n", m_appName.c_str(), m_appVersion.c_str());
}
void Application::run() {
HINSTANCE hInst = GetModuleHandle(NULL);
DialogBox(hInst, MAKEINTRESOURCE(IDD_MAINDIALOG), nullptr, (DLGPROC)dlgProc);
}
BOOL CALLBACK Application::dlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) {
switch (msg) {
case WM_INITDIALOG:
return TRUE;
case WM_CLOSE:
EndDialog(hWnd, 0);
return TRUE;
}
return FALSE;
}
Application::~Application() {
}

View File

@ -1,13 +1,19 @@
#pragma once
#include <string>
#include <Windows.h>
namespace wc {
class Application {
public:
Application(std::string& appName, std::string& appVersion);
void run();
~Application();
private:
static BOOL CALLBACK dlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
const std::string m_appName;
const std::string m_appVersion;
};

View File

@ -11,8 +11,8 @@ int main(int argc, char* argv[]) {
{
wc::Application app(appName, appVer);
app.run();
}
std::cin.get();
return EXIT_SUCCESS;
}