From 3c8e6f9173bab1ffc67a06675df3036ddec1f694 Mon Sep 17 00:00:00 2001 From: sekelsenmat Date: Sun, 16 Aug 2009 15:09:59 +0000 Subject: [PATCH] Many small fixes for TOpenDialog in wince git-svn-id: trunk@21246 - --- lcl/interfaces/wince/winceobject.inc | 11 ++--- lcl/interfaces/wince/winceproc.pp | 12 ++--- lcl/interfaces/wince/wincewinapi.inc | 63 ++++++++++++------------- lcl/interfaces/wince/wincewscontrols.pp | 2 +- lcl/interfaces/wince/wincewsdialogs.pp | 3 ++ lcl/interfaces/wince/wincewsforms.pp | 19 ++++---- 6 files changed, 54 insertions(+), 56 deletions(-) diff --git a/lcl/interfaces/wince/winceobject.inc b/lcl/interfaces/wince/winceobject.inc index 5f8cd46fd2..f8e147239b 100644 --- a/lcl/interfaces/wince/winceobject.inc +++ b/lcl/interfaces/wince/winceobject.inc @@ -148,28 +148,23 @@ begin // Create parent of all windows, 'button on taskbar' // does this work on wince?! - FAppHandle := CreateWindowExW(0, @ClsName, + (*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, Windows.LoadIcon(MainInstance, 'MAINICON')); // remove useless menuitems from sysmenu - {} // SysMenu := Windows.GetSystemMenu(FAppHandle, False); - // Windows.DeleteMenu(SysMenu, SC_MAXIMIZE, MF_BYCOMMAND); - // Windows.DeleteMenu(SysMenu, SC_SIZE, MF_BYCOMMAND); - // Windows.DeleteMenu(SysMenu, SC_MOVE, MF_BYCOMMAND); - // initialize ScreenInfo Handle := GetDesktopWindow; DC := Windows.GetDC(Handle); diff --git a/lcl/interfaces/wince/winceproc.pp b/lcl/interfaces/wince/winceproc.pp index 57c9b2b11b..5dd6e13b0f 100644 --- a/lcl/interfaces/wince/winceproc.pp +++ b/lcl/interfaces/wince/winceproc.pp @@ -1311,16 +1311,16 @@ Begin end; function GetWinCEPlatform: TApplicationType; -{$ifndef Win32} +{$ifdef Win32} +begin + Result := atDesktop; +end; +{$else} var buf: array[0..50] of WideChar; -{$endif} begin Result := atDefault; -{$ifdef Win32} - Result := atDefault;//atDesktop; -{$else} if Windows.SystemParametersInfo(SPI_GETPLATFORMTYPE, sizeof(buf), @buf, 0) then begin if WideStrCmp(@buf, 'PocketPC') = 0 then @@ -1330,8 +1330,8 @@ begin else if GetLastError = ERROR_ACCESS_DENIED then Result := atSmartphone; end; -{$endif} end; +{$endif} {------------------------------------------------------------------------------- diff --git a/lcl/interfaces/wince/wincewinapi.inc b/lcl/interfaces/wince/wincewinapi.inc index cc9fd2562c..a232109fc3 100644 --- a/lcl/interfaces/wince/wincewinapi.inc +++ b/lcl/interfaces/wince/wincewinapi.inc @@ -1684,49 +1684,46 @@ end; Returns: true on success Returns the current widget Width and Height + + Note: Windows.GetWindowInfo doesnt exist in wince, but + we can use GetWindowLong and other APIs for most information + + Also GetWindowPlacement doesnt exist ------------------------------------------------------------------------------} function TWinCEWidgetSet.GetWindowSize(Handle : hwnd; var Width, Height: integer): boolean; var - WP: WINDOWPLACEMENT; R: TRect; - Style, ExStyle: LongInt; WindowInfo: PWindowInfo; + Style, ExStyle: longint; - procedure AdjustForBuddySize; - var - BuddyWidth, BuddyHeight: integer; - begin - GetWindowSize(Windows.SendMessage(Handle, UDM_GETBUDDY, 0, 0), BuddyWidth, BuddyHeight); - Inc(Width, BuddyWidth); - end; +{ procedure AdjustForBuddySize; + var + BuddyHandle: HWND; + BuddyWP: WINDOWPLACEMENT; + begin + BuddyHandle := Windows.SendMessage(Handle, UDM_GETBUDDY, 0, 0); + if (BuddyHandle<>HWND(nil)) and Windows.GetWindowPlacement(BuddyHandle, BuddyWP) + then Width := WP.rcNormalPosition.Right - BuddyWP.rcNormalPosition.Left; + end;} begin - WP.length := SizeOf(WP); -// Result := Boolean(Windows.GetWindowPlacement(Handle, WP)); -// if (WP.showCmd=SW_MAXIMIZE) then - begin - // if the form is maximized, you can't use the normal size - Result := Boolean(Windows.GetWindowRect(Handle,@R)); - with R do - begin - Width := Right - Left; - Height := Bottom - Top; - end; - end; -{ else - with WP.rcNormalPosition do - begin - Width := Right - Left; - Height := Bottom - Top; - end;} - WindowInfo := GetWindowInfo(Handle); + Result := Boolean(Windows.GetWindowRect(Handle, R)); - //debugln('TWinCEWidgetSet.GetWindowSize ',DbgSName(WindowInfo^.WinControl),' SW_MAXIMIZE=',dbgs(WP.showCmd=SW_MAXIMIZE),' ',dbgs(WP.rcNormalPosition)); + if not Result then + Exit; + + // No special handling for maximized windows + // they dont exist in wince anyway, they are + // emulated by calculating the desktop size + Width := R.Right - R.Left; + Height := R.Bottom - R.Top; + + WindowInfo := winceproc.GetWindowInfo(Handle); // convert top level lcl window coordinaties to win32 coord - Style := Windows.GetWindowLong(Handle, GWL_STYLE); - ExStyle := Windows.GetWindowLong(Handle, GWL_EXSTYLE); + Style := Windows.GetWindowLongW(Handle, GWL_STYLE); + ExStyle := Windows.GetWindowLongW(Handle, GWL_EXSTYLE); if (Style and WS_THICKFRAME) <> 0 then begin // thick, sizing border @@ -1740,6 +1737,8 @@ begin Dec(Width, 2*Windows.GetSystemMetrics(SM_CXFIXEDFRAME)); Dec(Height, 2*Windows.GetSystemMetrics(SM_CYFIXEDFRAME)); end; + + // ExcludeCaption if (Style and WS_CAPTION) <> 0 then if (ExStyle and WS_EX_TOOLWINDOW) <> 0 then Dec(Height, Windows.GetSystemMetrics(SM_CYSMCAPTION)) @@ -1751,8 +1750,6 @@ begin end; { - - function TWinCEWidgetSet.GradientFill(DC: HDC; Vertices: PTriVertex; NumVertices: Longint; Meshes: Pointer; NumMeshes: Longint; Mode: Longint ): Boolean; diff --git a/lcl/interfaces/wince/wincewscontrols.pp b/lcl/interfaces/wince/wincewscontrols.pp index 3c44d792d9..7558caea8d 100644 --- a/lcl/interfaces/wince/wincewscontrols.pp +++ b/lcl/interfaces/wince/wincewscontrols.pp @@ -246,7 +246,7 @@ begin WindowInfo^.WinControl := AWinControl; AWinControl.Handle := Window; if SubClassWndProc <> nil then - WindowInfo^.DefWndProc := Windows.WNDPROC(Windows.SetWindowLong( + WindowInfo^.DefWndProc := Windows.WNDPROC(Windows.SetWindowLongW( Window, GWL_WNDPROC, LongInt(SubClassWndProc))); if AWinControl.Font.IsDefault then lhFont := WinCEWidgetset.MessageFont diff --git a/lcl/interfaces/wince/wincewsdialogs.pp b/lcl/interfaces/wince/wincewsdialogs.pp index 4cc3865bf9..553db36ae0 100644 --- a/lcl/interfaces/wince/wincewsdialogs.pp +++ b/lcl/interfaces/wince/wincewsdialogs.pp @@ -230,6 +230,9 @@ begin ResultForm := TWinCEFileDialogForm(ACommonDialog.Handle); ResultForm.ShowModal; + + // Without setting UserChoice the app will be locked + ACommonDialog.UserChoice := ResultForm.ModalResult; end; initialization diff --git a/lcl/interfaces/wince/wincewsforms.pp b/lcl/interfaces/wince/wincewsforms.pp index c947e037f1..22aba439e8 100644 --- a/lcl/interfaces/wince/wincewsforms.pp +++ b/lcl/interfaces/wince/wincewsforms.pp @@ -273,16 +273,17 @@ begin // customization of Params with Params do begin - //TODO: Make control respond to user scroll request - pClassName := @ClsName; + // Different from win32 FlagsEx := 0; Flags := WS_OVERLAPPEDWINDOW; - WindowTitle := StrCaption; + SubClassWndProc := nil; // Otherwise crash in wince, works in win32 + BorderStyle := TCustomForm(AWinControl).BorderStyle; + + // Same as in win32 lForm := TCustomForm(AWinControl); CalcFormWindowFlags(lForm, Flags, FlagsEx); - SubClassWndProc := nil; - Parent := 0; - BorderStyle := TCustomForm(AWinControl).BorderStyle; + pClassName := @ClsName; + WindowTitle := StrCaption; AdjustFormBounds(lForm, Bounds); // Gets the work area @@ -337,9 +338,11 @@ begin end; end else - { On Desktop mode we need to take into consideration the size of - the window decoration } + begin + { On Desktop mode we need to take into consideration the size of + the window decoration } CalculateDialogPosition(Params, Bounds, lForm); + end; end; // create window