nim_duilib/examples/virtualbox/main.cpp
ATTIOT\zhengcy dca8b90bc0 no message
2021-09-15 17:37:26 +08:00

61 lines
1.3 KiB
C++

// VirtualBox.cpp : 定义应用程序的入口点。
//
#include "stdafx.h"
#include "main.h"
#include "main_form.h"
#include "VirtualTileBox.h"
enum ThreadId
{
kThreadUI
};
ui::Control* MyCreateControlCallback(const std::wstring& sName)
{
if (sName == L"VirtualTileBox")
{
return new VirtualTileBox();
}
return nullptr;
}
int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
_In_opt_ HINSTANCE hPrevInstance,
_In_ LPWSTR lpCmdLine,
_In_ int nCmdShow)
{
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);
// 创建主线程
MainThread thread;
// 执行主线程循环
thread.RunOnCurrentThreadWithLoop(nbase::MessageLoop::kUIMessageLoop);
return 0;
}
void MainThread::Init()
{
nbase::ThreadManager::RegisterThread(kThreadUI);
// 获取资源路径,初始化全局参数
std::wstring theme_dir = nbase::win32::GetCurrentModuleDirectory();
ui::GlobalManager::Startup(theme_dir + L"resources\\", MyCreateControlCallback, true);
// 创建一个默认带有阴影的居中窗口
MainForm* window = new MainForm();
window->Create(NULL, MainForm::kClassName.c_str(), WS_OVERLAPPEDWINDOW & ~WS_MAXIMIZEBOX, 0);
window->CenterWindow();
window->ShowWindow();
}
void MainThread::Cleanup()
{
ui::GlobalManager::Shutdown();
SetThreadWasQuitProperly(true);
nbase::ThreadManager::UnregisterThread();
}