| 588 | } |
| 589 | |
| 590 | bool CMainFrame::LoadSettings() |
| 591 | { |
| 592 | auto mutex = Win32::CreateMutex(nullptr, false, L"Local\\DebugView++"); |
| 593 | Win32::MutexLock lock(mutex.get()); |
| 594 | |
| 595 | DWORD x, y, cx, cy; |
| 596 | CRegKey reg; |
| 597 | reg.Create(HKEY_CURRENT_USER, RegistryPath); |
| 598 | if (reg.QueryDWORDValue(L"X", x) == ERROR_SUCCESS && static_cast<int>(x) >= GetSystemMetrics(SM_XVIRTUALSCREEN) && |
| 599 | reg.QueryDWORDValue(L"Y", y) == ERROR_SUCCESS && static_cast<int>(y) >= GetSystemMetrics(SM_YVIRTUALSCREEN) && |
| 600 | reg.QueryDWORDValue(L"Width", cx) == ERROR_SUCCESS && static_cast<int>(x + cx) <= GetSystemMetrics(SM_CXVIRTUALSCREEN) && |
| 601 | reg.QueryDWORDValue(L"Height", cy) == ERROR_SUCCESS && static_cast<int>(y + cy) <= GetSystemMetrics(SM_CYVIRTUALSCREEN)) |
| 602 | SetWindowPos(0, x, y, cx, cy, SWP_NOZORDER); |
| 603 | |
| 604 | m_linkViews = Win32::RegGetDWORDValue(reg, L"LinkViews", 0) != 0; |
| 605 | m_logSources.SetAutoNewLine(Win32::RegGetDWORDValue(reg, L"AutoNewLine", 1) != 0); |
| 606 | SetAlwaysOnTop(Win32::RegGetDWORDValue(reg, L"AlwaysOnTop", 0) != 0); |
| 607 | |
| 608 | m_applicationName = Win32::RegGetStringValue(reg, L"ApplicationName", L"DebugView++"); |
| 609 | SetTitle(); |
| 610 | |
| 611 | m_hide = Win32::RegGetDWORDValue(reg, L"Hide", 0) != 0; |
| 612 | |
| 613 | auto fontName = Win32::RegGetStringValue(reg, L"FontName", L"").substr(0, LF_FACESIZE - 1); |
| 614 | int fontSize = Win32::RegGetDWORDValue(reg, L"FontSize", 8); |
| 615 | if (!fontName.empty()) |
| 616 | { |
| 617 | LOGFONT lf = { 0 }; |
| 618 | m_logfont = lf; |
| 619 | std::copy(fontName.begin(), fontName.end(), m_logfont.lfFaceName); |
| 620 | m_logfont.lfHeight = LogFontSizeFromPointSize(fontSize); |
| 621 | SetLogFont(); |
| 622 | } |
| 623 | |
| 624 | CRegKey regViews; |
| 625 | if (regViews.Open(reg, L"Views") == ERROR_SUCCESS) |
| 626 | { |
| 627 | for (size_t i = 0; ; ++i) |
| 628 | { |
| 629 | CRegKey regView; |
| 630 | if (regView.Open(regViews, WStr(wstringbuilder() << L"View" << i)) != ERROR_SUCCESS) |
| 631 | break; |
| 632 | |
| 633 | auto name = Win32::RegGetStringValue(regView); |
| 634 | if (i == 0) |
| 635 | GetTabCtrl().GetItem(0)->SetText(name.c_str()); |
| 636 | else |
| 637 | AddFilterView(name); |
| 638 | GetView().LoadSettings(regView); |
| 639 | } |
| 640 | GetTabCtrl().SetCurSel(Win32::RegGetDWORDValue(regViews, L"Current", 0)); |
| 641 | GetTabCtrl().UpdateLayout(); |
| 642 | GetTabCtrl().Invalidate(); |
| 643 | } |
| 644 | |
| 645 | CRegKey regColors; |
| 646 | if (regColors.Open(reg, L"Colors") == ERROR_SUCCESS) |
| 647 | { |
nothing calls this directly
no test coverage detected