diff --git a/lcl/interfaces/wince/winceint.pp b/lcl/interfaces/wince/winceint.pp index 5b4fd20c6c..d12121e2dc 100644 --- a/lcl/interfaces/wince/winceint.pp +++ b/lcl/interfaces/wince/winceint.pp @@ -139,10 +139,12 @@ type TWinCEWidgetSet = class(TWidgetSet) private - // The parent of all windows, represents the button of the taskbar - // This window is also the owner of the clipboard. - // Assoc. windowproc also acts as handler for popup menus - FAppHandle: HWND;//roozbeh:in win32 it was parrent of all..a window on taskbar + // In win32 it was: The parent of all windows, represents the button of the taskbar + // In wince it is just an invisible window, but retains the following functions: + // * This window is also the owner of the clipboard. + // * Assoc. windowproc also acts as handler for popup menus + // * It is indispensable for popupmenus and thread synchronization + FAppHandle: HWND; FMetrics: TNonClientMetrics; FMetricsFailed: Boolean; diff --git a/lcl/interfaces/wince/winceobject.inc b/lcl/interfaces/wince/winceobject.inc index 0f594a6f43..df587adc93 100644 --- a/lcl/interfaces/wince/winceobject.inc +++ b/lcl/interfaces/wince/winceobject.inc @@ -147,14 +147,15 @@ begin end; // Create parent of all windows, 'button on taskbar' - // does this work on wince?! - (*FAppHandle := CreateWindowExW(0, @ClsName, + // The AppHandle window is necessary for popupmenus and + // many other features, see bug 14560 + FAppHandle := CreateWindowExW(0, @ClsName, PWideChar(UTF8Decode(Application.Title)), - WS_POPUP or WS_CLIPSIBLINGS {or WS_CAPTION} or WS_SYSMENU or WS_MINIMIZEBOX, + WS_POPUP or WS_CLIPSIBLINGS or WS_CAPTION or WS_SYSMENU or WS_MINIMIZEBOX, 0, {Windows.GetSystemMetrics(SM_CXSCREEN) div 2,} 0, {Windows.GetSystemMetrics(SM_CYSCREEN) div 2,} 0, 0, HWND(nil), HMENU(nil), HInstance, nil); - AllocWindowInfo(FAppHandle);*) + AllocWindowInfo(FAppHandle); // set nice main icon SendMessage(FAppHandle, WM_SETICON, ICON_BIG, diff --git a/lcl/interfaces/wince/wincewscontrols.pp b/lcl/interfaces/wince/wincewscontrols.pp index c296589218..23a584025a 100644 --- a/lcl/interfaces/wince/wincewscontrols.pp +++ b/lcl/interfaces/wince/wincewscontrols.pp @@ -158,7 +158,9 @@ begin if AWinControl.Parent <> nil then Parent := AWinControl.Parent.Handle else - Parent := TWinCEWidgetSet(WidgetSet).AppHandle; + // Never set the parent of a window to AppHandle, + // otherwise wince will really try to make it a child + Parent := 0; SubClassWndProc := @WindowProc; StrCaption := AWinControl.Caption;