wince: don't disable self MenuBar window on ShowModal (#0011913)

git-svn-id: trunk@16342 -
This commit is contained in:
paul 2008-09-01 05:27:42 +00:00
parent 81a450222b
commit d0e2626172
3 changed files with 83 additions and 87 deletions

View File

@ -14,7 +14,7 @@
*****************************************************************************
}
type
TWinControlAccess = class(TWinControl);
TWinControlAccess = class(TWinControl);
{*************************************************************}
{ callback routines }
@ -253,7 +253,7 @@ Var
Result := PopupMenu.FindItem(LOWORD(WParam), fkCommand);
end;
{$ifndef win32}
if Result=nil then //if Result is still nil, process main menu
if Result = nil then //if Result is still nil, process main menu
begin
MainMenuHandle := SHFindMenuBar(Window);
// roozbeh : this is the only way we have
@ -1063,69 +1063,64 @@ begin
end
else
begin
{ Handles other reasons for WM_COMMAND }
if Hi(WParam) < 2 then //1 for accelerator 0 for menu
TargetObject := GetMenuItemObject else // menuitem or shortcut
TargetObject := nil;
if TargetObject is TMenuItem then
begin
if (Hi(WParam) = 0) or (Hi(WParam) = 1) then
{ Handles other reasons for WM_COMMAND }
if Hi(WParam) < 2 then //1 for accelerator 0 for menu
TargetObject := GetMenuItemObject else // menuitem or shortcut
TargetObject := nil;
if TargetObject is TMenuItem then
begin
LMessage.Msg := LM_ACTIVATE;
TargetObject.Dispatch(LMessage);
end;
lWinControl := nil;
end else
begin
lWinControl := GetWindowInfo(LParam)^.WinControl;
// buddy controls use 'awincontrol' to designate associated wincontrol
if lWinControl = nil then
lWinControl := GetWindowInfo(LParam)^.AWinControl;
if lWinControl is TCustomButton then
case Hi(WParam) of
BN_CLICKED: LMessage.Msg := LM_CLICKED;
BN_KILLFOCUS: LMessage.Msg := LM_EXIT;
end
else if (lWinControl is TCustomEdit) then
case Hi(WParam) of
EN_CHANGE: LMessage.Msg := CM_TEXTCHANGED;
end
{ else if (lWinControl is TCustomFloatSpinEdit) then
case Hi(WParam) of
EN_CHANGE: HandleSpinEditChange(TCustomFloatSpinEdit(lWinControl));
end}
else if (lWinControl is TCustomMemo) then
case Hi(WParam) of
// multiline edit doesn't send EN_CHANGE, so use EN_UPDATE
EN_UPDATE: LMessage.Msg := CM_TEXTCHANGED;
end
else if (lWinControl is TCustomListBox) then
case Hi(WParam) of
LBN_SELCHANGE: LMessage.Msg := LM_SELCHANGE;
end
else if lWinControl is TCustomCombobox then
case Hi(WParam) of
CBN_EDITCHANGE: LMessage.Msg := LM_CHANGED;
{ CBN_EDITCHANGE is only sent after the user changes the edit box.
CBN_SELCHANGE is sent when the user changes the text by
selecting in the list, but before text is actually changed.
itemindex is updated, so set text manually }
CBN_SELCHANGE: begin
UpdateComboBoxText(TCustomComboBox(lWinControl));
LMessage.Msg := LM_SELCHANGE;
lWinControl := nil;
end else
begin
lWinControl := GetWindowInfo(LParam)^.WinControl;
// buddy controls use 'awincontrol' to designate associated wincontrol
if lWinControl = nil then
lWinControl := GetWindowInfo(LParam)^.AWinControl;
if lWinControl is TCustomButton then
case Hi(WParam) of
BN_CLICKED: LMessage.Msg := LM_CLICKED;
BN_KILLFOCUS: LMessage.Msg := LM_EXIT;
end
else if (lWinControl is TCustomEdit) then
case Hi(WParam) of
EN_CHANGE: LMessage.Msg := CM_TEXTCHANGED;
end
{ else if (lWinControl is TCustomFloatSpinEdit) then
case Hi(WParam) of
EN_CHANGE: HandleSpinEditChange(TCustomFloatSpinEdit(lWinControl));
end}
else if (lWinControl is TCustomMemo) then
case Hi(WParam) of
// multiline edit doesn't send EN_CHANGE, so use EN_UPDATE
EN_UPDATE: LMessage.Msg := CM_TEXTCHANGED;
end
else if (lWinControl is TCustomListBox) then
case Hi(WParam) of
LBN_SELCHANGE: LMessage.Msg := LM_SELCHANGE;
end
else if lWinControl is TCustomCombobox then
case Hi(WParam) of
CBN_EDITCHANGE: LMessage.Msg := LM_CHANGED;
{ CBN_EDITCHANGE is only sent after the user changes the edit box.
CBN_SELCHANGE is sent when the user changes the text by
selecting in the list, but before text is actually changed.
itemindex is updated, so set text manually }
CBN_SELCHANGE: begin
UpdateComboBoxText(TCustomComboBox(lWinControl));
LMessage.Msg := LM_SELCHANGE;
end;
{ closeup message is sent before text is actually changed... *sigh*
itemindex is updated, so set text manually }
CBN_CLOSEUP:
UpdateComboBoxText(TCustomComboBox(lWinControl));
end;
{ closeup message is sent before text is actually changed... *sigh*
itemindex is updated, so set text manually }
CBN_CLOSEUP:
UpdateComboBoxText(TCustomComboBox(lWinControl));
end;
end;
// no specific message found? try send a general msg
if (LMessage.Msg = LM_NULL) and (lWinControl <> nil) then
lWinControl.Perform(CN_COMMAND, WParam, LParam);
end;
// no specific message found? try send a general msg
if (LMessage.Msg = LM_NULL) and (lWinControl <> nil) then
lWinControl.Perform(CN_COMMAND, WParam, LParam);
end;
end;
{

View File

@ -7,14 +7,17 @@ interface
uses
// Libs
Windows,
{$ifndef Win32}oleauto,{$endif}
{$ifdef win32}
win32compat,
{$else}
oleauto, aygshell,
{$endif}
// compatibility
{$ifdef Win32}win32compat,{$endif}
// RTL, LCL
Classes, LMessages, LCLType, LCLProc, Controls, Forms, Menus,
WinCEExtra, GraphType;
Type
type
TEventType = (etNotify, etKey, etKeyPress, etMouseWheel, etMouseUpDown);
PWindowInfo = ^TWindowInfo;
@ -1246,28 +1249,23 @@ end;
-----------------------------------------------------------------------------}
function DisableWindowsProc(Window: HWND; Data: LParam): LongBool; {$ifdef Win32}stdcall;{$else}cdecl;{$endif}
var
// Buffer: array[0..15] of WideChar;
DisableWindowsInfo: PDisableWindowsInfo absolute Data;
begin
Result:=true;
Result := True;
// Only disable windows from our application
if DisableWindowsInfo^.ProcessID <> GetWindowThreadProcessId(Window, nil) then
Exit;
// Don't disable the current window form
if Window = DisableWindowsInfo^.NewModalWindow then exit;
// Don't disable the current window form or menu of that form
if (Window = DisableWindowsInfo^.NewModalWindow)
{$ifndef Win32}
or (Window = SHFindMenuBar(DisableWindowsInfo^.NewModalWindow))
{$endif} then Exit;
// Don't disable any ComboBox listboxes
{
This causes a crash when exiting the dialog under arm-wince
All disabled windows will be enabled again, so it shouldn't be
a big problem to disable the ComboBox listboxes.
if (GetClassNameW(Window, @Buffer, sizeof(Buffer))<sizeof(Buffer))
and (WideCompareText(widestring(@Buffer), 'ComboLBox')=0) then exit;}
if not IsWindowVisible(Window) or not IsWindowEnabled(Window) then exit;
if not IsWindowVisible(Window) or
not IsWindowEnabled(Window) then
Exit;
DisableWindowsInfo^.DisabledWindowList.Add(Pointer(Window));
EnableWindow(Window, False);

