no message
This commit is contained in:
parent
eadae2021d
commit
dca8b90bc0
@ -130,13 +130,14 @@
|
||||
<ProjectGuid>{8D9A6595-717A-41C8-B468-0011A72BE3D1}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>base</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>v120_xp</PlatformToolset>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
@ -149,7 +150,7 @@
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>v120_xp</PlatformToolset>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
@ -204,7 +205,7 @@
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;NOMINMAX;WITH_ENCRYPT;CURL_STATICLIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;NOMINMAX;CURL_STATICLIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<TreatWarningAsError>false</TreatWarningAsError>
|
||||
<AdditionalIncludeDirectories>.\;..\</AdditionalIncludeDirectories>
|
||||
<DisableSpecificWarnings>4100;4127;4244;4245;4310;4355;4505;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
@ -250,7 +251,7 @@
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;NOMINMAX;WITH_ENCRYPT;CURL_STATICLIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;NOMINMAX;CURL_STATICLIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<TreatWarningAsError>false</TreatWarningAsError>
|
||||
<AdditionalIncludeDirectories>.\;..\</AdditionalIncludeDirectories>
|
||||
<DisableSpecificWarnings>4100;4127;4189;4244;4245;4310;4355;4505;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
|
@ -70,7 +70,7 @@ private:
|
||||
|
||||
// The lock that protects access to target_message_loop_.
|
||||
mutable NLock message_loop_lock_;
|
||||
MessageLoop* target_message_loop_;
|
||||
nbase::MessageLoop* target_message_loop_;
|
||||
|
||||
private:
|
||||
// This relay class remembers the MessageLoop that it was created on, and
|
||||
|
@ -14,396 +14,392 @@
|
||||
|
||||
namespace nbase
|
||||
{
|
||||
static const wchar_t kWndClass[] = L"NeteaseMessagePumpWindow";
|
||||
static const unsigned int kMsgHaveWork = WM_USER + 1;
|
||||
static const int kUserTimerMinmum = 10;
|
||||
|
||||
static const wchar_t kWndClass[] = L"NeteaseMessagePumpWindow";
|
||||
static const unsigned int kMsgHaveWork = WM_USER + 1;
|
||||
static const int kUserTimerMinmum = 10;
|
||||
|
||||
WinUIMessagePump::WinUIMessagePump()
|
||||
{
|
||||
InitMessageWnd();
|
||||
}
|
||||
|
||||
WinUIMessagePump::~WinUIMessagePump()
|
||||
{
|
||||
::DestroyWindow(message_hwnd_);
|
||||
::UnregisterClassW(kWndClass, ::GetModuleHandle(NULL));
|
||||
}
|
||||
|
||||
void WinUIMessagePump::ScheduleWork()
|
||||
{
|
||||
if (::InterlockedExchange(&have_work_, 1))
|
||||
return; // Pump已经开始
|
||||
|
||||
// 通知MessagePump有新任务到达,如果MessagePump处于睡眠状态,这将唤醒它
|
||||
::PostMessageW(message_hwnd_, kMsgHaveWork, reinterpret_cast<WPARAM>(this), 0);
|
||||
}
|
||||
|
||||
void WinUIMessagePump::ScheduleDelayedWork(const TimeTicks& delayed_work_time)
|
||||
{
|
||||
//
|
||||
// We would *like* to provide high resolution timers. Windows timers using
|
||||
// SetTimer() have a 10ms granularity. We have to use WM_TIMER as a wakeup
|
||||
// mechanism because the application can enter modal windows loops where it
|
||||
// is not running our MessageLoop; the only way to have our timers fire in
|
||||
// these cases is to post messages there.
|
||||
//
|
||||
// To provide sub-10ms timers, we process timers directly from our run loop.
|
||||
// For the common case, timers will be processed there as the run loop does
|
||||
// its normal work. However, we *also* set the system timer so that WM_TIMER
|
||||
// events fire. This mops up the case of timers not being able to work in
|
||||
// modal message loops. It is possible for the SetTimer to pop and have no
|
||||
// pending timers, because they could have already been processed by the
|
||||
// run loop itself.
|
||||
//
|
||||
// We use a single SetTimer corresponding to the timer that will expire
|
||||
// soonest. As new timers are created and destroyed, we update SetTimer.
|
||||
// Getting a spurrious SetTimer event firing is benign, as we'll just be
|
||||
// processing an empty timer queue.
|
||||
//
|
||||
delayed_work_time_ = delayed_work_time;
|
||||
|
||||
DWORD wait_time;
|
||||
int64_t delay_msec = GetCurrentDelay();
|
||||
if (delay_msec < kUserTimerMinmum)
|
||||
wait_time = kUserTimerMinmum;
|
||||
else if (delay_msec < 0)
|
||||
wait_time = INFINITE;
|
||||
else if (delay_msec > 0xfffffffe)
|
||||
wait_time = 0xfffffffe;
|
||||
else
|
||||
wait_time = static_cast<DWORD>(delay_msec);
|
||||
|
||||
|
||||
// Create a WM_TIMER event that will wake us up to check for any pending
|
||||
// timers (in case we are running within a nested, external sub-pump).
|
||||
::SetTimer(message_hwnd_, reinterpret_cast<UINT_PTR>(this), wait_time, NULL);
|
||||
}
|
||||
|
||||
void WinUIMessagePump::PumpOutPendingPaintMessages()
|
||||
{
|
||||
// If we are being called outside of the context of Run, then don't try to do
|
||||
// any work.
|
||||
if (!state_)
|
||||
return;
|
||||
|
||||
// Create a mini-message-pump to force immediate processing of only Windows
|
||||
// WM_PAINT messages. Don't provide an infinite loop, but do enough peeking
|
||||
// to get the job done. Actual common max is 4 peeks, but we'll be a little
|
||||
// safe here.
|
||||
const int kMaxPeekCount = 20;
|
||||
int peek_count;
|
||||
for (peek_count = 0; peek_count < kMaxPeekCount; ++peek_count)
|
||||
WinUIMessagePump::WinUIMessagePump()
|
||||
{
|
||||
MSG msg;
|
||||
if (!::PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE | PM_QS_PAINT))
|
||||
break;
|
||||
ProcessMessageHelper(msg);
|
||||
if (state_->should_quit) // Handle WM_QUIT.
|
||||
break;
|
||||
InitMessageWnd();
|
||||
}
|
||||
}
|
||||
|
||||
void WinUIMessagePump::InitMessageWnd()
|
||||
{
|
||||
HINSTANCE hinst = ::GetModuleHandle(NULL);
|
||||
|
||||
WNDCLASSEXW wc = {0};
|
||||
wc.cbSize = sizeof(wc);
|
||||
wc.lpfnWndProc = WndProcThunk;
|
||||
wc.hInstance = hinst;
|
||||
wc.lpszClassName = kWndClass;
|
||||
::RegisterClassExW(&wc);
|
||||
|
||||
message_hwnd_ = ::CreateWindowW(kWndClass, 0, 0, 0, 0, 0, 0, HWND_MESSAGE, 0, hinst, 0);
|
||||
}
|
||||
|
||||
LRESULT CALLBACK WinUIMessagePump::WndProcThunk(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
|
||||
{
|
||||
switch (message)
|
||||
WinUIMessagePump::~WinUIMessagePump()
|
||||
{
|
||||
case kMsgHaveWork:
|
||||
reinterpret_cast<WinUIMessagePump*>(wparam)->HandleWorkMessage();
|
||||
break;
|
||||
case WM_TIMER:
|
||||
reinterpret_cast<WinUIMessagePump*>(wparam)->HandleTimerMessage();
|
||||
break;
|
||||
::DestroyWindow(message_hwnd_);
|
||||
::UnregisterClassW(kWndClass, ::GetModuleHandle(NULL));
|
||||
}
|
||||
return ::DefWindowProcW(hwnd, message, wparam, lparam);
|
||||
}
|
||||
|
||||
void WinUIMessagePump::DoRunLoop()
|
||||
{
|
||||
// IF this was just a simple ::PeekMessageW() loop (servicing all possible work
|
||||
// queues), then Windows would try to achieve the following order according
|
||||
// to MSDN documentation about ::PeekMessageW with no filter):
|
||||
// * Sent messages
|
||||
// * Posted messages
|
||||
// * Sent messages (again)
|
||||
// * WM_PAINT messages
|
||||
// * WM_TIMER messages
|
||||
//
|
||||
// Summary: none of the above classes is starved, and sent messages has twice
|
||||
// the chance of being processed (i.e., reduced service time).
|
||||
|
||||
for (;;)
|
||||
void WinUIMessagePump::ScheduleWork()
|
||||
{
|
||||
// If we do any work, we may create more messages etc., and more work may
|
||||
// possibly be waiting in another task group. When we (for example)
|
||||
// ProcessNextWindowsMessage(), there is a good chance there are still more
|
||||
// messages waiting. On the other hand, when any of these methods return
|
||||
// having done no work, then it is pretty unlikely that calling them again
|
||||
// quickly will find any work to do. Finally, if they all say they had no
|
||||
// work, then it is a good time to consider sleeping (waiting) for more
|
||||
// work.
|
||||
if (::InterlockedExchange(&have_work_, 1))
|
||||
return; // Pump已经开始
|
||||
|
||||
bool more_work_is_plausible = ProcessNextWindowsMessage();
|
||||
if (state_->should_quit)
|
||||
break;
|
||||
|
||||
more_work_is_plausible |= state_->delegate->DoWork();
|
||||
if (state_->should_quit)
|
||||
break;
|
||||
|
||||
more_work_is_plausible |=
|
||||
state_->delegate->DoDelayedWork(&delayed_work_time_);
|
||||
// If we did not process any delayed work, then we can assume that our
|
||||
// existing WM_TIMER if any will fire when delayed work should run. We
|
||||
// don't want to disturb that timer if it is already in flight. However,
|
||||
// if we did do all remaining delayed work, then lets kill the WM_TIMER.
|
||||
if (more_work_is_plausible && delayed_work_time_.is_null())
|
||||
KillTimer(message_hwnd_, reinterpret_cast<UINT_PTR>(this));
|
||||
if (state_->should_quit)
|
||||
break;
|
||||
|
||||
if (more_work_is_plausible)
|
||||
continue;
|
||||
|
||||
more_work_is_plausible = state_->delegate->DoIdleWork();
|
||||
if (state_->should_quit)
|
||||
break;
|
||||
|
||||
if (more_work_is_plausible)
|
||||
continue;
|
||||
|
||||
WaitForWork(); // Wait (sleep) until we have work to do again.
|
||||
// 通知MessagePump有新任务到达,如果MessagePump处于睡眠状态,这将唤醒它
|
||||
::PostMessageW(message_hwnd_, kMsgHaveWork, reinterpret_cast<WPARAM>(this), 0);
|
||||
}
|
||||
}
|
||||
|
||||
void WinUIMessagePump::WaitForWork()
|
||||
{
|
||||
// Wait until a message is available, up to the time needed by the timer
|
||||
// manager to fire the next set of timers.
|
||||
int64_t delay = GetCurrentDelay();
|
||||
DWORD wait_time;
|
||||
if (delay < 0) // Negative value means no timers waiting.
|
||||
wait_time = INFINITE;
|
||||
else if (delay > 0xfffffffe)
|
||||
wait_time = 0xfffffffe;
|
||||
else
|
||||
wait_time = static_cast<DWORD>(delay);
|
||||
|
||||
DWORD result = ::MsgWaitForMultipleObjectsEx(0, NULL, wait_time, QS_ALLINPUT, MWMO_INPUTAVAILABLE);
|
||||
|
||||
if (WAIT_OBJECT_0 == result)
|
||||
void WinUIMessagePump::ScheduleDelayedWork(const TimeTicks& delayed_work_time)
|
||||
{
|
||||
// A WM_* message is available.
|
||||
// If a parent child relationship exists between windows across threads
|
||||
// then their thread inputs are implicitly attached.
|
||||
// This causes the MsgWaitForMultipleObjectsEx API to return indicating
|
||||
// that messages are ready for processing (specifically mouse messages
|
||||
// intended for the child window. Occurs if the child window has capture)
|
||||
// The subsequent PeekMessages call fails to return any messages thus
|
||||
// causing us to enter a tight loop at times.
|
||||
// The WaitMessage call below is a workaround to give the child window
|
||||
// sometime to process its input messages.
|
||||
MSG msg = {0};
|
||||
DWORD queue_status = ::GetQueueStatus(QS_MOUSE);
|
||||
if (HIWORD(queue_status) & QS_MOUSE && !::PeekMessageW(&msg, NULL, WM_MOUSEFIRST, WM_MOUSELAST, PM_NOREMOVE))
|
||||
//
|
||||
// We would *like* to provide high resolution timers. Windows timers using
|
||||
// SetTimer() have a 10ms granularity. We have to use WM_TIMER as a wakeup
|
||||
// mechanism because the application can enter modal windows loops where it
|
||||
// is not running our MessageLoop; the only way to have our timers fire in
|
||||
// these cases is to post messages there.
|
||||
//
|
||||
// To provide sub-10ms timers, we process timers directly from our run loop.
|
||||
// For the common case, timers will be processed there as the run loop does
|
||||
// its normal work. However, we *also* set the system timer so that WM_TIMER
|
||||
// events fire. This mops up the case of timers not being able to work in
|
||||
// modal message loops. It is possible for the SetTimer to pop and have no
|
||||
// pending timers, because they could have already been processed by the
|
||||
// run loop itself.
|
||||
//
|
||||
// We use a single SetTimer corresponding to the timer that will expire
|
||||
// soonest. As new timers are created and destroyed, we update SetTimer.
|
||||
// Getting a spurrious SetTimer event firing is benign, as we'll just be
|
||||
// processing an empty timer queue.
|
||||
//
|
||||
delayed_work_time_ = delayed_work_time;
|
||||
|
||||
DWORD wait_time;
|
||||
int64_t delay_msec = GetCurrentDelay();
|
||||
if (delay_msec < kUserTimerMinmum)
|
||||
wait_time = kUserTimerMinmum;
|
||||
else if (delay_msec < 0)
|
||||
wait_time = INFINITE;
|
||||
else if (delay_msec > 0xfffffffe)
|
||||
wait_time = 0xfffffffe;
|
||||
else
|
||||
wait_time = static_cast<DWORD>(delay_msec);
|
||||
|
||||
// Create a WM_TIMER event that will wake us up to check for any pending
|
||||
// timers (in case we are running within a nested, external sub-pump).
|
||||
::SetTimer(message_hwnd_, reinterpret_cast<UINT_PTR>(this), wait_time, NULL);
|
||||
}
|
||||
|
||||
void WinUIMessagePump::PumpOutPendingPaintMessages()
|
||||
{
|
||||
// If we are being called outside of the context of Run, then don't try to do
|
||||
// any work.
|
||||
if (!state_)
|
||||
return;
|
||||
|
||||
// Create a mini-message-pump to force immediate processing of only Windows
|
||||
// WM_PAINT messages. Don't provide an infinite loop, but do enough peeking
|
||||
// to get the job done. Actual common max is 4 peeks, but we'll be a little
|
||||
// safe here.
|
||||
const int kMaxPeekCount = 20;
|
||||
int peek_count;
|
||||
for (peek_count = 0; peek_count < kMaxPeekCount; ++peek_count)
|
||||
{
|
||||
WaitMessage();
|
||||
MSG msg;
|
||||
if (!::PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE | PM_QS_PAINT))
|
||||
break;
|
||||
ProcessMessageHelper(msg);
|
||||
if (state_->should_quit) // Handle WM_QUIT.
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void WinUIMessagePump::HandleWorkMessage()
|
||||
{
|
||||
// If we are being called outside of the context of Run, then don't try to do
|
||||
// any work. This could correspond to a MessageBox call or something of that
|
||||
// sort.
|
||||
if (!state_)
|
||||
{
|
||||
// Since we handled a kMsgHaveWork message, we must still update this flag.
|
||||
::InterlockedExchange(&have_work_, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
// Let whatever would have run had we not been putting messages in the queue
|
||||
// run now. This is an attempt to make our dummy message not starve other
|
||||
// messages that may be in the Windows message queue.
|
||||
ProcessPumpReplacementMessage();
|
||||
|
||||
// Now give the delegate a chance to do some work. He'll let us know if he
|
||||
// needs to do more work.
|
||||
if (state_->delegate->DoWork())
|
||||
ScheduleWork();
|
||||
}
|
||||
|
||||
void WinUIMessagePump::HandleTimerMessage()
|
||||
{
|
||||
::KillTimer(message_hwnd_, reinterpret_cast<UINT_PTR>(this));
|
||||
|
||||
// If we are being called outside of the context of Run, then don't do
|
||||
// anything. This could correspond to a MessageBox call or something of
|
||||
// that sort.
|
||||
if (!state_)
|
||||
return;
|
||||
|
||||
state_->delegate->DoDelayedWork(&delayed_work_time_);
|
||||
if (!delayed_work_time_.is_null())
|
||||
void WinUIMessagePump::InitMessageWnd()
|
||||
{
|
||||
// A bit gratuitous to set delayed_work_time_ again, but oh well.
|
||||
ScheduleDelayedWork(delayed_work_time_);
|
||||
}
|
||||
}
|
||||
HINSTANCE hinst = ::GetModuleHandle(NULL);
|
||||
|
||||
bool WinUIMessagePump::ProcessNextWindowsMessage()
|
||||
{
|
||||
// If there are sent messages in the queue then PeekMessage internally
|
||||
// dispatches the message and returns false. We return true in this
|
||||
// case to ensure that the message loop peeks again instead of calling
|
||||
// MsgWaitForMultipleObjectsEx again.
|
||||
bool sent_messages_in_queue = false;
|
||||
DWORD queue_status = ::GetQueueStatus(QS_SENDMESSAGE);
|
||||
if (HIWORD(queue_status) & QS_SENDMESSAGE)
|
||||
sent_messages_in_queue = true;
|
||||
WNDCLASSEXW wc = { 0 };
|
||||
wc.cbSize = sizeof(wc);
|
||||
wc.lpfnWndProc = WndProcThunk;
|
||||
wc.hInstance = hinst;
|
||||
wc.lpszClassName = kWndClass;
|
||||
::RegisterClassExW(&wc);
|
||||
|
||||
MSG msg;
|
||||
if (::PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE))
|
||||
return ProcessMessageHelper(msg);
|
||||
|
||||
return sent_messages_in_queue;
|
||||
}
|
||||
|
||||
bool WinUIMessagePump::ProcessMessageHelper(const MSG& msg)
|
||||
{
|
||||
if (WM_QUIT == msg.message)
|
||||
{
|
||||
// Repost the QUIT message so that it will be retrieved by the primary
|
||||
// GetMessage() loop.
|
||||
state_->should_quit = true;
|
||||
::PostQuitMessage(static_cast<int>(msg.wParam));
|
||||
return false;
|
||||
message_hwnd_ = ::CreateWindowW(kWndClass, 0, 0, 0, 0, 0, 0, HWND_MESSAGE, 0, hinst, 0);
|
||||
}
|
||||
|
||||
// While running our main message pump, we discard kMsgHaveWork messages.
|
||||
if (msg.message == kMsgHaveWork && msg.hwnd == message_hwnd_)
|
||||
return ProcessPumpReplacementMessage();
|
||||
|
||||
if (::CallMsgFilter(const_cast<MSG*>(&msg), kMessageFilterCode))
|
||||
return true;
|
||||
|
||||
PreProcessMessage(msg);
|
||||
|
||||
if (state_->dispatcher)
|
||||
LRESULT CALLBACK WinUIMessagePump::WndProcThunk(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
|
||||
{
|
||||
if (!state_->dispatcher->Dispatch(msg))
|
||||
switch (message)
|
||||
{
|
||||
case kMsgHaveWork:
|
||||
reinterpret_cast<WinUIMessagePump*>(wparam)->HandleWorkMessage();
|
||||
break;
|
||||
case WM_TIMER:
|
||||
reinterpret_cast<WinUIMessagePump*>(wparam)->HandleTimerMessage();
|
||||
break;
|
||||
}
|
||||
return ::DefWindowProcW(hwnd, message, wparam, lparam);
|
||||
}
|
||||
|
||||
void WinUIMessagePump::DoRunLoop()
|
||||
{
|
||||
// IF this was just a simple ::PeekMessageW() loop (servicing all possible work
|
||||
// queues), then Windows would try to achieve the following order according
|
||||
// to MSDN documentation about ::PeekMessageW with no filter):
|
||||
// * Sent messages
|
||||
// * Posted messages
|
||||
// * Sent messages (again)
|
||||
// * WM_PAINT messages
|
||||
// * WM_TIMER messages
|
||||
//
|
||||
// Summary: none of the above classes is starved, and sent messages has twice
|
||||
// the chance of being processed (i.e., reduced service time).
|
||||
|
||||
for (;;)
|
||||
{
|
||||
// If we do any work, we may create more messages etc., and more work may
|
||||
// possibly be waiting in another task group. When we (for example)
|
||||
// ProcessNextWindowsMessage(), there is a good chance there are still more
|
||||
// messages waiting. On the other hand, when any of these methods return
|
||||
// having done no work, then it is pretty unlikely that calling them again
|
||||
// quickly will find any work to do. Finally, if they all say they had no
|
||||
// work, then it is a good time to consider sleeping (waiting) for more
|
||||
// work.
|
||||
|
||||
bool more_work_is_plausible = ProcessNextWindowsMessage();
|
||||
if (state_->should_quit)
|
||||
break;
|
||||
|
||||
more_work_is_plausible |= state_->delegate->DoWork();
|
||||
if (state_->should_quit)
|
||||
break;
|
||||
|
||||
more_work_is_plausible |=
|
||||
state_->delegate->DoDelayedWork(&delayed_work_time_);
|
||||
// If we did not process any delayed work, then we can assume that our
|
||||
// existing WM_TIMER if any will fire when delayed work should run. We
|
||||
// don't want to disturb that timer if it is already in flight. However,
|
||||
// if we did do all remaining delayed work, then lets kill the WM_TIMER.
|
||||
if (more_work_is_plausible && delayed_work_time_.is_null())
|
||||
KillTimer(message_hwnd_, reinterpret_cast<UINT_PTR>(this));
|
||||
if (state_->should_quit)
|
||||
break;
|
||||
|
||||
if (more_work_is_plausible)
|
||||
continue;
|
||||
|
||||
more_work_is_plausible = state_->delegate->DoIdleWork();
|
||||
if (state_->should_quit)
|
||||
break;
|
||||
|
||||
if (more_work_is_plausible)
|
||||
continue;
|
||||
|
||||
WaitForWork(); // Wait (sleep) until we have work to do again.
|
||||
}
|
||||
}
|
||||
|
||||
void WinUIMessagePump::WaitForWork()
|
||||
{
|
||||
// Wait until a message is available, up to the time needed by the timer
|
||||
// manager to fire the next set of timers.
|
||||
int64_t delay = GetCurrentDelay();
|
||||
DWORD wait_time;
|
||||
if (delay < 0) // Negative value means no timers waiting.
|
||||
wait_time = INFINITE;
|
||||
else if (delay > 0xfffffffe)
|
||||
wait_time = 0xfffffffe;
|
||||
else
|
||||
wait_time = static_cast<DWORD>(delay);
|
||||
|
||||
DWORD result = ::MsgWaitForMultipleObjectsEx(0, NULL, wait_time, QS_ALLINPUT, MWMO_INPUTAVAILABLE);
|
||||
|
||||
if (WAIT_OBJECT_0 == result)
|
||||
{
|
||||
// A WM_* message is available.
|
||||
// If a parent child relationship exists between windows across threads
|
||||
// then their thread inputs are implicitly attached.
|
||||
// This causes the MsgWaitForMultipleObjectsEx API to return indicating
|
||||
// that messages are ready for processing (specifically mouse messages
|
||||
// intended for the child window. Occurs if the child window has capture)
|
||||
// The subsequent PeekMessages call fails to return any messages thus
|
||||
// causing us to enter a tight loop at times.
|
||||
// The WaitMessage call below is a workaround to give the child window
|
||||
// sometime to process its input messages.
|
||||
MSG msg = { 0 };
|
||||
DWORD queue_status = ::GetQueueStatus(QS_MOUSE);
|
||||
if (HIWORD(queue_status) & QS_MOUSE && !::PeekMessageW(&msg, NULL, WM_MOUSEFIRST, WM_MOUSELAST, PM_NOREMOVE))
|
||||
{
|
||||
WaitMessage();
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void WinUIMessagePump::HandleWorkMessage()
|
||||
{
|
||||
// If we are being called outside of the context of Run, then don't try to do
|
||||
// any work. This could correspond to a MessageBox call or something of that
|
||||
// sort.
|
||||
if (!state_)
|
||||
{
|
||||
// Since we handled a kMsgHaveWork message, we must still update this flag.
|
||||
::InterlockedExchange(&have_work_, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
// Let whatever would have run had we not been putting messages in the queue
|
||||
// run now. This is an attempt to make our dummy message not starve other
|
||||
// messages that may be in the Windows message queue.
|
||||
ProcessPumpReplacementMessage();
|
||||
|
||||
// Now give the delegate a chance to do some work. He'll let us know if he
|
||||
// needs to do more work.
|
||||
if (state_->delegate->DoWork())
|
||||
ScheduleWork();
|
||||
}
|
||||
|
||||
void WinUIMessagePump::HandleTimerMessage()
|
||||
{
|
||||
::KillTimer(message_hwnd_, reinterpret_cast<UINT_PTR>(this));
|
||||
|
||||
// If we are being called outside of the context of Run, then don't do
|
||||
// anything. This could correspond to a MessageBox call or something of
|
||||
// that sort.
|
||||
if (!state_)
|
||||
return;
|
||||
|
||||
state_->delegate->DoDelayedWork(&delayed_work_time_);
|
||||
if (!delayed_work_time_.is_null())
|
||||
{
|
||||
// A bit gratuitous to set delayed_work_time_ again, but oh well.
|
||||
ScheduleDelayedWork(delayed_work_time_);
|
||||
}
|
||||
}
|
||||
|
||||
bool WinUIMessagePump::ProcessNextWindowsMessage()
|
||||
{
|
||||
// If there are sent messages in the queue then PeekMessage internally
|
||||
// dispatches the message and returns false. We return true in this
|
||||
// case to ensure that the message loop peeks again instead of calling
|
||||
// MsgWaitForMultipleObjectsEx again.
|
||||
bool sent_messages_in_queue = false;
|
||||
DWORD queue_status = ::GetQueueStatus(QS_SENDMESSAGE);
|
||||
if (HIWORD(queue_status) & QS_SENDMESSAGE)
|
||||
sent_messages_in_queue = true;
|
||||
|
||||
MSG msg;
|
||||
if (::PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE))
|
||||
return ProcessMessageHelper(msg);
|
||||
|
||||
return sent_messages_in_queue;
|
||||
}
|
||||
|
||||
bool WinUIMessagePump::ProcessMessageHelper(const MSG& msg)
|
||||
{
|
||||
if (WM_QUIT == msg.message)
|
||||
{
|
||||
// Repost the QUIT message so that it will be retrieved by the primary
|
||||
// GetMessage() loop.
|
||||
state_->should_quit = true;
|
||||
::PostQuitMessage(static_cast<int>(msg.wParam));
|
||||
return false;
|
||||
}
|
||||
|
||||
// While running our main message pump, we discard kMsgHaveWork messages.
|
||||
if (msg.message == kMsgHaveWork && msg.hwnd == message_hwnd_)
|
||||
return ProcessPumpReplacementMessage();
|
||||
|
||||
if (::CallMsgFilter(const_cast<MSG*>(&msg), kMessageFilterCode))
|
||||
return true;
|
||||
|
||||
PreProcessMessage(msg);
|
||||
|
||||
if (state_->dispatcher)
|
||||
{
|
||||
if (!state_->dispatcher->Dispatch(msg))
|
||||
state_->should_quit = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
|
||||
PostProcessMessage(msg);
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
|
||||
bool WinUIMessagePump::ProcessPumpReplacementMessage()
|
||||
{
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
// When we encounter a kMsgHaveWork message, this method is called to peek
|
||||
// and process a replacement message, such as a WM_PAINT or WM_TIMER. The
|
||||
// goal is to make the kMsgHaveWork as non-intrusive as possible, even though
|
||||
// a continuous stream of such messages are posted. This method carefully
|
||||
// peeks a message while there is no chance for a kMsgHaveWork to be pending,
|
||||
// then resets the have_work_ flag (allowing a replacement kMsgHaveWork to
|
||||
// possibly be posted), and finally dispatches that peeked replacement. Note
|
||||
// that the re-post of kMsgHaveWork may be asynchronous to this thread!!
|
||||
|
||||
bool have_message = false;
|
||||
MSG msg;
|
||||
// We should not process all window messages if we are in the context of an
|
||||
// OS modal loop, i.e. in the context of a windows API call like MessageBox.
|
||||
// This is to ensure that these messages are peeked out by the OS modal loop.
|
||||
if (MessageLoop::current()->os_modal_loop())
|
||||
{
|
||||
// We only peek out WM_PAINT and WM_TIMER here for reasons mentioned above.
|
||||
have_message = ::PeekMessageW(&msg, NULL, WM_PAINT, WM_PAINT, PM_REMOVE) ||
|
||||
::PeekMessageW(&msg, NULL, WM_TIMER, WM_TIMER, PM_REMOVE);
|
||||
}
|
||||
else
|
||||
{
|
||||
have_message = (0 != ::PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE));
|
||||
}
|
||||
|
||||
// Since we discarded a kMsgHaveWork message, we must update the flag.
|
||||
::InterlockedExchange(&have_work_, 0);
|
||||
|
||||
// We don't need a special time slice if we didn't have_message to process.
|
||||
if (!have_message)
|
||||
return false;
|
||||
|
||||
// Guarantee we'll get another time slice in the case where we go into native
|
||||
// windows code. This ScheduleWork() may hurt performance a tiny bit when
|
||||
// tasks appear very infrequently, but when the event queue is busy, the
|
||||
// kMsgHaveWork events get (percentage wise) rarer and rarer.
|
||||
ScheduleWork();
|
||||
|
||||
return ProcessMessageHelper(msg);
|
||||
}
|
||||
|
||||
PostProcessMessage(msg);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WinUIMessagePump::ProcessPumpReplacementMessage()
|
||||
{
|
||||
// When we encounter a kMsgHaveWork message, this method is called to peek
|
||||
// and process a replacement message, such as a WM_PAINT or WM_TIMER. The
|
||||
// goal is to make the kMsgHaveWork as non-intrusive as possible, even though
|
||||
// a continuous stream of such messages are posted. This method carefully
|
||||
// peeks a message while there is no chance for a kMsgHaveWork to be pending,
|
||||
// then resets the have_work_ flag (allowing a replacement kMsgHaveWork to
|
||||
// possibly be posted), and finally dispatches that peeked replacement. Note
|
||||
// that the re-post of kMsgHaveWork may be asynchronous to this thread!!
|
||||
|
||||
bool have_message = false;
|
||||
MSG msg;
|
||||
// We should not process all window messages if we are in the context of an
|
||||
// OS modal loop, i.e. in the context of a windows API call like MessageBox.
|
||||
// This is to ensure that these messages are peeked out by the OS modal loop.
|
||||
if (MessageLoop::current()->os_modal_loop())
|
||||
void WinUIMessagePump::AddObserver(UIObserver* observer)
|
||||
{
|
||||
// We only peek out WM_PAINT and WM_TIMER here for reasons mentioned above.
|
||||
have_message = ::PeekMessageW(&msg, NULL, WM_PAINT, WM_PAINT, PM_REMOVE) ||
|
||||
::PeekMessageW(&msg, NULL, WM_TIMER, WM_TIMER, PM_REMOVE);
|
||||
observers_.AddObserver(observer);
|
||||
}
|
||||
else
|
||||
|
||||
void WinUIMessagePump::RemoveObserver(UIObserver* observer)
|
||||
{
|
||||
have_message = (0 != ::PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE));
|
||||
observers_.RemoveObserver(observer);
|
||||
}
|
||||
|
||||
// Since we discarded a kMsgHaveWork message, we must update the flag.
|
||||
::InterlockedExchange(&have_work_, 0);
|
||||
|
||||
// We don't need a special time slice if we didn't have_message to process.
|
||||
if (!have_message)
|
||||
return false;
|
||||
|
||||
// Guarantee we'll get another time slice in the case where we go into native
|
||||
// windows code. This ScheduleWork() may hurt performance a tiny bit when
|
||||
// tasks appear very infrequently, but when the event queue is busy, the
|
||||
// kMsgHaveWork events get (percentage wise) rarer and rarer.
|
||||
ScheduleWork();
|
||||
|
||||
return ProcessMessageHelper(msg);
|
||||
}
|
||||
|
||||
void WinUIMessagePump::AddObserver(UIObserver *observer)
|
||||
{
|
||||
observers_.AddObserver(observer);
|
||||
}
|
||||
|
||||
void WinUIMessagePump::RemoveObserver(UIObserver *observer)
|
||||
{
|
||||
observers_.RemoveObserver(observer);
|
||||
}
|
||||
|
||||
void WinUIMessagePump::PreProcessMessage(const MSG& msg)
|
||||
{
|
||||
AutoLazyEraser lazy_eraser(&observers_);
|
||||
size_t index = 0;
|
||||
UIObserver* observer;
|
||||
while (index < observers_.GetObserverCount())
|
||||
void WinUIMessagePump::PreProcessMessage(const MSG& msg)
|
||||
{
|
||||
observer = observers_.GetObserver(index++);
|
||||
if (observer == NULL)
|
||||
continue;
|
||||
observer->PreProcessMessage(msg);
|
||||
AutoLazyEraser lazy_eraser(&observers_);
|
||||
size_t index = 0;
|
||||
UIObserver* observer;
|
||||
while (index < observers_.GetObserverCount())
|
||||
{
|
||||
observer = observers_.GetObserver(index++);
|
||||
if (observer == NULL)
|
||||
continue;
|
||||
observer->PreProcessMessage(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void WinUIMessagePump::PostProcessMessage(const MSG& msg)
|
||||
{
|
||||
AutoLazyEraser lazy_eraser(&observers_);
|
||||
size_t index = 0;
|
||||
UIObserver* observer;
|
||||
while (index < observers_.GetObserverCount())
|
||||
void WinUIMessagePump::PostProcessMessage(const MSG& msg)
|
||||
{
|
||||
observer = observers_.GetObserver(index++);
|
||||
if (observer == NULL)
|
||||
continue;
|
||||
observer->PostProcessMessage(msg);
|
||||
AutoLazyEraser lazy_eraser(&observers_);
|
||||
size_t index = 0;
|
||||
UIObserver* observer;
|
||||
while (index < observers_.GetObserverCount())
|
||||
{
|
||||
observer = observers_.GetObserver(index++);
|
||||
if (observer == NULL)
|
||||
continue;
|
||||
observer->PostProcessMessage(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace nbase
|
||||
|
||||
#endif // OS_WIN
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
</HBox>
|
||||
<Box>
|
||||
<VBox margin="0,0,0,0" valign="center" halign="center" width="auto" height="auto">
|
||||
<Label name="tooltip" text="一个简单窗口,带有标题栏和常规按钮。"/>
|
||||
<Label name="tooltip" text="dfasdfasd"/>
|
||||
</VBox>
|
||||
</Box>
|
||||
</VBox>
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Window>
|
||||
<Window caption="0,0,180,30" roundcorner="5,5" sizebox="10,10,10,10" mininfo="280,70" maxinfo="300,700">
|
||||
<ListContainerElement class="listitem" height="auto">
|
||||
<HBox height="auto" mouse="false" padding="10,5,10,5">
|
||||
<Control name="control_img" width="auto" height="auto" margin="0,0,10" mouse="false"/>
|
||||
|
@ -1,88 +1,75 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?xml version="1.0"?>
|
||||
<Window size="1200,800" caption="0,0,0,35">
|
||||
<VBox bkcolor="bk_wnd_darkcolor">
|
||||
<HBox width="stretch" height="35" bkcolor="bk_wnd_lightcolor">
|
||||
<Label text="TileBox数据懒加载实现" font="system_14" valign="center" margin="8"/>
|
||||
<Control />
|
||||
<Button class="btn_wnd_min" name="minbtn" margin="4,6,0,0"/>
|
||||
<Box width="21" margin="4,6,0,0">
|
||||
<Button class="btn_wnd_max" name="maxbtn"/>
|
||||
<Button class="btn_wnd_restore" name="restorebtn" visible="false"/>
|
||||
</Box>
|
||||
<Button class="btn_wnd_close" name="closebtn" margin="4,6,8,0"/>
|
||||
</HBox>
|
||||
<HBox childmargin="5" bkcolor="white" padding="5,5,5,10">
|
||||
<VBox width="300" bordersize="1" bordercolor="splitline_level2" padding="5,10,5,10" childmargin="10">
|
||||
<HBox height="30" childmargin="10">
|
||||
<Label font="system_bold_14" text="列设置:" width="auto" height="auto" valign="center" />
|
||||
<Option class="circle_option_2" name="option_column_auto" group="option_group" text="自动计算" margin="0,5,0,10" selected="true"/>
|
||||
<Option class="circle_option_2" name="option_column_fix" group="option_group" text="固定列数" margin="0,5,0,10">
|
||||
<Event type="select" receiver="box_column_op" applyattribute="visible="true"" />
|
||||
<Event type="unselect" receiver="box_column_op" applyattribute="visible="false"" />
|
||||
</Option>
|
||||
</HBox>
|
||||
|
||||
<HBox name="box_column_op" height="30" childmargin="10" visible="false">
|
||||
<Control width="45" />
|
||||
<Box bordersize="1" bordercolor="splitline_level1" width="80" height="26">
|
||||
<RichEdit name="edit_column" margin="10,0,10,0" font="system_14" width="stretch" height="auto" valign="center" normaltextcolor="black" multiline="false" promptmode="true" prompttext="列数" align="vcenter,hcenter" text="3" promptcolor="splitline_level1" autohscroll="true" />
|
||||
</Box>
|
||||
<CheckBox class="checkbox_font12" name="checkbox_item_center" text="列表居中" margin="0,5,0,10" selected="true" />
|
||||
</HBox>
|
||||
<Control height="1" bkcolor="splitline_level2" />
|
||||
<HBox height="30" childmargin="10">
|
||||
<Label font="system_bold_14" text="子项间隙:" width="auto" height="auto" valign="center" />
|
||||
<Box bordersize="1" bordercolor="splitline_level1" width="80" height="26">
|
||||
<RichEdit name="edit_child_margin" margin="10,0,10,0" font="system_14" width="stretch" height="auto" valign="center" normaltextcolor="black" multiline="false" promptmode="true" prompttext="子项间隙" align="vcenter,hcenter" text="" promptcolor="splitline_level1" autohscroll="true" />
|
||||
</Box>
|
||||
</HBox>
|
||||
<HBox height="30" childmargin="10">
|
||||
<Label font="system_bold_14" text="总数据:" width="auto" height="auto" valign="center" />
|
||||
<Box bordersize="1" bordercolor="splitline_level1" width="180" >
|
||||
<RichEdit name="edit_total" margin="10,0,10,0" font="system_14" width="stretch" height="auto" valign="center" normaltextcolor="black" multiline="false" promptmode="true" prompttext="总数据" promptcolor="splitline_level1" autohscroll="true" />
|
||||
</Box>
|
||||
|
||||
</HBox>
|
||||
|
||||
<Box height="30" childmargin="10" width="stretch">
|
||||
<Button class="btn_global_blue_80x30" halign="center" valign="center" name="btn_set_total" text="更改/设置" />
|
||||
</Box>
|
||||
|
||||
<Control height="1" bkcolor="splitline_level2" />
|
||||
|
||||
<HBox height="30" childmargin="10">
|
||||
<Label font="system_bold_14" text="改变数据:" width="auto" height="auto" valign="center" />
|
||||
<Box bordersize="1" bordercolor="splitline_level1" height="26">
|
||||
<RichEdit name="edit_update" margin="10,0,10,0" font="system_14" width="stretch" height="auto" valign="center" normaltextcolor="black" multiline="false" promptmode="true" prompttext="序号(下标1)" promptcolor="splitline_level1" autohscroll="true" align="vcenter,hcenter" />
|
||||
</Box>
|
||||
<Box bordersize="1" bordercolor="splitline_level1" height="26">
|
||||
<RichEdit name="edit_task_name" margin="10,0,10,0" font="system_14" width="stretch" height="auto" valign="center" normaltextcolor="black" multiline="false" promptmode="true" prompttext="新的任务名称" promptcolor="splitline_level1" autohscroll="true" />
|
||||
</Box>
|
||||
</HBox>
|
||||
|
||||
|
||||
<Box height="30" childmargin="10" width="stretch">
|
||||
<Button class="btn_global_blue_80x30" halign="center" valign="center" name="btn_update" text="更新数据" />
|
||||
</Box>
|
||||
|
||||
<Control height="1" bkcolor="splitline_level2" />
|
||||
|
||||
<HBox height="30" childmargin="10">
|
||||
<Label font="system_bold_14" text="删除数据:" width="auto" height="auto" valign="center" />
|
||||
<Box bordersize="1" bordercolor="splitline_level1" >
|
||||
<RichEdit name="edit_delete" margin="10,0,10,0" font="system_14" width="stretch" height="auto" valign="center" normaltextcolor="black" multiline="false" promptmode="true" prompttext="序号(下标1)" promptcolor="splitline_level1" autohscroll="true" align="vcenter,hcenter" />
|
||||
</Box>
|
||||
<Button class="btn_global_red_80x30" halign="center" valign="center" name="btn_delete" text="删除数据" />
|
||||
</HBox>
|
||||
|
||||
|
||||
</VBox>
|
||||
<!--column="3" width="auto" halign="center" childmargin="10" -->
|
||||
<Box>
|
||||
<VirtualTileBox class="list" name="list" vscrollunit="70" itemsize="220,60" bordersize="1" bordercolor="splitline_level2" padding="1,1,1,1">
|
||||
</VirtualTileBox>
|
||||
</Box>
|
||||
|
||||
</HBox>
|
||||
</VBox>
|
||||
<VBox bkcolor="bk_wnd_darkcolor">
|
||||
<HBox width="stretch" height="35" bkcolor="bk_wnd_lightcolor">
|
||||
<Label text="TileBox数据懒加载实现" font="system_14" valign="center" margin="8" />
|
||||
<Control />
|
||||
<Button class="btn_wnd_min" name="minbtn" margin="4,6,0,0" />
|
||||
<Box width="21" margin="4,6,0,0">
|
||||
<Button class="btn_wnd_max" name="maxbtn" />
|
||||
<Button class="btn_wnd_restore" name="restorebtn" visible="false" />
|
||||
</Box>
|
||||
<Button class="btn_wnd_close" name="closebtn" margin="4,6,8,0" />
|
||||
</HBox>
|
||||
<HBox childmargin="5" bkcolor="white" padding="5,5,5,10">
|
||||
<VBox width="300" bordersize="1" bordercolor="splitline_level2" padding="5,10,5,10" childmargin="10">
|
||||
<HBox height="30" childmargin="10">
|
||||
<Label font="system_bold_14" text="列设置:" width="auto" height="auto" valign="center" />
|
||||
<Option class="circle_option_2" name="option_column_auto" group="option_group" text="自动计算" margin="0,5,0,10" selected="true" />
|
||||
<Option class="circle_option_2" name="option_column_fix" group="option_group" text="固定列数" margin="0,5,0,10">
|
||||
<Event type="select" receiver="box_column_op" applyattribute="visible="true"" />
|
||||
<Event type="unselect" receiver="box_column_op" applyattribute="visible="false"" />
|
||||
</Option>
|
||||
</HBox>
|
||||
<HBox name="box_column_op" height="30" childmargin="10" visible="false">
|
||||
<Control width="45" />
|
||||
<Box bordersize="1" bordercolor="splitline_level1" width="80" height="26">
|
||||
<RichEdit name="edit_column" margin="10,0,10,0" font="system_14" width="stretch" height="auto" valign="center" normaltextcolor="black" promptmode="true" prompttext="列数" align="vcenter,hcenter" text="3" promptcolor="splitline_level1" autohscroll="true" />
|
||||
</Box>
|
||||
<CheckBox class="checkbox_font12" name="checkbox_item_center" text="列表居中" margin="0,5,0,10" selected="true" />
|
||||
</HBox>
|
||||
<Control height="1" bkcolor="splitline_level2" />
|
||||
<HBox height="30" childmargin="10">
|
||||
<Label font="system_bold_14" text="子项间隙:" width="auto" height="auto" valign="center" />
|
||||
<Box bordersize="1" bordercolor="splitline_level1" width="80" height="26">
|
||||
<RichEdit name="edit_child_margin" margin="10,0,10,0" font="system_14" width="stretch" height="auto" valign="center" normaltextcolor="black" promptmode="true" prompttext="子项间隙" align="vcenter,hcenter" text="" promptcolor="splitline_level1" autohscroll="true" />
|
||||
</Box>
|
||||
</HBox>
|
||||
<HBox height="30" childmargin="10">
|
||||
<Label font="system_bold_14" text="总数据:" width="auto" height="auto" valign="center" />
|
||||
<Box bordersize="1" bordercolor="splitline_level1" width="180">
|
||||
<RichEdit name="edit_total" margin="10,0,10,0" font="system_14" width="stretch" height="auto" valign="center" normaltextcolor="black" promptmode="true" prompttext="总数据" promptcolor="splitline_level1" autohscroll="true" />
|
||||
</Box>
|
||||
</HBox>
|
||||
<Box height="30" childmargin="10" width="stretch">
|
||||
<Button class="btn_global_blue_80x30" halign="center" valign="center" name="btn_set_total" text="更改/设置" />
|
||||
</Box>
|
||||
<Control height="1" bkcolor="splitline_level2" />
|
||||
<HBox height="30" childmargin="10">
|
||||
<Label font="system_bold_14" text="改变数据:" width="auto" height="auto" valign="center" />
|
||||
<Box bordersize="1" bordercolor="splitline_level1" height="26">
|
||||
<RichEdit name="edit_update" margin="10,0,10,0" font="system_14" width="stretch" height="auto" valign="center" normaltextcolor="black" promptmode="true" prompttext="序号(下标1)" promptcolor="splitline_level1" autohscroll="true" align="vcenter,hcenter" />
|
||||
</Box>
|
||||
<Box bordersize="1" bordercolor="splitline_level1" height="26">
|
||||
<RichEdit name="edit_task_name" margin="10,0,10,0" font="system_14" width="stretch" height="auto" valign="center" normaltextcolor="black" promptmode="true" prompttext="新的任务名称" promptcolor="splitline_level1" autohscroll="true" />
|
||||
</Box>
|
||||
</HBox>
|
||||
<Box height="30" childmargin="10" width="stretch">
|
||||
<Button class="btn_global_blue_80x30" halign="center" valign="center" name="btn_update" text="更新数据" />
|
||||
</Box>
|
||||
<Control height="1" bkcolor="splitline_level2" />
|
||||
<HBox height="30" childmargin="10">
|
||||
<Label font="system_bold_14" text="删除数据:" width="auto" height="auto" valign="center" />
|
||||
<Box bordersize="1" bordercolor="splitline_level1">
|
||||
<RichEdit name="edit_delete" margin="10,0,10,0" font="system_14" width="stretch" height="auto" valign="center" normaltextcolor="black" promptmode="true" prompttext="序号(下标1)" promptcolor="splitline_level1" autohscroll="true" align="vcenter,hcenter" />
|
||||
</Box>
|
||||
<Button class="btn_global_red_80x30" halign="center" valign="center" name="btn_delete" text="删除数据" />
|
||||
</HBox>
|
||||
</VBox>
|
||||
<!--column="3" width="auto" halign="center" childmargin="10" -->
|
||||
<Box>
|
||||
<VirtualTileBox class="list" name="list" vscrollunit="70" itemsize="220,60" bordersize="1" bordercolor="splitline_level2" padding="1,1,1,1" />
|
||||
</Box>
|
||||
</HBox>
|
||||
</VBox>
|
||||
</Window>
|
@ -2,488 +2,481 @@
|
||||
|
||||
namespace ui
|
||||
{
|
||||
|
||||
WindowImplBase::WindowImplBase()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
WindowImplBase::~WindowImplBase()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void WindowImplBase::OnFinalMessage( HWND hWnd )
|
||||
{
|
||||
__super::OnFinalMessage(hWnd);
|
||||
ReapObjects(GetRoot());
|
||||
delete this;
|
||||
}
|
||||
|
||||
LONG WindowImplBase::GetStyle()
|
||||
{
|
||||
LONG styleValue = ::GetWindowLong(GetHWND(), GWL_STYLE);
|
||||
styleValue &= ~WS_CAPTION;
|
||||
|
||||
return styleValue;
|
||||
}
|
||||
|
||||
UINT WindowImplBase::GetClassStyle() const
|
||||
{
|
||||
return CS_DBLCLKS;
|
||||
}
|
||||
|
||||
std::wstring WindowImplBase::GetResourceID() const
|
||||
{
|
||||
return _T("");
|
||||
}
|
||||
|
||||
Control* WindowImplBase::CreateControl(const std::wstring& pstrClass)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
LRESULT WindowImplBase::MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
LRESULT WindowImplBase::OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
bHandled = FALSE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT WindowImplBase::OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
bHandled = FALSE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT WindowImplBase::OnNcActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
if( ::IsIconic(GetHWND()) ) bHandled = FALSE;
|
||||
return (wParam == 0) ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
LRESULT WindowImplBase::OnNcCalcSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT WindowImplBase::OnWindowPosChanging(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
bHandled = FALSE;
|
||||
if (IsZoomed(m_hWnd))
|
||||
WindowImplBase::WindowImplBase()
|
||||
{
|
||||
LPWINDOWPOS lpPos = (LPWINDOWPOS)lParam;
|
||||
if (lpPos->flags & SWP_FRAMECHANGED) // 第一次最大化,而不是最大化之后所触发的WINDOWPOSCHANGE
|
||||
}
|
||||
|
||||
WindowImplBase::~WindowImplBase()
|
||||
{
|
||||
}
|
||||
|
||||
void WindowImplBase::OnFinalMessage(HWND hWnd)
|
||||
{
|
||||
__super::OnFinalMessage(hWnd);
|
||||
ReapObjects(GetRoot());
|
||||
delete this;
|
||||
}
|
||||
|
||||
LONG WindowImplBase::GetStyle()
|
||||
{
|
||||
LONG styleValue = ::GetWindowLong(GetHWND(), GWL_STYLE);
|
||||
styleValue &= ~WS_CAPTION;
|
||||
|
||||
return styleValue;
|
||||
}
|
||||
|
||||
UINT WindowImplBase::GetClassStyle() const
|
||||
{
|
||||
return CS_DBLCLKS;
|
||||
}
|
||||
|
||||
std::wstring WindowImplBase::GetResourceID() const
|
||||
{
|
||||
return _T("");
|
||||
}
|
||||
|
||||
Control* WindowImplBase::CreateControl(const std::wstring& pstrClass)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
LRESULT WindowImplBase::MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
LRESULT WindowImplBase::OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
bHandled = FALSE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT WindowImplBase::OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
bHandled = FALSE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT WindowImplBase::OnNcActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
if (::IsIconic(GetHWND())) bHandled = FALSE;
|
||||
return (wParam == 0) ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
LRESULT WindowImplBase::OnNcCalcSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT WindowImplBase::OnWindowPosChanging(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
bHandled = FALSE;
|
||||
if (IsZoomed(m_hWnd))
|
||||
{
|
||||
POINT pt = { 0, 0 };
|
||||
HMONITOR hMontorPrimary = MonitorFromPoint(pt, MONITOR_DEFAULTTOPRIMARY);
|
||||
HMONITOR hMonitorTo = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
|
||||
|
||||
if (hMonitorTo != hMontorPrimary)
|
||||
LPWINDOWPOS lpPos = (LPWINDOWPOS)lParam;
|
||||
if (lpPos->flags & SWP_FRAMECHANGED) // 第一次最大化,而不是最大化之后所触发的WINDOWPOSCHANGE
|
||||
{
|
||||
// 解决无边框窗口在双屏下面(副屏分辨率大于主屏)时,最大化不正确的问题
|
||||
MONITORINFO miTo = { sizeof(miTo), 0 };
|
||||
GetMonitorInfo(hMonitorTo, &miTo);
|
||||
POINT pt = { 0, 0 };
|
||||
HMONITOR hMontorPrimary = MonitorFromPoint(pt, MONITOR_DEFAULTTOPRIMARY);
|
||||
HMONITOR hMonitorTo = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
|
||||
|
||||
lpPos->x = miTo.rcWork.left;
|
||||
lpPos->y = miTo.rcWork.top;
|
||||
lpPos->cx = miTo.rcWork.right - miTo.rcWork.left;
|
||||
lpPos->cy = miTo.rcWork.bottom - miTo.rcWork.top;
|
||||
if (hMonitorTo != hMontorPrimary)
|
||||
{
|
||||
// 解决无边框窗口在双屏下面(副屏分辨率大于主屏)时,最大化不正确的问题
|
||||
MONITORINFO miTo = { sizeof(miTo), 0 };
|
||||
GetMonitorInfo(hMonitorTo, &miTo);
|
||||
|
||||
lpPos->x = miTo.rcWork.left;
|
||||
lpPos->y = miTo.rcWork.top;
|
||||
lpPos->cx = miTo.rcWork.right - miTo.rcWork.left;
|
||||
lpPos->cy = miTo.rcWork.bottom - miTo.rcWork.top;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT WindowImplBase::OnNcPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT WindowImplBase::OnNcLButtonDbClick(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
/*if (!::IsZoomed(GetHWND()))
|
||||
LRESULT WindowImplBase::OnNcPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
SendMessage(WM_SYSCOMMAND, SC_MAXIMIZE, 0);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
|
||||
LRESULT WindowImplBase::OnNcLButtonDbClick(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
SendMessage(WM_SYSCOMMAND, SC_RESTORE, 0);
|
||||
}*/
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT WindowImplBase::OnNcHitTest(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
POINT pt; pt.x = GET_X_LPARAM(lParam); pt.y = GET_Y_LPARAM(lParam);
|
||||
::ScreenToClient(GetHWND(), &pt);
|
||||
|
||||
UiRect rcClient;
|
||||
::GetClientRect(GetHWND(), &rcClient);
|
||||
|
||||
rcClient.Deflate(m_shadow.GetShadowCorner());
|
||||
|
||||
if( !::IsZoomed(GetHWND()) ) {
|
||||
UiRect rcSizeBox = GetSizeBox();
|
||||
if( pt.y < rcClient.top + rcSizeBox.top ) {
|
||||
if (pt.y >= rcClient.top) {
|
||||
if (pt.x < (rcClient.left + rcSizeBox.left) && pt.x >= rcClient.left) return HTTOPLEFT;
|
||||
else if (pt.x >(rcClient.right - rcSizeBox.right) && pt.x <= rcClient.right) return HTTOPRIGHT;
|
||||
else return HTTOP;
|
||||
}
|
||||
else return HTCLIENT;
|
||||
}
|
||||
else if( pt.y > rcClient.bottom - rcSizeBox.bottom ) {
|
||||
if (pt.y <= rcClient.bottom) {
|
||||
if (pt.x < (rcClient.left + rcSizeBox.left) && pt.x >= rcClient.left) return HTBOTTOMLEFT;
|
||||
else if (pt.x > (rcClient.right - rcSizeBox.right) && pt.x <= rcClient.right) return HTBOTTOMRIGHT;
|
||||
else return HTBOTTOM;
|
||||
}
|
||||
else return HTCLIENT;
|
||||
/*if (!::IsZoomed(GetHWND()))
|
||||
{
|
||||
SendMessage(WM_SYSCOMMAND, SC_MAXIMIZE, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
SendMessage(WM_SYSCOMMAND, SC_RESTORE, 0);
|
||||
}*/
|
||||
|
||||
if (pt.x < rcClient.left + rcSizeBox.left) {
|
||||
if (pt.x >= rcClient.left) return HTLEFT;
|
||||
else return HTCLIENT;
|
||||
}
|
||||
if (pt.x > rcClient.right - rcSizeBox.right) {
|
||||
if (pt.x <= rcClient.right) return HTRIGHT;
|
||||
else return HTCLIENT;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
UiRect rcCaption = GetCaptionRect();
|
||||
if( pt.x >= rcClient.left + rcCaption.left && pt.x < rcClient.right - rcCaption.right \
|
||||
&& pt.y >= rcClient.top + rcCaption.top && pt.y < rcClient.top + rcCaption.bottom ) {
|
||||
LRESULT WindowImplBase::OnNcHitTest(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
POINT pt; pt.x = GET_X_LPARAM(lParam); pt.y = GET_Y_LPARAM(lParam);
|
||||
::ScreenToClient(GetHWND(), &pt);
|
||||
|
||||
UiRect rcClient;
|
||||
::GetClientRect(GetHWND(), &rcClient);
|
||||
|
||||
rcClient.Deflate(m_shadow.GetShadowCorner());
|
||||
|
||||
if (!::IsZoomed(GetHWND())) {
|
||||
UiRect rcSizeBox = GetSizeBox();
|
||||
if (pt.y < rcClient.top + rcSizeBox.top) {
|
||||
if (pt.y >= rcClient.top) {
|
||||
if (pt.x < (rcClient.left + rcSizeBox.left) && pt.x >= rcClient.left) return HTTOPLEFT;
|
||||
else if (pt.x > (rcClient.right - rcSizeBox.right) && pt.x <= rcClient.right) return HTTOPRIGHT;
|
||||
else return HTTOP;
|
||||
}
|
||||
else return HTCLIENT;
|
||||
}
|
||||
else if (pt.y > rcClient.bottom - rcSizeBox.bottom) {
|
||||
if (pt.y <= rcClient.bottom) {
|
||||
if (pt.x < (rcClient.left + rcSizeBox.left) && pt.x >= rcClient.left) return HTBOTTOMLEFT;
|
||||
else if (pt.x > (rcClient.right - rcSizeBox.right) && pt.x <= rcClient.right) return HTBOTTOMRIGHT;
|
||||
else return HTBOTTOM;
|
||||
}
|
||||
else return HTCLIENT;
|
||||
}
|
||||
|
||||
if (pt.x < rcClient.left + rcSizeBox.left) {
|
||||
if (pt.x >= rcClient.left) return HTLEFT;
|
||||
else return HTCLIENT;
|
||||
}
|
||||
if (pt.x > rcClient.right - rcSizeBox.right) {
|
||||
if (pt.x <= rcClient.right) return HTRIGHT;
|
||||
else return HTCLIENT;
|
||||
}
|
||||
}
|
||||
|
||||
UiRect rcCaption = GetCaptionRect();
|
||||
if (pt.x >= rcClient.left + rcCaption.left && pt.x < rcClient.right - rcCaption.right \
|
||||
&& pt.y >= rcClient.top + rcCaption.top && pt.y < rcClient.top + rcCaption.bottom) {
|
||||
Control* pControl = FindControl(pt);
|
||||
if( pControl ) {
|
||||
if (pControl) {
|
||||
if (dynamic_cast<Button*>(pControl) || dynamic_cast<ButtonBox*>(pControl) || dynamic_cast<RichEdit*>(pControl))
|
||||
return HTCLIENT;
|
||||
else
|
||||
return HTCAPTION;
|
||||
}
|
||||
}
|
||||
|
||||
return HTCLIENT;
|
||||
}
|
||||
|
||||
return HTCLIENT;
|
||||
}
|
||||
LRESULT WindowImplBase::OnGetMinMaxInfo(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
LPMINMAXINFO lpMMI = (LPMINMAXINFO)lParam;
|
||||
MONITORINFO oMonitor = {};
|
||||
oMonitor.cbSize = sizeof(oMonitor);
|
||||
::GetMonitorInfo(::MonitorFromWindow(GetHWND(), MONITOR_DEFAULTTONEAREST), &oMonitor);
|
||||
UiRect rcWork = oMonitor.rcWork;
|
||||
UiRect rcMonitor = oMonitor.rcMonitor;
|
||||
rcWork.Offset(-oMonitor.rcMonitor.left, -oMonitor.rcMonitor.top);
|
||||
|
||||
LRESULT WindowImplBase::OnGetMinMaxInfo(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
LPMINMAXINFO lpMMI = (LPMINMAXINFO) lParam;
|
||||
MONITORINFO oMonitor = {};
|
||||
oMonitor.cbSize = sizeof(oMonitor);
|
||||
::GetMonitorInfo(::MonitorFromWindow(GetHWND(), MONITOR_DEFAULTTONEAREST), &oMonitor);
|
||||
UiRect rcWork = oMonitor.rcWork;
|
||||
UiRect rcMonitor = oMonitor.rcMonitor;
|
||||
rcWork.Offset(-oMonitor.rcMonitor.left, -oMonitor.rcMonitor.top);
|
||||
UiRect rcMaximize = GetMaximizeInfo();
|
||||
if (rcMaximize.GetWidth() > 0 && rcMaximize.GetHeight() > 0) {
|
||||
lpMMI->ptMaxPosition.x = rcWork.left + rcMaximize.left;
|
||||
lpMMI->ptMaxPosition.y = rcWork.top + rcMaximize.top;
|
||||
lpMMI->ptMaxSize.x = rcMaximize.GetWidth();
|
||||
lpMMI->ptMaxSize.y = rcMaximize.GetHeight();
|
||||
}
|
||||
else {
|
||||
// 计算最大化时,正确的原点坐标
|
||||
lpMMI->ptMaxPosition.x = rcWork.left;
|
||||
lpMMI->ptMaxPosition.y = rcWork.top;
|
||||
lpMMI->ptMaxSize.x = rcWork.GetWidth();
|
||||
lpMMI->ptMaxSize.y = rcWork.GetHeight();
|
||||
}
|
||||
|
||||
UiRect rcMaximize = GetMaximizeInfo();
|
||||
if (rcMaximize.GetWidth() > 0 && rcMaximize.GetHeight() > 0) {
|
||||
lpMMI->ptMaxPosition.x = rcWork.left + rcMaximize.left;
|
||||
lpMMI->ptMaxPosition.y = rcWork.top + rcMaximize.top;
|
||||
lpMMI->ptMaxSize.x = rcMaximize.GetWidth();
|
||||
lpMMI->ptMaxSize.y = rcMaximize.GetHeight();
|
||||
}
|
||||
else {
|
||||
// 计算最大化时,正确的原点坐标
|
||||
lpMMI->ptMaxPosition.x = rcWork.left;
|
||||
lpMMI->ptMaxPosition.y = rcWork.top;
|
||||
lpMMI->ptMaxSize.x = rcWork.GetWidth();
|
||||
lpMMI->ptMaxSize.y = rcWork.GetHeight();
|
||||
}
|
||||
if (GetMaxInfo().cx != 0) {
|
||||
lpMMI->ptMaxTrackSize.x = GetMaxInfo(true).cx;
|
||||
}
|
||||
if (GetMaxInfo().cy != 0) {
|
||||
lpMMI->ptMaxTrackSize.y = GetMaxInfo(true).cy;
|
||||
}
|
||||
if (GetMinInfo().cx != 0) {
|
||||
lpMMI->ptMinTrackSize.x = GetMinInfo(true).cx;
|
||||
}
|
||||
if (GetMinInfo().cy != 0) {
|
||||
lpMMI->ptMinTrackSize.y = GetMinInfo(true).cy;
|
||||
}
|
||||
|
||||
if (GetMaxInfo().cx != 0) {
|
||||
lpMMI->ptMaxTrackSize.x = GetMaxInfo(true).cx;
|
||||
}
|
||||
if (GetMaxInfo().cy != 0) {
|
||||
lpMMI->ptMaxTrackSize.y = GetMaxInfo(true).cy;
|
||||
}
|
||||
if (GetMinInfo().cx != 0) {
|
||||
lpMMI->ptMinTrackSize.x = GetMinInfo(true).cx;
|
||||
}
|
||||
if (GetMinInfo().cy != 0) {
|
||||
lpMMI->ptMinTrackSize.y = GetMinInfo(true).cy;
|
||||
}
|
||||
|
||||
bHandled = FALSE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT WindowImplBase::OnMouseWheel(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
bHandled = FALSE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT WindowImplBase::OnMouseHover(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
bHandled = FALSE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT WindowImplBase::OnDpiChanged(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
bHandled = FALSE;
|
||||
|
||||
// 重置全局 DPI 设定
|
||||
DpiManager::GetInstance()->SetScale(LOWORD(wParam));
|
||||
|
||||
// 重置阴影范围
|
||||
m_shadow.ResetShadowBox();
|
||||
|
||||
// TODO 对窗口大小进行进行改变,让所有控件重新根据 DPI 计算大小
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT WindowImplBase::OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
CSize szRoundCorner = GetRoundCorner();
|
||||
if( !::IsIconic(GetHWND()) && (szRoundCorner.cx != 0 || szRoundCorner.cy != 0) ) {
|
||||
UiRect rcWnd;
|
||||
::GetWindowRect(GetHWND(), &rcWnd);
|
||||
rcWnd.Offset(-rcWnd.left, -rcWnd.top);
|
||||
rcWnd.right++; rcWnd.bottom++;
|
||||
HRGN hRgn = ::CreateRoundRectRgn(rcWnd.left, rcWnd.top, rcWnd.right, rcWnd.bottom, szRoundCorner.cx, szRoundCorner.cy);
|
||||
::SetWindowRgn(GetHWND(), hRgn, TRUE);
|
||||
::DeleteObject(hRgn);
|
||||
}
|
||||
|
||||
bHandled = FALSE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT WindowImplBase::OnChar(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
bHandled = FALSE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT WindowImplBase::OnSysCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
if (wParam == SC_CLOSE) {
|
||||
bHandled = TRUE;
|
||||
SendMessage(WM_CLOSE);
|
||||
bHandled = FALSE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
BOOL bZoomed = ::IsZoomed(GetHWND());
|
||||
LRESULT lRes = Window::HandleMessage(uMsg, wParam, lParam);
|
||||
if( ::IsZoomed(GetHWND()) != bZoomed )
|
||||
LRESULT WindowImplBase::OnMouseWheel(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
|
||||
bHandled = FALSE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return lRes;
|
||||
}
|
||||
|
||||
LRESULT WindowImplBase::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
::SetWindowLong(this->GetHWND(), GWL_STYLE, GetStyle());
|
||||
|
||||
Init(m_hWnd);
|
||||
SetWindowResourcePath(GetSkinFolder());
|
||||
|
||||
WindowBuilder builder;
|
||||
std::wstring strSkinFile = GetWindowResourcePath() + GetSkinFile();
|
||||
|
||||
auto callback = nbase::Bind(&WindowImplBase::CreateControl, this, std::placeholders::_1);
|
||||
auto pRoot = (Box*)builder.Create(strSkinFile.c_str(), callback, this);
|
||||
|
||||
ASSERT(pRoot && L"Faield to load xml file.");
|
||||
if (pRoot == NULL) {
|
||||
TCHAR szErrMsg[MAX_PATH] = { 0 };
|
||||
_stprintf_s(szErrMsg, L"Failed to load xml file %s", strSkinFile.c_str());
|
||||
MessageBox(NULL, szErrMsg, _T("Duilib"), MB_OK | MB_ICONERROR);
|
||||
return -1;
|
||||
}
|
||||
|
||||
pRoot = m_shadow.AttachShadow(pRoot);
|
||||
AttachDialog(pRoot);
|
||||
InitWindow();
|
||||
|
||||
if (pRoot->GetFixedWidth() == DUI_LENGTH_AUTO || pRoot->GetFixedHeight() == DUI_LENGTH_AUTO) {
|
||||
CSize maxSize(99999, 99999);
|
||||
CSize needSize = pRoot->EstimateSize(maxSize);
|
||||
if( needSize.cx < pRoot->GetMinWidth() ) needSize.cx = pRoot->GetMinWidth();
|
||||
if( pRoot->GetMaxWidth() >= 0 && needSize.cx > pRoot->GetMaxWidth() ) needSize.cx = pRoot->GetMaxWidth();
|
||||
if( needSize.cy < pRoot->GetMinHeight() ) needSize.cy = pRoot->GetMinHeight();
|
||||
if( needSize.cy > pRoot->GetMaxHeight() ) needSize.cy = pRoot->GetMaxHeight();
|
||||
|
||||
::MoveWindow(m_hWnd, 0, 0, needSize.cx, needSize.cy, FALSE);
|
||||
}
|
||||
|
||||
Control *pControl = (Control*)FindControl(L"closebtn");
|
||||
if (pControl) {
|
||||
Button *pCloseBtn = dynamic_cast<Button*>(pControl);
|
||||
ASSERT(pCloseBtn);
|
||||
pCloseBtn->AttachClick(nbase::Bind(&WindowImplBase::OnButtonClick, this, std::placeholders::_1));
|
||||
}
|
||||
|
||||
pControl = (Control*)FindControl(L"minbtn");
|
||||
if (pControl) {
|
||||
Button* pMinBtn = dynamic_cast<Button*>(pControl);
|
||||
ASSERT(pMinBtn);
|
||||
pMinBtn->AttachClick(nbase::Bind(&WindowImplBase::OnButtonClick, this, std::placeholders::_1));
|
||||
}
|
||||
|
||||
pControl = (Control*)FindControl(L"maxbtn");
|
||||
if (pControl) {
|
||||
Button* pMaxBtn = dynamic_cast<Button*>(pControl);
|
||||
ASSERT(pMaxBtn);
|
||||
pMaxBtn->AttachClick(nbase::Bind(&WindowImplBase::OnButtonClick, this, std::placeholders::_1));
|
||||
}
|
||||
|
||||
pControl = (Control*)FindControl(L"restorebtn");
|
||||
if (pControl) {
|
||||
Button* pRestoreBtn = dynamic_cast<Button*>(pControl);
|
||||
ASSERT(pRestoreBtn);
|
||||
pRestoreBtn->AttachClick(nbase::Bind(&WindowImplBase::OnButtonClick, this, std::placeholders::_1));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT WindowImplBase::OnKeyDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
bHandled = FALSE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT WindowImplBase::OnKillFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
bHandled = FALSE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT WindowImplBase::OnSetFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
bHandled = FALSE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT WindowImplBase::OnLButtonDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
bHandled = FALSE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT WindowImplBase::OnLButtonUp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
bHandled = FALSE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT WindowImplBase::OnMouseMove(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
bHandled = FALSE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT WindowImplBase::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
LRESULT lRes = 0;
|
||||
BOOL bHandled = TRUE;
|
||||
switch (uMsg)
|
||||
LRESULT WindowImplBase::OnMouseHover(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
case WM_CREATE: lRes = OnCreate(uMsg, wParam, lParam, bHandled); break;
|
||||
case WM_CLOSE: lRes = OnClose(uMsg, wParam, lParam, bHandled); break;
|
||||
case WM_DESTROY: lRes = OnDestroy(uMsg, wParam, lParam, bHandled); break;
|
||||
case WM_NCACTIVATE: lRes = OnNcActivate(uMsg, wParam, lParam, bHandled); break;
|
||||
case WM_NCCALCSIZE: lRes = OnNcCalcSize(uMsg, wParam, lParam, bHandled); break;
|
||||
case WM_WINDOWPOSCHANGING: lRes = OnWindowPosChanging(uMsg, wParam, lParam, bHandled); break;
|
||||
case WM_NCPAINT: lRes = OnNcPaint(uMsg, wParam, lParam, bHandled); break;
|
||||
case WM_NCLBUTTONDBLCLK:lRes = OnNcLButtonDbClick(uMsg, wParam, lParam, bHandled); break;
|
||||
case WM_NCHITTEST: lRes = OnNcHitTest(uMsg, wParam, lParam, bHandled); break;
|
||||
case WM_GETMINMAXINFO: lRes = OnGetMinMaxInfo(uMsg, wParam, lParam, bHandled); break;
|
||||
case WM_MOUSEWHEEL: lRes = OnMouseWheel(uMsg, wParam, lParam, bHandled); break;
|
||||
case WM_SIZE: lRes = OnSize(uMsg, wParam, lParam, bHandled); break;
|
||||
case WM_CHAR: lRes = OnChar(uMsg, wParam, lParam, bHandled); break;
|
||||
case WM_SYSCOMMAND: lRes = OnSysCommand(uMsg, wParam, lParam, bHandled); break;
|
||||
case WM_KEYDOWN: lRes = OnKeyDown(uMsg, wParam, lParam, bHandled); break;
|
||||
case WM_KILLFOCUS: lRes = OnKillFocus(uMsg, wParam, lParam, bHandled); break;
|
||||
case WM_SETFOCUS: lRes = OnSetFocus(uMsg, wParam, lParam, bHandled); break;
|
||||
case WM_LBUTTONUP: lRes = OnLButtonUp(uMsg, wParam, lParam, bHandled); break;
|
||||
case WM_LBUTTONDOWN: lRes = OnLButtonDown(uMsg, wParam, lParam, bHandled); break;
|
||||
case WM_MOUSEMOVE: lRes = OnMouseMove(uMsg, wParam, lParam, bHandled); break;
|
||||
case WM_MOUSEHOVER: lRes = OnMouseHover(uMsg, wParam, lParam, bHandled); break;
|
||||
case WM_DPICHANGED: lRes = OnDpiChanged(uMsg, wParam, lParam, bHandled); break;
|
||||
default: bHandled = FALSE; break;
|
||||
bHandled = FALSE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (bHandled) return lRes;
|
||||
LRESULT WindowImplBase::OnDpiChanged(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
bHandled = FALSE;
|
||||
|
||||
return Window::HandleMessage(uMsg, wParam, lParam);
|
||||
}
|
||||
// 重置全局 DPI 设定
|
||||
DpiManager::GetInstance()->SetScale(LOWORD(wParam));
|
||||
|
||||
bool WindowImplBase::OnButtonClick(EventArgs* msg)
|
||||
{
|
||||
std::wstring sCtrlName = msg->pSender->GetName();
|
||||
if( sCtrlName == _T("closebtn") ) {
|
||||
Close();
|
||||
// 重置阴影范围
|
||||
m_shadow.ResetShadowBox();
|
||||
|
||||
// TODO 对窗口大小进行进行改变,让所有控件重新根据 DPI 计算大小
|
||||
|
||||
return 0;
|
||||
}
|
||||
else if( sCtrlName == _T("minbtn")) {
|
||||
SendMessage(WM_SYSCOMMAND, SC_MINIMIZE, 0);
|
||||
}
|
||||
else if( sCtrlName == _T("maxbtn")) {
|
||||
Control* pMaxButton = (Control*)FindControl(L"maxbtn");
|
||||
Control* pRestoreButton = (Control*)FindControl(L"restorebtn");
|
||||
if (pMaxButton && pRestoreButton) {
|
||||
pMaxButton->SetVisible(false);
|
||||
pRestoreButton->SetVisible(true);
|
||||
|
||||
LRESULT WindowImplBase::OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
CSize szRoundCorner = GetRoundCorner();
|
||||
if (!::IsIconic(GetHWND()) && (szRoundCorner.cx != 0 || szRoundCorner.cy != 0)) {
|
||||
UiRect rcWnd;
|
||||
::GetWindowRect(GetHWND(), &rcWnd);
|
||||
rcWnd.Offset(-rcWnd.left, -rcWnd.top);
|
||||
rcWnd.right++; rcWnd.bottom++;
|
||||
HRGN hRgn = ::CreateRoundRectRgn(rcWnd.left, rcWnd.top, rcWnd.right, rcWnd.bottom, szRoundCorner.cx, szRoundCorner.cy);
|
||||
::SetWindowRgn(GetHWND(), hRgn, TRUE);
|
||||
::DeleteObject(hRgn);
|
||||
}
|
||||
SendMessage(WM_SYSCOMMAND, SC_MAXIMIZE, 0);
|
||||
}
|
||||
else if( sCtrlName == _T("restorebtn")) {
|
||||
Control* pMaxButton = (Control*)FindControl(L"maxbtn");
|
||||
Control* pRestoreButton = (Control*)FindControl(L"restorebtn");
|
||||
if (pMaxButton && pRestoreButton) {
|
||||
pMaxButton->SetVisible(true);
|
||||
pRestoreButton->SetVisible(false);
|
||||
}
|
||||
SendMessage(WM_SYSCOMMAND, SC_RESTORE, 0);
|
||||
|
||||
bHandled = FALSE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void WindowImplBase::ActiveWindow()
|
||||
{
|
||||
if (::IsWindow(m_hWnd))
|
||||
LRESULT WindowImplBase::OnChar(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
if (::IsIconic(m_hWnd))
|
||||
bHandled = FALSE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT WindowImplBase::OnSysCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
if (wParam == SC_CLOSE) {
|
||||
bHandled = TRUE;
|
||||
SendMessage(WM_CLOSE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
BOOL bZoomed = ::IsZoomed(GetHWND());
|
||||
LRESULT lRes = Window::HandleMessage(uMsg, wParam, lParam);
|
||||
if (::IsZoomed(GetHWND()) != bZoomed)
|
||||
{
|
||||
::ShowWindow(m_hWnd, SW_RESTORE);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!::IsWindowVisible(m_hWnd))
|
||||
::ShowWindow(m_hWnd, SW_SHOW);
|
||||
::SetForegroundWindow(m_hWnd);
|
||||
}
|
||||
|
||||
return lRes;
|
||||
}
|
||||
}
|
||||
|
||||
void WindowImplBase::SetTaskbarTitle(const std::wstring &title)
|
||||
{
|
||||
::SetWindowTextW(m_hWnd, title.c_str());
|
||||
}
|
||||
|
||||
|
||||
void WindowImplBase::ToTopMost(bool forever)
|
||||
{
|
||||
ASSERT(::IsWindow(m_hWnd));
|
||||
::SetWindowPos(m_hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
|
||||
if (!forever)
|
||||
LRESULT WindowImplBase::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
::SetWindowPos(m_hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
|
||||
::SetWindowLong(this->GetHWND(), GWL_STYLE, GetStyle());
|
||||
|
||||
Init(m_hWnd);
|
||||
SetWindowResourcePath(GetSkinFolder());
|
||||
|
||||
WindowBuilder builder;
|
||||
std::wstring strSkinFile = GetWindowResourcePath() + GetSkinFile();
|
||||
|
||||
auto callback = nbase::Bind(&WindowImplBase::CreateControl, this, std::placeholders::_1);
|
||||
auto pRoot = (Box*)builder.Create(strSkinFile.c_str(), callback, this);
|
||||
|
||||
ASSERT(pRoot && L"Faield to load xml file.");
|
||||
if (pRoot == NULL) {
|
||||
TCHAR szErrMsg[MAX_PATH] = { 0 };
|
||||
_stprintf_s(szErrMsg, L"Failed to load xml file %s", strSkinFile.c_str());
|
||||
MessageBox(NULL, szErrMsg, _T("Duilib"), MB_OK | MB_ICONERROR);
|
||||
return -1;
|
||||
}
|
||||
|
||||
pRoot = m_shadow.AttachShadow(pRoot);
|
||||
AttachDialog(pRoot);
|
||||
InitWindow();
|
||||
|
||||
if (pRoot->GetFixedWidth() == DUI_LENGTH_AUTO || pRoot->GetFixedHeight() == DUI_LENGTH_AUTO) {
|
||||
CSize maxSize(99999, 99999);
|
||||
CSize needSize = pRoot->EstimateSize(maxSize);
|
||||
if (needSize.cx < pRoot->GetMinWidth()) needSize.cx = pRoot->GetMinWidth();
|
||||
if (pRoot->GetMaxWidth() >= 0 && needSize.cx > pRoot->GetMaxWidth()) needSize.cx = pRoot->GetMaxWidth();
|
||||
if (needSize.cy < pRoot->GetMinHeight()) needSize.cy = pRoot->GetMinHeight();
|
||||
if (needSize.cy > pRoot->GetMaxHeight()) needSize.cy = pRoot->GetMaxHeight();
|
||||
|
||||
::MoveWindow(m_hWnd, 0, 0, needSize.cx, needSize.cy, FALSE);
|
||||
}
|
||||
|
||||
Control* pControl = (Control*)FindControl(L"closebtn");
|
||||
if (pControl) {
|
||||
Button* pCloseBtn = dynamic_cast<Button*>(pControl);
|
||||
ASSERT(pCloseBtn);
|
||||
pCloseBtn->AttachClick(nbase::Bind(&WindowImplBase::OnButtonClick, this, std::placeholders::_1));
|
||||
}
|
||||
|
||||
pControl = (Control*)FindControl(L"minbtn");
|
||||
if (pControl) {
|
||||
Button* pMinBtn = dynamic_cast<Button*>(pControl);
|
||||
ASSERT(pMinBtn);
|
||||
pMinBtn->AttachClick(nbase::Bind(&WindowImplBase::OnButtonClick, this, std::placeholders::_1));
|
||||
}
|
||||
|
||||
pControl = (Control*)FindControl(L"maxbtn");
|
||||
if (pControl) {
|
||||
Button* pMaxBtn = dynamic_cast<Button*>(pControl);
|
||||
ASSERT(pMaxBtn);
|
||||
pMaxBtn->AttachClick(nbase::Bind(&WindowImplBase::OnButtonClick, this, std::placeholders::_1));
|
||||
}
|
||||
|
||||
pControl = (Control*)FindControl(L"restorebtn");
|
||||
if (pControl) {
|
||||
Button* pRestoreBtn = dynamic_cast<Button*>(pControl);
|
||||
ASSERT(pRestoreBtn);
|
||||
pRestoreBtn->AttachClick(nbase::Bind(&WindowImplBase::OnButtonClick, this, std::placeholders::_1));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT WindowImplBase::OnKeyDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
bHandled = FALSE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT WindowImplBase::OnKillFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
bHandled = FALSE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT WindowImplBase::OnSetFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
bHandled = FALSE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT WindowImplBase::OnLButtonDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
bHandled = FALSE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT WindowImplBase::OnLButtonUp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
bHandled = FALSE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT WindowImplBase::OnMouseMove(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
bHandled = FALSE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT WindowImplBase::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
LRESULT lRes = 0;
|
||||
BOOL bHandled = TRUE;
|
||||
switch (uMsg)
|
||||
{
|
||||
case WM_CREATE: lRes = OnCreate(uMsg, wParam, lParam, bHandled); break;
|
||||
case WM_CLOSE: lRes = OnClose(uMsg, wParam, lParam, bHandled); break;
|
||||
case WM_DESTROY: lRes = OnDestroy(uMsg, wParam, lParam, bHandled); break;
|
||||
case WM_NCACTIVATE: lRes = OnNcActivate(uMsg, wParam, lParam, bHandled); break;
|
||||
case WM_NCCALCSIZE: lRes = OnNcCalcSize(uMsg, wParam, lParam, bHandled); break;
|
||||
case WM_WINDOWPOSCHANGING: lRes = OnWindowPosChanging(uMsg, wParam, lParam, bHandled); break;
|
||||
case WM_NCPAINT: lRes = OnNcPaint(uMsg, wParam, lParam, bHandled); break;
|
||||
case WM_NCLBUTTONDBLCLK:lRes = OnNcLButtonDbClick(uMsg, wParam, lParam, bHandled); break;
|
||||
case WM_NCHITTEST: lRes = OnNcHitTest(uMsg, wParam, lParam, bHandled); break;
|
||||
case WM_GETMINMAXINFO: lRes = OnGetMinMaxInfo(uMsg, wParam, lParam, bHandled); break;
|
||||
case WM_MOUSEWHEEL: lRes = OnMouseWheel(uMsg, wParam, lParam, bHandled); break;
|
||||
case WM_SIZE: lRes = OnSize(uMsg, wParam, lParam, bHandled); break;
|
||||
case WM_CHAR: lRes = OnChar(uMsg, wParam, lParam, bHandled); break;
|
||||
case WM_SYSCOMMAND: lRes = OnSysCommand(uMsg, wParam, lParam, bHandled); break;
|
||||
case WM_KEYDOWN: lRes = OnKeyDown(uMsg, wParam, lParam, bHandled); break;
|
||||
case WM_KILLFOCUS: lRes = OnKillFocus(uMsg, wParam, lParam, bHandled); break;
|
||||
case WM_SETFOCUS: lRes = OnSetFocus(uMsg, wParam, lParam, bHandled); break;
|
||||
case WM_LBUTTONUP: lRes = OnLButtonUp(uMsg, wParam, lParam, bHandled); break;
|
||||
case WM_LBUTTONDOWN: lRes = OnLButtonDown(uMsg, wParam, lParam, bHandled); break;
|
||||
case WM_MOUSEMOVE: lRes = OnMouseMove(uMsg, wParam, lParam, bHandled); break;
|
||||
case WM_MOUSEHOVER: lRes = OnMouseHover(uMsg, wParam, lParam, bHandled); break;
|
||||
case WM_DPICHANGED: lRes = OnDpiChanged(uMsg, wParam, lParam, bHandled); break;
|
||||
default: bHandled = FALSE; break;
|
||||
}
|
||||
|
||||
if (bHandled) return lRes;
|
||||
|
||||
return Window::HandleMessage(uMsg, wParam, lParam);
|
||||
}
|
||||
|
||||
bool WindowImplBase::OnButtonClick(EventArgs* msg)
|
||||
{
|
||||
std::wstring sCtrlName = msg->pSender->GetName();
|
||||
if (sCtrlName == _T("closebtn")) {
|
||||
Close();
|
||||
}
|
||||
else if (sCtrlName == _T("minbtn")) {
|
||||
SendMessage(WM_SYSCOMMAND, SC_MINIMIZE, 0);
|
||||
}
|
||||
else if (sCtrlName == _T("maxbtn")) {
|
||||
Control* pMaxButton = (Control*)FindControl(L"maxbtn");
|
||||
Control* pRestoreButton = (Control*)FindControl(L"restorebtn");
|
||||
if (pMaxButton && pRestoreButton) {
|
||||
pMaxButton->SetVisible(false);
|
||||
pRestoreButton->SetVisible(true);
|
||||
}
|
||||
SendMessage(WM_SYSCOMMAND, SC_MAXIMIZE, 0);
|
||||
}
|
||||
else if (sCtrlName == _T("restorebtn")) {
|
||||
Control* pMaxButton = (Control*)FindControl(L"maxbtn");
|
||||
Control* pRestoreButton = (Control*)FindControl(L"restorebtn");
|
||||
if (pMaxButton && pRestoreButton) {
|
||||
pMaxButton->SetVisible(true);
|
||||
pRestoreButton->SetVisible(false);
|
||||
}
|
||||
SendMessage(WM_SYSCOMMAND, SC_RESTORE, 0);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void WindowImplBase::ActiveWindow()
|
||||
{
|
||||
if (::IsWindow(m_hWnd))
|
||||
{
|
||||
if (::IsIconic(m_hWnd))
|
||||
{
|
||||
::ShowWindow(m_hWnd, SW_RESTORE);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!::IsWindowVisible(m_hWnd))
|
||||
::ShowWindow(m_hWnd, SW_SHOW);
|
||||
::SetForegroundWindow(m_hWnd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void WindowImplBase::SetTaskbarTitle(const std::wstring& title)
|
||||
{
|
||||
::SetWindowTextW(m_hWnd, title.c_str());
|
||||
}
|
||||
|
||||
void WindowImplBase::ToTopMost(bool forever)
|
||||
{
|
||||
ASSERT(::IsWindow(m_hWnd));
|
||||
::SetWindowPos(m_hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
|
||||
if (!forever)
|
||||
{
|
||||
::SetWindowPos(m_hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -21,13 +21,14 @@
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{E106ACD7-4E53-4AEE-942B-D0DD426DB34E}</ProjectGuid>
|
||||
<RootNamespace>duilib</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>v120_xp</PlatformToolset>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
@ -39,13 +40,13 @@
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>v120_xp</PlatformToolset>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>v120_xp</PlatformToolset>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
@ -232,6 +233,7 @@
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<DisableSpecificWarnings>4100;4121;4127;4244;4310;4355;4481;4505;4512;4702;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
<LanguageStandard>stdcpp14</LanguageStandard>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
|
@ -23,13 +23,13 @@
|
||||
<ProjectGuid>{F1A9371F-9A34-45A0-98EB-83FF371F067F}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>basic</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v120_xp</PlatformToolset>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
@ -42,7 +42,7 @@
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v120_xp</PlatformToolset>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
@ -107,7 +107,7 @@
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
|
@ -7,7 +7,6 @@ BasicForm::BasicForm()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
BasicForm::~BasicForm()
|
||||
{
|
||||
}
|
||||
@ -27,9 +26,13 @@ std::wstring BasicForm::GetWindowClassName() const
|
||||
return kClassName;
|
||||
}
|
||||
|
||||
LRESULT BasicForm::OnNcHitTest(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
return WindowImplBase::OnNcHitTest(uMsg, wParam, lParam, bHandled);
|
||||
}
|
||||
|
||||
void BasicForm::InitWindow()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
LRESULT BasicForm::OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
|
@ -15,6 +15,7 @@ public:
|
||||
virtual std::wstring GetSkinFolder() override;
|
||||
virtual std::wstring GetSkinFile() override;
|
||||
virtual std::wstring GetWindowClassName() const override;
|
||||
virtual LRESULT OnNcHitTest(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||
|
||||
/**
|
||||
* 收到 WM_CREATE 消息时该函数会被调用,通常做一些控件初始化的操作
|
||||
@ -28,4 +29,3 @@ public:
|
||||
|
||||
static const std::wstring kClassName;
|
||||
};
|
||||
|
||||
|
@ -11,10 +11,13 @@ enum ThreadId
|
||||
};
|
||||
|
||||
int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
|
||||
_In_opt_ HINSTANCE hPrevInstance,
|
||||
_In_ LPWSTR lpCmdLine,
|
||||
_In_ int nCmdShow)
|
||||
_In_opt_ HINSTANCE hPrevInstance,
|
||||
_In_ LPWSTR lpCmdLine,
|
||||
_In_ int nCmdShow)
|
||||
{
|
||||
AllocConsole();
|
||||
freopen("CONOUT$", "w", stdout);
|
||||
|
||||
UNREFERENCED_PARAMETER(hPrevInstance);
|
||||
UNREFERENCED_PARAMETER(lpCmdLine);
|
||||
|
||||
@ -40,12 +43,13 @@ void MainThread::Init()
|
||||
// 如需修改请指定 Startup 最后两个参数
|
||||
ui::GlobalManager::Startup(theme_dir + L"resources\\", ui::CreateControlCallback(), false);
|
||||
#else
|
||||
|
||||
// Release 模式下使用资源中的压缩包作为资源
|
||||
// 资源被导入到资源列表分类为 THEME,资源名称为 IDR_THEME
|
||||
// 如果资源使用的是本地的 zip 文件而非资源中的 zip 压缩包
|
||||
// 可以使用 OpenResZip 另一个重载函数打开本地的资源压缩包
|
||||
ui::GlobalManager::OpenResZip(MAKEINTRESOURCE(IDR_THEME), L"THEME", "");
|
||||
// ui::GlobalManager::OpenResZip(L"resources.zip", "");
|
||||
//ui::GlobalManager::OpenResZip(MAKEINTRESOURCE(IDR_THEME), L"THEME", "");
|
||||
ui::GlobalManager::OpenResZip(L"resources.zip", "");
|
||||
ui::GlobalManager::Startup(L"resources\\", ui::CreateControlCallback(), false);
|
||||
#endif
|
||||
|
||||
|
@ -23,13 +23,13 @@
|
||||
<ProjectGuid>{B8588C07-9CE2-456C-83B1-86E4B65D4108}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>cef</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v120_xp</PlatformToolset>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
|
@ -23,19 +23,19 @@
|
||||
<ProjectGuid>{8BD95440-9000-4745-8011-27DD553EF06F}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>controls</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v120_xp</PlatformToolset>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v120_xp</PlatformToolset>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
@ -75,7 +75,7 @@
|
||||
<IntDir>$(ProjectDir)..\..\tmp\$(PlatformName)\$(ProjectName)\$(Configuration)\</IntDir>
|
||||
<TargetName>$(ProjectName)_d</TargetName>
|
||||
<OutDir>..\..\bin\</OutDir>
|
||||
<IncludePath>..\..\;$(IncludePath)</IncludePath>
|
||||
<IncludePath>..\..\;$(ProjectDir)..\..\duilib;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
@ -107,7 +107,7 @@
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "stdafx.h"
|
||||
#include "controls_form.h"
|
||||
#include "Utils\DpiManager.h"
|
||||
|
||||
#include <fstream>
|
||||
|
||||
@ -9,7 +10,6 @@ ControlForm::ControlForm()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
ControlForm::~ControlForm()
|
||||
{
|
||||
}
|
||||
@ -29,6 +29,16 @@ std::wstring ControlForm::GetWindowClassName() const
|
||||
return kClassName;
|
||||
}
|
||||
|
||||
bool ComboChange(ui::EventArgs* ev) {
|
||||
if (nullptr != ev) {
|
||||
printf("%d\r\n", ev->Type);
|
||||
auto p = static_cast<ui::Combo*>(ev->pSender);
|
||||
auto text = p->GetText();
|
||||
wprintf(L"%s\r\n", text.c_str());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void ControlForm::InitWindow()
|
||||
{
|
||||
/**
|
||||
@ -37,7 +47,7 @@ void ControlForm::InitWindow()
|
||||
* 不要在每次使用的时候都需要 FindControl,否则会影响性能代码不易读
|
||||
*/
|
||||
|
||||
/* Initialize ListBox data */
|
||||
/* Initialize ListBox data */
|
||||
ui::ListBox* list = dynamic_cast<ui::ListBox*>(FindControl(L"list"));
|
||||
for (auto i = 0; i < 30; i++)
|
||||
{
|
||||
@ -82,7 +92,7 @@ void ControlForm::InitWindow()
|
||||
element->SetText(nbase::StringPrintf(L"Combo element %d", i));
|
||||
combo->Add(element);
|
||||
}
|
||||
|
||||
combo->AttachAllEvents(ComboChange);
|
||||
/* Load xml file content in global misc thread, and post update RichEdit task to UI thread */
|
||||
StdClosure closure = [this]() {
|
||||
std::streamoff length = 0;
|
||||
@ -103,7 +113,9 @@ void ControlForm::InitWindow()
|
||||
}
|
||||
|
||||
// Post task to UI thread
|
||||
nbase::ThreadManager::PostTask(kThreadUI, nbase::Bind(&ControlForm::OnLoadedResourceFile, this, xml)); // or Post2UI(nbase::Bind(&ControlForm::OnLoadedResourceFile, this, xml));
|
||||
nbase::ThreadManager::PostTask(kThreadUI,
|
||||
nbase::Bind(&ControlForm::OnLoadedResourceFile, this, xml));
|
||||
// or Post2UI(nbase::Bind(&ControlForm::OnLoadedResourceFile, this, xml));
|
||||
};
|
||||
// Using ToWeakCallback to protect closure when if [ControlForm] was destoryed
|
||||
nbase::ThreadManager::PostTask(kThreadGlobalMisc, ToWeakCallback(closure)); // or Post2GlobalMisc(ToWeakCallback(closure));
|
||||
@ -111,9 +123,11 @@ void ControlForm::InitWindow()
|
||||
/* Post repeat task to update progress value 200 milliseconds once */
|
||||
StdClosure repeat_task = [this]() {
|
||||
nbase::TimeDelta time_delta = nbase::TimeDelta::FromMicroseconds(nbase::Time::Now().ToInternalValue());
|
||||
nbase::ThreadManager::PostTask(kThreadUI, nbase::Bind(&ControlForm::OnProgressValueChagned, this, time_delta.ToMilliseconds() % 100));
|
||||
nbase::ThreadManager::PostTask(kThreadUI,
|
||||
nbase::Bind(&ControlForm::OnProgressValueChagned, this, time_delta.ToMilliseconds() % 100));
|
||||
};
|
||||
nbase::ThreadManager::PostRepeatedTask(kThreadGlobalMisc, ToWeakCallback(repeat_task), nbase::TimeDelta::FromMilliseconds(200));
|
||||
nbase::ThreadManager::PostRepeatedTask(kThreadGlobalMisc,
|
||||
ToWeakCallback(repeat_task), nbase::TimeDelta::FromMilliseconds(200));
|
||||
|
||||
/* Show settings menu */
|
||||
ui::Button* settings = dynamic_cast<ui::Button*>(FindControl(L"settings"));
|
||||
@ -128,7 +142,7 @@ void ControlForm::InitWindow()
|
||||
ui::STRINGorID xml(L"settings_menu.xml");
|
||||
pMenu->Init(xml, _T("xml"), point);
|
||||
return true;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
LRESULT ControlForm::OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
@ -154,7 +168,7 @@ void ControlForm::OnProgressValueChagned(float value)
|
||||
progress->SetValue(value);
|
||||
auto circleprogress = dynamic_cast<ui::Progress*>(FindControl(L"circleprogress"));
|
||||
circleprogress->SetValue(value);
|
||||
TCHAR szBuffer[32] = {0};
|
||||
TCHAR szBuffer[32] = { 0 };
|
||||
swprintf_s(szBuffer, _T("%.0f%%"), value);
|
||||
circleprogress->SetText(szBuffer);
|
||||
}
|
@ -4,12 +4,21 @@
|
||||
#include "stdafx.h"
|
||||
#include "main.h"
|
||||
#include "controls_form.h"
|
||||
#include "Utils\DpiManager.h"
|
||||
|
||||
|
||||
int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
|
||||
_In_opt_ HINSTANCE hPrevInstance,
|
||||
_In_ LPWSTR lpCmdLine,
|
||||
_In_ int nCmdShow)
|
||||
{
|
||||
AllocConsole();
|
||||
freopen("CONOUT$", "w", stdout);
|
||||
|
||||
auto dpiManager = ui::DpiManager::GetInstance();
|
||||
dpiManager->SetAdaptDPI(); // 设置适配自动dpi
|
||||
printf("dpi is %d\r\n",dpiManager->GetDPIFromRegistry());
|
||||
|
||||
UNREFERENCED_PARAMETER(hPrevInstance);
|
||||
UNREFERENCED_PARAMETER(lpCmdLine);
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
class MiscThread : public nbase::FrameworkThread
|
||||
{
|
||||
public:
|
||||
MiscThread(enum ThreadId thread_id, const char *name)
|
||||
MiscThread(enum ThreadId thread_id, const char* name)
|
||||
: FrameworkThread(name)
|
||||
, thread_id_(thread_id) {}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2013
|
||||
VisualStudioVersion = 12.0.40629.0
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.31229.75
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "examples", "examples", "{B2087994-3DF6-4A57-B8C6-6F744520D7FA}"
|
||||
EndProject
|
||||
@ -29,6 +29,10 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "duilib", "..\duilib\duilib.
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ui_components", "..\ui_components\ui_components.vcxproj", "{0149BA6E-3C0A-426D-AA0A-0B9EC7742F19}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "proto_debuger", "proto_debuger\proto_debuger.vcxproj", "{6D78D8B7-1617-4ED4-B155-94369FC3E73C}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "catch_test", "catch_test\catch_test.vcxproj", "{91850193-0E5E-4983-9D11-F9875805D91E}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
@ -123,6 +127,22 @@ Global
|
||||
{0149BA6E-3C0A-426D-AA0A-0B9EC7742F19}.Release|Win32.Build.0 = Release|Win32
|
||||
{0149BA6E-3C0A-426D-AA0A-0B9EC7742F19}.Release|x64.ActiveCfg = Release|x64
|
||||
{0149BA6E-3C0A-426D-AA0A-0B9EC7742F19}.Release|x64.Build.0 = Release|x64
|
||||
{6D78D8B7-1617-4ED4-B155-94369FC3E73C}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{6D78D8B7-1617-4ED4-B155-94369FC3E73C}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{6D78D8B7-1617-4ED4-B155-94369FC3E73C}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{6D78D8B7-1617-4ED4-B155-94369FC3E73C}.Debug|x64.Build.0 = Debug|x64
|
||||
{6D78D8B7-1617-4ED4-B155-94369FC3E73C}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{6D78D8B7-1617-4ED4-B155-94369FC3E73C}.Release|Win32.Build.0 = Release|Win32
|
||||
{6D78D8B7-1617-4ED4-B155-94369FC3E73C}.Release|x64.ActiveCfg = Release|x64
|
||||
{6D78D8B7-1617-4ED4-B155-94369FC3E73C}.Release|x64.Build.0 = Release|x64
|
||||
{91850193-0E5E-4983-9D11-F9875805D91E}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{91850193-0E5E-4983-9D11-F9875805D91E}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{91850193-0E5E-4983-9D11-F9875805D91E}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{91850193-0E5E-4983-9D11-F9875805D91E}.Debug|x64.Build.0 = Debug|x64
|
||||
{91850193-0E5E-4983-9D11-F9875805D91E}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{91850193-0E5E-4983-9D11-F9875805D91E}.Release|Win32.Build.0 = Release|Win32
|
||||
{91850193-0E5E-4983-9D11-F9875805D91E}.Release|x64.ActiveCfg = Release|x64
|
||||
{91850193-0E5E-4983-9D11-F9875805D91E}.Release|x64.Build.0 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
@ -136,6 +156,7 @@ Global
|
||||
{A9D6DC71-C0DC-4549-AEA0-3B15B44E86A9} = {1DA0A8E2-5832-42FC-83F7-2CDCAD379C90}
|
||||
{8BD95440-9000-4745-8011-27DD553EF06F} = {B2087994-3DF6-4A57-B8C6-6F744520D7FA}
|
||||
{E35589C6-9509-4116-996F-1D045C2DACAE} = {B2087994-3DF6-4A57-B8C6-6F744520D7FA}
|
||||
{91850193-0E5E-4983-9D11-F9875805D91E} = {B2087994-3DF6-4A57-B8C6-6F744520D7FA}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {68CA0970-4242-4E4F-94D2-C19760FCA05D}
|
||||
|
@ -23,13 +23,13 @@
|
||||
<ProjectGuid>{2BFFA1EE-039D-479E-9BCC-2D12F8AEDD16}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>layouts</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v120_xp</PlatformToolset>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
|
@ -22,12 +22,13 @@
|
||||
<ProjectGuid>{FDB5539F-1060-4975-B603-B66454C8C897}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>multi_browser</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v120_xp</PlatformToolset>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
|
86
examples/proto_debuger/base_form.cpp
Normal file
86
examples/proto_debuger/base_form.cpp
Normal file
@ -0,0 +1,86 @@
|
||||
#include "base_form.h"
|
||||
#include "new_monitor_form.h"
|
||||
|
||||
const std::wstring BasicForm::kClassName = L"Basic";
|
||||
#define WM_USER_POS_CHANGED (WM_USER + 2)
|
||||
|
||||
BasicForm::BasicForm()
|
||||
{
|
||||
}
|
||||
|
||||
BasicForm::~BasicForm()
|
||||
{
|
||||
}
|
||||
|
||||
std::wstring BasicForm::GetSkinFolder()
|
||||
{
|
||||
return L"basic";
|
||||
}
|
||||
|
||||
std::wstring BasicForm::GetSkinFile()
|
||||
{
|
||||
return L"basic.xml";
|
||||
}
|
||||
|
||||
std::wstring BasicForm::GetWindowClassName() const
|
||||
{
|
||||
return kClassName;
|
||||
}
|
||||
|
||||
|
||||
LRESULT BasicForm::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
if (uMsg == WM_USER_POS_CHANGED) {
|
||||
NewMonitorForm* window = new NewMonitorForm();
|
||||
window->Create(NULL, NewMonitorForm::kClassName.c_str(), WS_OVERLAPPEDWINDOW & ~WS_MAXIMIZEBOX & WS_SIZEBOX, 0);
|
||||
window->CenterWindow();
|
||||
window->ShowModalFake(this->m_hWnd);
|
||||
nim_comp::Toast::ShowToast(L"×Ô¶¨ÒåÏûÏ¢±»µ÷ÓÃ", 1000, this->GetHWND());
|
||||
}
|
||||
return WindowImplBase::HandleMessage(uMsg, wParam, lParam);
|
||||
}
|
||||
|
||||
void BasicForm::InitWindow()
|
||||
{
|
||||
/* Show settings menu */
|
||||
ui::Button* settings = dynamic_cast<ui::Button*>(FindControl(L"test_customize"));
|
||||
if (nullptr != settings) {
|
||||
settings->AttachClick([this](ui::EventArgs* args) {
|
||||
printf("%d\r\n", ::PostMessage(this->GetHWND(), WM_USER_POS_CHANGED, 0, 0));
|
||||
return true;
|
||||
});
|
||||
}
|
||||
ui::TreeView* tree = dynamic_cast<ui::TreeView*>(FindControl(L"tree"));
|
||||
if (nullptr != tree) {
|
||||
ui::TreeNode* parent_node = nullptr;
|
||||
for (auto j = 0; j < 8; j++)
|
||||
{
|
||||
ui::TreeNode* node = new ui::TreeNode;
|
||||
node->SetClass(L"listitem");
|
||||
node->SetFixedHeight(20);
|
||||
if (parent_node)
|
||||
{
|
||||
node->SetText(nbase::StringPrintf(L"Child node %d", j));
|
||||
node->SetMargin({ 10, 0, 0, 0 });
|
||||
parent_node->AddChildNode(node);
|
||||
}
|
||||
else
|
||||
{
|
||||
node->SetText(nbase::StringPrintf(L"Parent node", j));
|
||||
tree->GetRootNode()->AddChildNode(node);
|
||||
parent_node = node;
|
||||
parent_node->AttachClick([this](ui::EventArgs* args) {
|
||||
printf("%d\r\n", ::PostMessage(this->GetHWND(), WM_USER_POS_CHANGED, 0, 0));
|
||||
return true;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
LRESULT BasicForm::OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
PostQuitMessage(0L);
|
||||
return __super::OnClose(uMsg, wParam, lParam, bHandled);
|
||||
}
|
46
examples/proto_debuger/base_form.h
Normal file
46
examples/proto_debuger/base_form.h
Normal file
@ -0,0 +1,46 @@
|
||||
#pragma once
|
||||
|
||||
// C runtime header
|
||||
#ifdef __cplusplus
|
||||
#include <stdlib.h>
|
||||
#include <malloc.h>
|
||||
#include <memory.h>
|
||||
#include <tchar.h>
|
||||
#endif
|
||||
|
||||
// base header
|
||||
#include "base/base.h"
|
||||
|
||||
// duilib
|
||||
#include "duilib/UIlib.h"
|
||||
#include "ui_components/ui_components.h"
|
||||
|
||||
|
||||
class BasicForm : public ui::WindowImplBase
|
||||
{
|
||||
public:
|
||||
BasicForm();
|
||||
~BasicForm();
|
||||
|
||||
/**
|
||||
* 一下三个接口是必须要覆写的接口,父类会调用这三个接口来构建窗口
|
||||
* GetSkinFolder 接口设置你要绘制的窗口皮肤资源路径
|
||||
* GetSkinFile 接口设置你要绘制的窗口的 xml 描述文件
|
||||
* GetWindowClassName 接口设置窗口唯一的类名称
|
||||
*/
|
||||
virtual std::wstring GetSkinFolder() override;
|
||||
virtual std::wstring GetSkinFile() override;
|
||||
virtual std::wstring GetWindowClassName() const override;
|
||||
virtual LRESULT HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) override;
|
||||
/**
|
||||
* 收到 WM_CREATE 消息时该函数会被调用,通常做一些控件初始化的操作
|
||||
*/
|
||||
void InitWindow() override;
|
||||
|
||||
/**
|
||||
* 收到 WM_CLOSE 消息时该函数会被调用
|
||||
*/
|
||||
virtual LRESULT OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||
|
||||
static const std::wstring kClassName;
|
||||
};
|
67
examples/proto_debuger/main.cpp
Normal file
67
examples/proto_debuger/main.cpp
Normal file
@ -0,0 +1,67 @@
|
||||
// basic.cpp : 定义应用程序的入口点。
|
||||
//
|
||||
|
||||
#include "main.h"
|
||||
#include "base_form.h"
|
||||
#include"resource1.h"
|
||||
#include <math.h>
|
||||
|
||||
enum ThreadId
|
||||
{
|
||||
kThreadUI
|
||||
};
|
||||
|
||||
int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
|
||||
_In_opt_ HINSTANCE hPrevInstance,
|
||||
_In_ LPWSTR lpCmdLine,
|
||||
_In_ int nCmdShow)
|
||||
{
|
||||
AllocConsole();
|
||||
freopen("CONOUT$", "w", stdout);
|
||||
|
||||
UNREFERENCED_PARAMETER(hPrevInstance);
|
||||
UNREFERENCED_PARAMETER(lpCmdLine);
|
||||
|
||||
// 创建主线程
|
||||
MainThread thread;
|
||||
// 执行主线程循环
|
||||
thread.RunOnCurrentThreadWithLoop(nbase::MessageLoop::kUIMessageLoop);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void MainThread::Init()
|
||||
{
|
||||
nbase::ThreadManager::RegisterThread(kThreadUI);
|
||||
|
||||
// 获取资源路径,初始化全局参数
|
||||
std::wstring theme_dir = nbase::win32::GetCurrentModuleDirectory();
|
||||
wprintf(L"%s\r\n", theme_dir);
|
||||
#if 1
|
||||
// Debug 模式下使用本地文件夹作为资源
|
||||
// 默认皮肤使用 resources\\themes\\default
|
||||
// 默认语言使用 resources\\lang\\zh_CN
|
||||
// 如需修改请指定 Startup 最后两个参数
|
||||
ui::GlobalManager::Startup(theme_dir + L"resources\\", ui::CreateControlCallback(), false);
|
||||
#else
|
||||
// Release 模式下使用资源中的压缩包作为资源
|
||||
// 资源被导入到资源列表分类为 THEME,资源名称为 IDR_THEME
|
||||
// 如果资源使用的是本地的 zip 文件而非资源中的 zip 压缩包
|
||||
// 可以使用 OpenResZip 另一个重载函数打开本地的资源压缩包
|
||||
ui::GlobalManager::OpenResZip(MAKEINTRESOURCE(IDR_THEME2), L"THEME", "");
|
||||
//ui::GlobalManager::OpenResZip(L"resources.zip", "");
|
||||
ui::GlobalManager::Startup(L"resources\\", ui::CreateControlCallback(), false);
|
||||
#endif
|
||||
|
||||
// 创建一个默认带有阴影的居中窗口
|
||||
BasicForm* window = new BasicForm();
|
||||
window->Create(NULL, BasicForm::kClassName.c_str(), WS_OVERLAPPEDWINDOW & ~WS_MAXIMIZEBOX & WS_SIZEBOX, 0);
|
||||
window->CenterWindow();
|
||||
window->ShowWindow();
|
||||
}
|
||||
|
||||
void MainThread::Cleanup()
|
||||
{
|
||||
ui::GlobalManager::Shutdown();
|
||||
SetThreadWasQuitProperly(true);
|
||||
nbase::ThreadManager::UnregisterThread();
|
||||
}
|
40
examples/proto_debuger/main.h
Normal file
40
examples/proto_debuger/main.h
Normal file
@ -0,0 +1,40 @@
|
||||
#pragma once
|
||||
|
||||
|
||||
// C runtime header
|
||||
#include <stdlib.h>
|
||||
#include <malloc.h>
|
||||
#include <memory.h>
|
||||
#include <tchar.h>
|
||||
|
||||
// base header
|
||||
#include "base/base.h"
|
||||
|
||||
// duilib
|
||||
#include "duilib/UIlib.h"
|
||||
|
||||
/** @class MainThread
|
||||
* @brief 主线程(UI线程)类,继承 nbase::FrameworkThread
|
||||
* @copyright (c) 2015, NetEase Inc. All rights reserved
|
||||
* @author towik
|
||||
* @date 2015/1/1
|
||||
*/
|
||||
class MainThread : public nbase::FrameworkThread
|
||||
{
|
||||
public:
|
||||
MainThread() : nbase::FrameworkThread("MainThread") {}
|
||||
virtual ~MainThread() {}
|
||||
|
||||
private:
|
||||
/**
|
||||
* 虚函数,初始化主线程
|
||||
* @return void 无返回值
|
||||
*/
|
||||
virtual void Init() override;
|
||||
|
||||
/**
|
||||
* 虚函数,主线程退出时,做一些清理工作
|
||||
* @return void 无返回值
|
||||
*/
|
||||
virtual void Cleanup() override;
|
||||
};
|
41
examples/proto_debuger/new_monitor_form.cpp
Normal file
41
examples/proto_debuger/new_monitor_form.cpp
Normal file
@ -0,0 +1,41 @@
|
||||
#include "new_monitor_form.h"
|
||||
const std::wstring NewMonitorForm::kClassName = L"Basic";
|
||||
|
||||
NewMonitorForm::NewMonitorForm()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
NewMonitorForm::~NewMonitorForm()
|
||||
{
|
||||
}
|
||||
|
||||
std::wstring NewMonitorForm::GetSkinFolder()
|
||||
{
|
||||
return L"basic";
|
||||
}
|
||||
|
||||
std::wstring NewMonitorForm::GetSkinFile()
|
||||
{
|
||||
return L"newmonitor.xml";
|
||||
}
|
||||
|
||||
std::wstring NewMonitorForm::GetWindowClassName() const
|
||||
{
|
||||
return kClassName;
|
||||
}
|
||||
|
||||
LRESULT NewMonitorForm::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
return WindowImplBase::HandleMessage(uMsg, wParam, lParam);
|
||||
}
|
||||
|
||||
void NewMonitorForm::InitWindow()
|
||||
{
|
||||
}
|
||||
|
||||
LRESULT NewMonitorForm::OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
PostQuitMessage(0L);
|
||||
return __super::OnClose(uMsg, wParam, lParam, bHandled);
|
||||
}
|
46
examples/proto_debuger/new_monitor_form.h
Normal file
46
examples/proto_debuger/new_monitor_form.h
Normal file
@ -0,0 +1,46 @@
|
||||
#pragma once
|
||||
// C runtime header
|
||||
#ifdef __cplusplus
|
||||
#include <stdlib.h>
|
||||
#include <malloc.h>
|
||||
#include <memory.h>
|
||||
#include <tchar.h>
|
||||
#endif
|
||||
|
||||
// base header
|
||||
#include "base/base.h"
|
||||
|
||||
// duilib
|
||||
#include "duilib/UIlib.h"
|
||||
#include "ui_components/ui_components.h"
|
||||
|
||||
|
||||
class NewMonitorForm : public ui::WindowImplBase
|
||||
{
|
||||
public:
|
||||
NewMonitorForm();
|
||||
~NewMonitorForm();
|
||||
|
||||
/**
|
||||
* 一下三个接口是必须要覆写的接口,父类会调用这三个接口来构建窗口
|
||||
* GetSkinFolder 接口设置你要绘制的窗口皮肤资源路径
|
||||
* GetSkinFile 接口设置你要绘制的窗口的 xml 描述文件
|
||||
* GetWindowClassName 接口设置窗口唯一的类名称
|
||||
*/
|
||||
virtual std::wstring GetSkinFolder() override;
|
||||
virtual std::wstring GetSkinFile() override;
|
||||
virtual std::wstring GetWindowClassName() const override;
|
||||
virtual LRESULT HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) override;
|
||||
/**
|
||||
* 收到 WM_CREATE 消息时该函数会被调用,通常做一些控件初始化的操作
|
||||
*/
|
||||
void InitWindow() override;
|
||||
|
||||
/**
|
||||
* 收到 WM_CLOSE 消息时该函数会被调用
|
||||
*/
|
||||
virtual LRESULT OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||
|
||||
static const std::wstring kClassName;
|
||||
};
|
||||
|
76
examples/proto_debuger/proto_debuger.rc
Normal file
76
examples/proto_debuger/proto_debuger.rc
Normal file
@ -0,0 +1,76 @@
|
||||
// Microsoft Visual C++ generated resource script.
|
||||
//
|
||||
#include "resource1.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#include "winres.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// 中文(简体,中国) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHS)
|
||||
LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED
|
||||
#pragma code_page(936)
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE
|
||||
BEGIN
|
||||
"resource1.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE
|
||||
BEGIN
|
||||
"#include ""winres.h""\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Accelerator
|
||||
//
|
||||
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// THEME
|
||||
//
|
||||
|
||||
IDR_THEME2 THEME "E:\\NIM_Duilib_Framework\\examples\\proto_debuger\\Release\\resources.zip"
|
||||
|
||||
#endif // 中文(简体,中国) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
181
examples/proto_debuger/proto_debuger.vcxproj
Normal file
181
examples/proto_debuger/proto_debuger.vcxproj
Normal file
@ -0,0 +1,181 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>16.0</VCProjectVersion>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<ProjectGuid>{6d78d8b7-1617-4ed4-b155-94369fc3e73c}</ProjectGuid>
|
||||
<RootNamespace>protodebuger</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<ReferencePath>$(VC_ReferencesPath_x86);</ReferencePath>
|
||||
<IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);..\..\;$(IncludePath)</IncludePath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<IncludePath>../../;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<ShowProgress>LinkVerbose</ShowProgress>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\base\base.vcxproj">
|
||||
<Project>{8d9a6595-717a-41c8-b468-0011a72be3d1}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\duilib\duilib.vcxproj">
|
||||
<Project>{e106acd7-4e53-4aee-942b-d0dd426db34e}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\ui_components\ui_components.vcxproj">
|
||||
<Project>{0149ba6e-3c0a-426d-aa0a-0b9ec7742f19}</Project>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="base_form.cpp" />
|
||||
<ClCompile Include="main.cpp" />
|
||||
<ClCompile Include="new_monitor_form.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="base_form.h" />
|
||||
<ClInclude Include="main.h" />
|
||||
<ClInclude Include="new_monitor_form.h" />
|
||||
<ClInclude Include="resource1.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Xml Include="..\Debug\resources\themes\default\global.xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="proto_debuger.rc" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\Release\resources.zip" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
55
examples/proto_debuger/proto_debuger.vcxproj.filters
Normal file
55
examples/proto_debuger/proto_debuger.vcxproj.filters
Normal file
@ -0,0 +1,55 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="源文件">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="头文件">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="资源文件">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="main.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="base_form.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="new_monitor_form.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="main.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="base_form.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="resource1.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="new_monitor_form.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Xml Include="..\Debug\resources\themes\default\global.xml">
|
||||
<Filter>资源文件</Filter>
|
||||
</Xml>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="proto_debuger.rc">
|
||||
<Filter>资源文件</Filter>
|
||||
</ResourceCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\Release\resources.zip" />
|
||||
</ItemGroup>
|
||||
</Project>
|
17
examples/proto_debuger/resource1.h
Normal file
17
examples/proto_debuger/resource1.h
Normal file
@ -0,0 +1,17 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Visual C++ 生成的包含文件。
|
||||
// 供 proto_debuger.rc 使用
|
||||
//
|
||||
#define IDR_ACCELERATOR1 101
|
||||
#define IDR_THEME2 103
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 104
|
||||
#define _APS_NEXT_COMMAND_VALUE 40002
|
||||
#define _APS_NEXT_CONTROL_VALUE 1001
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
@ -23,13 +23,13 @@
|
||||
<ProjectGuid>{878F5BF0-652A-4FDB-992B-BB7F26D62F0D}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>richlist</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v120_xp</PlatformToolset>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
|
@ -43,7 +43,7 @@ void MainThread::Init()
|
||||
|
||||
// 获取资源路径,初始化全局参数
|
||||
std::wstring theme_dir = nbase::win32::GetCurrentModuleDirectory();
|
||||
ui::GlobalManager::Startup(theme_dir + L"resources\\", MyCreateControlCallback, false);
|
||||
ui::GlobalManager::Startup(theme_dir + L"resources\\", MyCreateControlCallback, true);
|
||||
|
||||
// 创建一个默认带有阴影的居中窗口
|
||||
MainForm* window = new MainForm();
|
||||
|
@ -46,8 +46,6 @@ void MainForm::InitWindow()
|
||||
m_DataProvider = new Provider;
|
||||
m_pTileList->SetDataProvider(m_DataProvider);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
LRESULT MainForm::OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
@ -72,7 +70,7 @@ bool MainForm::OnClicked(ui::EventArgs* args)
|
||||
if (m_CheckBoxItemCenter->IsSelected())
|
||||
{
|
||||
m_pTileList->SetAttribute(L"width", L"auto");
|
||||
m_pTileList->SetAttribute(L"halign", L"center");
|
||||
m_pTileList->SetAttribute(L"halign", L"left");
|
||||
}
|
||||
else {
|
||||
m_pTileList->SetAttribute(L"width", L"stretch");
|
||||
@ -93,7 +91,7 @@ bool MainForm::OnClicked(ui::EventArgs* args)
|
||||
}
|
||||
else if (sName == L"btn_update")
|
||||
{
|
||||
m_DataProvider->ChangeTaskName(_ttoi(m_EditUpdate->GetText().c_str())-1,
|
||||
m_DataProvider->ChangeTaskName(_ttoi(m_EditUpdate->GetText().c_str()) - 1,
|
||||
m_EditTaskName->GetText());
|
||||
}
|
||||
else if (sName == L"btn_delete")
|
||||
|
@ -15,12 +15,13 @@
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>VirtualBox</RootNamespace>
|
||||
<ProjectName>virtualbox</ProjectName>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v120_xp</PlatformToolset>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
|
@ -23,13 +23,14 @@
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<Platform>Win32</Platform>
|
||||
<ProjectName>libcef_dll_wrapper</ProjectName>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>v120_xp</PlatformToolset>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
@ -41,7 +42,7 @@
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>v120_xp</PlatformToolset>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
|
@ -35,10 +35,12 @@ public:
|
||||
// the ownership of the dialog
|
||||
bool DoModal(ModalWndBase *dlg);
|
||||
void CancelModalThenExit();
|
||||
template<class _Ty>
|
||||
friend class Ref_count_obj;
|
||||
|
||||
private:
|
||||
template<class _Ty>
|
||||
friend class std::_Ref_count_obj;
|
||||
|
||||
|
||||
|
||||
friend class AsyncModalRunnerManager;
|
||||
friend class std::shared_ptr<AsyncModalRunner>;
|
||||
|
@ -23,19 +23,19 @@
|
||||
<ProjectGuid>{0149BA6E-3C0A-426D-AA0A-0B9EC7742F19}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>uicomponents</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v120_xp</PlatformToolset>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v120_xp</PlatformToolset>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
@ -100,6 +100,7 @@
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<AdditionalIncludeDirectories>.\;..\;..\third_party\cef_wrapper\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
@ -200,7 +201,6 @@
|
||||
<ClInclude Include="cef_control\util\util.h" />
|
||||
<ClInclude Include="menu\ui_menu.h" />
|
||||
<ClInclude Include="modal_wnd\async_do_modal.h" />
|
||||
<ClInclude Include="modal_wnd\async_modal_runner.h" />
|
||||
<ClInclude Include="modal_wnd\file_dialog_ex.h" />
|
||||
<ClInclude Include="modal_wnd\modal_wnd_base.h" />
|
||||
<ClInclude Include="msgbox\msgbox.h" />
|
||||
@ -228,7 +228,6 @@
|
||||
<ClCompile Include="cef_control\util\memory_dc.cpp" />
|
||||
<ClCompile Include="menu\ui_menu.cpp" />
|
||||
<ClCompile Include="modal_wnd\async_do_modal.cpp" />
|
||||
<ClCompile Include="modal_wnd\async_modal_runner.cpp" />
|
||||
<ClCompile Include="modal_wnd\file_dialog_ex.cpp" />
|
||||
<ClCompile Include="msgbox\msgbox.cpp" />
|
||||
<ClCompile Include="shadow_wnd\shadow_wnd.cpp" />
|
||||
|
@ -66,9 +66,6 @@
|
||||
<ClInclude Include="modal_wnd\async_do_modal.h">
|
||||
<Filter>modal_wnd</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="modal_wnd\async_modal_runner.h">
|
||||
<Filter>modal_wnd</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="modal_wnd\file_dialog_ex.h">
|
||||
<Filter>modal_wnd</Filter>
|
||||
</ClInclude>
|
||||
@ -149,9 +146,6 @@
|
||||
<ClCompile Include="modal_wnd\async_do_modal.cpp">
|
||||
<Filter>modal_wnd</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="modal_wnd\async_modal_runner.cpp">
|
||||
<Filter>modal_wnd</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="modal_wnd\file_dialog_ex.cpp">
|
||||
<Filter>modal_wnd</Filter>
|
||||
</ClCompile>
|
||||
|
@ -3,86 +3,86 @@
|
||||
|
||||
namespace nim_comp
|
||||
{
|
||||
/** @class WindowEx
|
||||
* @brief 所有窗体的基类
|
||||
* @copyright (c) 2015, NetEase Inc. All rights reserved
|
||||
* @date 2015/9/16
|
||||
*/
|
||||
class WindowEx : public ui::WindowImplBase
|
||||
{
|
||||
public:
|
||||
WindowEx();
|
||||
virtual ~WindowEx();
|
||||
/** @class WindowEx
|
||||
* @brief 所有窗体的基类
|
||||
* @copyright (c) 2015, NetEase Inc. All rights reserved
|
||||
* @date 2015/9/16
|
||||
*/
|
||||
class WindowEx : public ui::WindowImplBase
|
||||
{
|
||||
public:
|
||||
WindowEx();
|
||||
virtual ~WindowEx();
|
||||
|
||||
/**
|
||||
* 创建窗口
|
||||
* @param[in] hwndParent 父窗口句柄
|
||||
* @param[in] pstrName 窗口名称
|
||||
* @param[in] dwStyle 窗口样式
|
||||
* @param[in] dwExStyle 窗口扩展样式
|
||||
* @param[in] isLayeredWindow 是否创建分层窗口
|
||||
* @param[in] rc 窗口位置
|
||||
* @return HWND 窗口句柄
|
||||
*/
|
||||
virtual HWND Create(HWND hwndParent, LPCTSTR pstrName, DWORD dwStyle, DWORD dwExStyle,
|
||||
bool isLayeredWindow = true, const ui::UiRect& rc = ui::UiRect(0, 0, 0, 0)) override;
|
||||
|
||||
/**
|
||||
* 处理窗口被销毁的消息
|
||||
* @param[in] uMsg 消息
|
||||
* @param[in] wParam 参数
|
||||
* @param[in] lParam 参数
|
||||
* @param[out] b
|
||||
d 消息是否被处理
|
||||
* @return LRESULT 处理结果
|
||||
*/
|
||||
virtual LRESULT OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||
|
||||
/**
|
||||
* 处理ESC键单击的消息
|
||||
* @param[out] bHandled 消息是否被处理
|
||||
* @return void 无返回值
|
||||
*/
|
||||
virtual void OnEsc(BOOL& bHandled);
|
||||
|
||||
/**
|
||||
* 获取窗口类名的接口
|
||||
* @return wstring 窗口类名
|
||||
*/
|
||||
virtual std::wstring GetWindowClassName(void) const = 0;
|
||||
|
||||
/**
|
||||
* 获取窗口id的接口
|
||||
* @return wstring 窗口id
|
||||
*/
|
||||
virtual std::wstring GetWindowId(void) const = 0;
|
||||
|
||||
/**
|
||||
* 处理窗口消息
|
||||
* @param[in] uMsg 消息
|
||||
* @param[in] wParam 参数
|
||||
* @param[in] lParam 参数
|
||||
* @return LRESULT 处理结果
|
||||
*/
|
||||
virtual LRESULT HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
private:
|
||||
/**
|
||||
* 从WindowManager中注册自己
|
||||
* @return bool true 注册成功,false 注册失败
|
||||
*/
|
||||
bool RegisterWnd();
|
||||
|
||||
/**
|
||||
* 从WindowManager中反注册自己
|
||||
* @return void 无返回值
|
||||
*/
|
||||
void UnRegisterWnd();
|
||||
};
|
||||
|
||||
/**
|
||||
* 创建窗口
|
||||
* @param[in] hwndParent 父窗口句柄
|
||||
* @param[in] pstrName 窗口名称
|
||||
* @param[in] dwStyle 窗口样式
|
||||
* @param[in] dwExStyle 窗口扩展样式
|
||||
* @param[in] isLayeredWindow 是否创建分层窗口
|
||||
* @param[in] rc 窗口位置
|
||||
* @return HWND 窗口句柄
|
||||
*/
|
||||
virtual HWND Create(HWND hwndParent, LPCTSTR pstrName, DWORD dwStyle, DWORD dwExStyle,
|
||||
bool isLayeredWindow = true, const ui::UiRect& rc = ui::UiRect(0, 0, 0, 0)) override;
|
||||
|
||||
/**
|
||||
* 处理窗口被销毁的消息
|
||||
* @param[in] uMsg 消息
|
||||
* @param[in] wParam 参数
|
||||
* @param[in] lParam 参数
|
||||
* @param[out] bHandled 消息是否被处理
|
||||
* @return LRESULT 处理结果
|
||||
*/
|
||||
virtual LRESULT OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||
|
||||
/**
|
||||
* 处理ESC键单击的消息
|
||||
* @param[out] bHandled 消息是否被处理
|
||||
* @return void 无返回值
|
||||
*/
|
||||
virtual void OnEsc(BOOL &bHandled);
|
||||
|
||||
/**
|
||||
* 获取窗口类名的接口
|
||||
* @return wstring 窗口类名
|
||||
*/
|
||||
virtual std::wstring GetWindowClassName(void) const = 0;
|
||||
|
||||
/**
|
||||
* 获取窗口id的接口
|
||||
* @return wstring 窗口id
|
||||
*/
|
||||
virtual std::wstring GetWindowId(void) const = 0;
|
||||
|
||||
/**
|
||||
* 处理窗口消息
|
||||
* @param[in] uMsg 消息
|
||||
* @param[in] wParam 参数
|
||||
* @param[in] lParam 参数
|
||||
* @return LRESULT 处理结果
|
||||
*/
|
||||
virtual LRESULT HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
private:
|
||||
/**
|
||||
* 从WindowManager中注册自己
|
||||
* @return bool true 注册成功,false 注册失败
|
||||
*/
|
||||
bool RegisterWnd();
|
||||
|
||||
/**
|
||||
* 从WindowManager中反注册自己
|
||||
* @return void 无返回值
|
||||
*/
|
||||
void UnRegisterWnd();
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取弹出窗口可以显示在右下角位置的坐标
|
||||
* @return POINT 窗口坐标
|
||||
*/
|
||||
POINT GetPopupWindowPos(WindowEx* window);
|
||||
|
||||
* 获取弹出窗口可以显示在右下角位置的坐标
|
||||
* @return POINT 窗口坐标
|
||||
*/
|
||||
POINT GetPopupWindowPos(WindowEx* window);
|
||||
}
|
Loading…
Reference in New Issue
Block a user