CtrlCore: Fixed issue with popups and click on disabled parent dialog

git-svn-id: svn://ultimatepp.org/upp/trunk@13946 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2020-01-27 14:47:21 +00:00
parent d0054ee7a2
commit 79506b97cf
4 changed files with 11 additions and 31 deletions

View file

@ -308,11 +308,7 @@ void Ctrl::Enable(bool aenable) {
GuiLock __;
if(enabled != aenable) {
enabled = aenable;
// 01/12/2007 - mdelfede
// added support for windowed controls
// if(!parent) WndEnable(enabled);
if(top) WndEnable(enabled);
// 01/12/2007 - END
if(!enabled && parent && HasFocusDeep())
IterateFocusForward(this, GetTopCtrl());
RefreshFrame();

View file

@ -310,7 +310,7 @@ void Ctrl::KillFocusWnd()
void Ctrl::ClickActivateWnd()
{
GuiLock __;
LLOG("Ctrl::ClickActivateWnd");
LLOG("Ctrl::ClickActivateWnd " << Name(this));
if(this == ~focusCtrlWnd && focusCtrl && focusCtrl->GetTopCtrl() != this) {
LLOG("Ctrl::ClickActivateWnd -> ActivateWnd");
ActivateWnd();

View file

@ -39,8 +39,6 @@ void AvoidPaintingCheck__()
Ctrl::painting = false;
}
void SetWinceMouse(HWND hwnd, LPARAM lparam) {}
dword GetKeyStateSafe(dword what) {
bool h = Ctrl::painting;
Ctrl::painting = false;
@ -126,7 +124,6 @@ LRESULT Ctrl::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) {
#ifdef PLARFORM_WINCE
wince_mouseleft = true;
#endif
SetWinceMouse(hwnd, lParam);
ClickActivateWnd();
if(ignoreclick) return 0L;
DoMouse(LEFTDOWN, Point((dword)lParam), 0);
@ -200,7 +197,6 @@ LRESULT Ctrl::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) {
break;
#endif
case WM_MOUSEMOVE:
SetWinceMouse(hwnd, lParam);
LLOG("WM_MOUSEMOVE: ignoreclick = " << ignoreclick);
if(ignoreclick) {
EndIgnore();
@ -305,10 +301,8 @@ LRESULT Ctrl::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) {
return 1L;
case WM_DESTROY:
PreDestroy();
#ifndef PLATFORM_WINCE
break;
case WM_NCDESTROY:
#endif
if(!hwnd) break;
if(HasChildDeep(mouseCtrl) || this == ~mouseCtrl) mouseCtrl = NULL;
if(HasChildDeep(focusCtrl) || this == ~focusCtrl) focusCtrl = NULL;
@ -322,14 +316,10 @@ LRESULT Ctrl::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) {
if(owner && (owner->IsForeground() || IsForeground()) && !owner->SetWantFocus())
IterateFocusForward(owner, owner);
}
#ifdef PLATFORM_WINCE
DefWindowProc(hwnd, message, wParam, lParam);
#else
if(IsWindowUnicode(hwnd)) // TRC 04/10/17: ActiveX unicode patch
DefWindowProcW(hwnd, message, wParam, lParam);
else
DefWindowProc(hwnd, message, wParam, lParam);
#endif
hwnd = NULL;
return 0L;
case WM_CANCELMODE:
@ -340,13 +330,18 @@ LRESULT Ctrl::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) {
visible = (BOOL) wParam;
StateH(SHOW);
break;
#ifndef PLATFORM_WINCE
case WM_MOUSEACTIVATE:
LLOG("WM_MOUSEACTIVATE " << Name() << ", focusCtrlWnd = " << UPP::Name(focusCtrlWnd) << ", raw = " << (void *)::GetFocus());
if(!IsEnabled()) {
if(lastActiveWnd && lastActiveWnd->IsEnabled()) {
LLOG("WM_MOUSEACTIVATE -> ::SetFocus for " << UPP::Name(lastActiveWnd));
::SetFocus(lastActiveWnd->GetHWND());
if(focusCtrl) { // this closes popup
LLOG("WM_MOUSEACTIVATE -> ClickActivateWnd for " << UPP::Name(lastActiveWnd));
lastActiveWnd->ClickActivateWnd();
}
else { // this makes child dialog active when clicked on disabled parent
LLOG("WM_MOUSEACTIVATE -> ::SetFocus for " << UPP::Name(lastActiveWnd));
::SetFocus(lastActiveWnd->GetHWND());
}
}
else
MessageBeep(MB_OK);
@ -354,12 +349,10 @@ LRESULT Ctrl::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) {
}
if(IsPopUp()) return MA_NOACTIVATE;
break;
#endif
case WM_SIZE:
case WM_MOVE:
if(hwnd) {
Rect rect;
#ifndef PLATFORM_WINCE
if(activex) {
WINDOWPLACEMENT wp;
wp.length = sizeof(WINDOWINFO);
@ -367,7 +360,6 @@ LRESULT Ctrl::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) {
rect = wp.rcNormalPosition;
}
else
#endif
rect = GetScreenClient(hwnd);
LLOG("WM_MOVE / WM_SIZE: screen client = " << rect);
if(GetRect() != rect)
@ -387,7 +379,7 @@ LRESULT Ctrl::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) {
break;
case WM_SETFOCUS:
LLOG("WM_SETFOCUS " << Name() << ", focusCtrlWnd = " << UPP::Name(focusCtrlWnd) << ", raw = " << (void *)::GetFocus());
if(this != focusCtrlWnd) {
if(this != focusCtrlWnd || focusCtrl && focusCtrlWnd != focusCtrl->GetTopCtrl()) { // second condition fixes popup issue when clicking dialog parent
if(IsEnabled()) {
LLOG("WM_SETFOCUS -> ActivateWnd: this != focusCtrlWnd, this = "
<< Name() << ", focusCtrlWnd = " << UPP::Name(focusCtrlWnd));

View file

@ -1066,25 +1066,17 @@ Rect Ctrl::GetPrimaryScreenArea()
int Ctrl::GetKbdDelay()
{
GuiLock __;
#ifdef PLATFORM_WINCE
return 500;
#else
int a;
SystemParametersInfo(SPI_GETKEYBOARDDELAY, 0, &a, 0);
return 250 + a * 750 / 4;
#endif
}
int Ctrl::GetKbdSpeed()
{
GuiLock __;
#ifdef PLATFORM_WINCE
return 1000 / 32;
#else
int a;
SystemParametersInfo(SPI_GETKEYBOARDSPEED, 0, &a, 0);
return 1000 / (a + 2);
#endif
}
void Ctrl::SetWndForeground()
@ -1255,7 +1247,7 @@ void Ctrl::WndScrollView(const Rect& r, int dx, int dy)
void Ctrl::PopUpHWND(HWND owner, bool savebits, bool activate, bool dropshadow, bool topmost)
{
LLOG("PopUpHWND " << UPP::Name(this) << ", owner: " << owner);
LLOG("PopUpHWND " << UPP::Name(this) << ", owner: " << owner << ", activate: " << activate);
popup = false;
Create(owner, WS_POPUP, topmost ? WS_EX_TOPMOST : 0, savebits,
owner || !activate ? SW_SHOWNOACTIVATE : SW_SHOW,