From 252519effe30881825dd02e26dc41bd9cde34782 Mon Sep 17 00:00:00 2001 From: crupest Date: Mon, 5 Nov 2018 15:38:46 +0800 Subject: ... --- src/application.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'src/application.cpp') diff --git a/src/application.cpp b/src/application.cpp index 7658a340..2adab7c6 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -89,6 +89,17 @@ namespace cru { namespace { + CaretInfo GetSystemCaretInfo() + { + CaretInfo caret_info; + caret_info.caret_blink_duration = std::chrono::milliseconds(::GetCaretBlinkTime()); + DWORD caret_width; + if (!::SystemParametersInfoW(SPI_GETCARETWIDTH, 0 , &caret_width, 0)) + throw Win32Error(::GetLastError(), "Failed to get system caret width."); + caret_info.half_caret_width = caret_width / 2.0f; + return caret_info; + } + void LoadSystemCursor(HINSTANCE h_instance) { ui::cursors[ui::cursor_arrow_key] = std::make_shared(::LoadCursorW(h_instance, MAKEINTRESOURCEW(IDC_ARROW)), false); @@ -118,11 +129,7 @@ namespace cru { debug_layout_resource_.padding_brush = graph::CreateSolidBrush(D2D1::ColorF(D2D1::ColorF::SkyBlue, 0.25f)); #endif - caret_info_.caret_blink_duration = std::chrono::milliseconds(::GetCaretBlinkTime()); - DWORD caret_width; - if (!::SystemParametersInfoW(SPI_GETCARETWIDTH, 0 , &caret_width, 0)) - throw Win32Error(::GetLastError(), "Failed to get system caret width."); - caret_info_.half_caret_width = caret_width / 2.0f; + caret_info_ = GetSystemCaretInfo(); LoadSystemCursor(h_instance); } -- cgit v1.2.3