View File

@ -204,13 +204,15 @@ begin
hasLMenu := false;
hasRMenu := false;
FillChar(mi, SizeOf(mi), 0);
with mi do begin
with mi do
begin
cbSize:=SizeOf(mi);
fMask:=MIIM_SUBMENU or MIIM_TYPE or MIIM_ID or MIIM_STATE;
dwTypeData:=@buf;
end;
if Menu <> 0 then begin
if Menu <> 0 then
begin
if GetMenuItemInfo(Menu, 0, True, mi) then//does it have left menu?
hasLMenu := True;
if GetMenuItemInfo(Menu, 1, True, mi) then//does it have right menu?
@ -220,12 +222,13 @@ begin
GetWindowRect(Wnd, BR);
mbi.hwndMB:=SHFindMenuBar(Wnd);
FillChar(mbi, SizeOf(mbi), 0);
with mbi do begin
cbSize:=SizeOf(mbi);
hwndParent:=Wnd;
dwFlags:=SHCMBF_HMENU;
nToolBarId:=MenuBarIDS[hasLMenu,hasRMenu];
hInstRes:=HINSTANCE;
with mbi do
begin
cbSize := SizeOf(mbi);
hwndParent := Wnd;
dwFlags := SHCMBF_HMENU;
nToolBarId := MenuBarIDS[hasLMenu,hasRMenu];
hInstRes := HINSTANCE;
end;
{if found a menubar check if it matches number of buttons of previous menubar...}
@ -295,7 +298,7 @@ begin
end;
end;
GetWindowRect(mbi.hwndMB, R);
GetWindowRect(mbi.hwndMB, R);
// if BR.Bottom > R.Top then
// SetWindowPos(wnd, 0, 0, 0, BR.Right - BR.Left, R.Top - BR.Top, SWP_NOZORDER or SWP_NOREPOSITION or SWP_NOMOVE);
@ -431,7 +434,7 @@ var
Index, fstate, cmd: integer;
begin
ParentMenuHandle := AMenuItem.Parent.Handle;
FillChar(MenuInfo, SizeOf(MenuInfo), 0);
{Following part fixes the case when an item is added in runtime