添加窗口大小缩放

This commit is contained in:
zcy 2021-12-31 11:42:45 +08:00
parent c2ab898b1b
commit e8ec913705
2 changed files with 22 additions and 2 deletions

View File

@ -8,7 +8,7 @@ BasicForm::BasicForm():
mMonitorNewSelect(nullptr),
mRightShow(nullptr)
{
this->SetInitSize(1024, 768, true, false);
}
BasicForm::~BasicForm()
@ -30,10 +30,13 @@ std::wstring BasicForm::GetWindowClassName() const
{
return kClassName;
}
int gTcpServerCnt = 0;
int gTcpClientCnt = 0;
LRESULT BasicForm::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
wprintf(L"recv message 0x%x\r\n", uMsg);
if (uMsg == WM_ADD_UART_CLOSE) {
wprintf(L"close %s\r\n", ((wstring*)wParam)->c_str());
mRightShow->SetVisible(false);
@ -300,6 +303,20 @@ void BasicForm::InitWindow(){
mRightSide->RemoveAll();
this->SetMinInfo(1024, 768, true);
this->SetInitSize(1024, 768, false, false);
ui::UiRect maxRect = GetMaximizeInfo();
this->Invalidate(maxRect);
RECT rc;
//取当前窗口区域
GetClientRect(m_hWnd, &rc);
//改变窗口大小
//移动窗口到指定区域
::MoveWindow(m_hWnd, rc.left, rc.top, rc.right, rc.bottom, true);
}
LRESULT BasicForm::OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)

View File

@ -90,9 +90,12 @@ void MainThread::Init()
auto dpiManager = ui::DpiManager::GetInstance();
// 创建一个默认带有阴影的居中窗口
BasicForm* window = new BasicForm();
window->Create(NULL, BasicForm::kClassName.c_str(), WS_OVERLAPPEDWINDOW & ~WS_MAXIMIZEBOX & WS_SIZEBOX, 0);
window->Create(NULL, BasicForm::kClassName.c_str(),
WS_OVERLAPPEDWINDOW & WS_SIZEBOX,0,true, ui::UiRect(0,0,1024,768));
window->CenterWindow();
window->ShowWindow();
window->SetInitSize(1024,768);
}
void MainThread::Cleanup()