nim_duilib/examples/controls/main.cpp

68 lines
1.7 KiB
C++
Raw Normal View History

2019-04-19 17:19:57 +08:00
// controls.cpp : 定义应用程序的入口点。
//
#include "stdafx.h"
#include "main.h"
#include "controls_form.h"
2021-09-15 17:37:26 +08:00
2019-04-19 17:19:57 +08:00
int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
_In_opt_ HINSTANCE hPrevInstance,
_In_ LPWSTR lpCmdLine,
_In_ int nCmdShow)
{
2022-01-13 01:37:24 +08:00
//AllocConsole();
//freopen("CONOUT$", "w", stdout);
2021-09-15 17:37:26 +08:00
auto dpiManager = ui::DpiManager::GetInstance();
dpiManager->SetAdaptDPI(); // 设置适配自动dpi
printf("dpi is %d\r\n",dpiManager->GetDPIFromRegistry());
2019-04-19 17:19:57 +08:00
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);
MainThread().RunOnCurrentThreadWithLoop(nbase::MessageLoop::kUIMessageLoop);
return 0;
}
void MiscThread::Init()
{
nbase::ThreadManager::RegisterThread(thread_id_);
}
void MiscThread::Cleanup()
{
nbase::ThreadManager::UnregisterThread();
}
2019-04-19 17:19:57 +08:00
void MainThread::Init()
{
nbase::ThreadManager::RegisterThread(kThreadUI);
2019-04-19 17:19:57 +08:00
// 启动杂事处理线程
misc_thread_.reset(new MiscThread(kThreadGlobalMisc, "Global Misc Thread"));
misc_thread_->Start();
// 获取资源路径,初始化全局参数
std::wstring app_dir = nbase::win32::GetCurrentModuleDirectory();
2019-04-19 17:19:57 +08:00
ui::GlobalManager::Startup(app_dir + L"resources\\", ui::CreateControlCallback(), false);
// 创建一个默认带有阴影的居中窗口
ControlForm* window = new ControlForm();
window->Create(NULL, ControlForm::kClassName.c_str(), WS_OVERLAPPEDWINDOW & ~WS_MAXIMIZEBOX, 0);
window->CenterWindow();
window->ShowWindow();
}
void MainThread::Cleanup()
{
ui::GlobalManager::Shutdown();
misc_thread_->Stop();
misc_thread_.reset(nullptr);
SetThreadWasQuitProperly(true);
nbase::ThreadManager::UnregisterThread();
}