nim_duilib/examples/basic/main.cpp

68 lines
1.9 KiB
C++
Raw Normal View History

2019-04-19 17:19:57 +08:00
// basic.cpp : 定义应用程序的入口点。
//
#include "stdafx.h"
#include "main.h"
#include "basic_form.h"
enum ThreadId
{
kThreadUI
};
2019-04-19 17:19:57 +08:00
int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
2021-09-15 17:37:26 +08:00
_In_opt_ HINSTANCE hPrevInstance,
_In_ LPWSTR lpCmdLine,
_In_ int nCmdShow)
2019-04-19 17:19:57 +08:00
{
2022-01-13 01:37:24 +08:00
//AllocConsole();
//freopen("CONOUT$", "w", stdout);
2021-09-15 17:37:26 +08:00
2019-04-19 17:19:57 +08:00
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);
// 创建主线程
MainThread thread;
// 执行主线程循环
thread.RunOnCurrentThreadWithLoop(nbase::MessageLoop::kUIMessageLoop);
return 0;
}
void MainThread::Init()
{
nbase::ThreadManager::RegisterThread(kThreadUI);
2019-04-19 17:19:57 +08:00
// 获取资源路径,初始化全局参数
std::wstring theme_dir = nbase::win32::GetCurrentModuleDirectory();
2019-04-19 17:19:57 +08:00
#ifdef _DEBUG
// Debug 模式下使用本地文件夹作为资源
// 默认皮肤使用 resources\\themes\\default
// 默认语言使用 resources\\lang\\zh_CN
// 如需修改请指定 Startup 最后两个参数
ui::GlobalManager::Startup(theme_dir + L"resources\\", ui::CreateControlCallback(), false);
#else
2021-09-15 17:37:26 +08:00
2019-04-19 17:19:57 +08:00
// Release 模式下使用资源中的压缩包作为资源
// 资源被导入到资源列表分类为 THEME资源名称为 IDR_THEME
// 如果资源使用的是本地的 zip 文件而非资源中的 zip 压缩包
// 可以使用 OpenResZip 另一个重载函数打开本地的资源压缩包
2021-09-15 17:37:26 +08:00
//ui::GlobalManager::OpenResZip(MAKEINTRESOURCE(IDR_THEME), L"THEME", "");
ui::GlobalManager::OpenResZip(L"resources.zip", "");
2019-04-19 17:19:57 +08:00
ui::GlobalManager::Startup(L"resources\\", ui::CreateControlCallback(), false);
#endif
// 创建一个默认带有阴影的居中窗口
BasicForm* window = new BasicForm();
window->Create(NULL, BasicForm::kClassName.c_str(), WS_OVERLAPPEDWINDOW & ~WS_MAXIMIZEBOX, 0);
window->CenterWindow();
window->ShowWindow();
}
void MainThread::Cleanup()
{
ui::GlobalManager::Shutdown();
SetThreadWasQuitProperly(true);
nbase::ThreadManager::UnregisterThread();
2021-09-15 17:37:26 +08:00
}