Makes WinCE link to WinCE 5+ routines dynamic.

git-svn-id: trunk@25557 -
This commit is contained in:
sekelsenmat 2010-05-21 04:39:54 +00:00
parent 331b05a147
commit 6918fc7b24
3 changed files with 36 additions and 23 deletions

View File

@ -424,7 +424,7 @@ Var
DCIndex := Windows.SaveDC(PaintMsg.DC);
{$ifdef DEBUG_WINDOW_ORG}
GetWindowOrgEx(PaintMsg.DC, @WindowOrg);
LCLIntf.GetWindowOrgEx(PaintMsg.DC, @WindowOrg);
DbgAppendToFile(ExtractFilePath(ParamStr(0)) + '1.log',
Format(':> [SendPaintMessage 1] Control=%s DC=%d Moving WindowOrg from %d,%d by DX=%d DY=%d',
[lWinControl.Name, PaintMsg.DC, WindowOrg.X, WindowOrg.Y, -parLeft, -parTop]));
@ -439,7 +439,7 @@ Var
DCIndex := Windows.SaveDC(PaintMsg.DC);
{$ifdef DEBUG_WINDOW_ORG}
GetWindowOrgEx(PaintMsg.DC, @WindowOrg);
LCLIntf.GetWindowOrgEx(PaintMsg.DC, @WindowOrg);
DbgAppendToFile(ExtractFilePath(ParamStr(0)) + '1.log',
Format(':> [SendPaintMessage 2] Control=%s DC=%d Moving WindowOrg from %d,%d by DX=%d DY=%d',
[lWinControl.Name, PaintMsg.DC, WindowOrg.X, WindowOrg.Y, -parLeft, -parTop]));
@ -450,7 +450,7 @@ Var
Windows.RestoreDC(PaintMsg.DC, DCIndex);
{$ifdef DEBUG_WINDOW_ORG}
GetWindowOrgEx(PaintMsg.DC, @WindowOrg);
LCLIntf.GetWindowOrgEx(PaintMsg.DC, @WindowOrg);
DbgAppendToFile(ExtractFilePath(ParamStr(0)) + '1.log',
Format(':> [SendPaintMessage 3] Control=%s DC=%d WindowOrg=%d,%d',
[lWinControl.Name, PaintMsg.DC, WindowOrg.X, WindowOrg.Y]));
@ -489,7 +489,7 @@ Var
GetWin32ControlPos(Window, Parent, P.X, P.Y);
{$ifdef DEBUG_WINDOW_ORG}
GetWindowOrgEx(ControlDC, @Point);
LCLIntf.GetWindowOrgEx(ControlDC, @Point);
DbgAppendToFile(ExtractFilePath(ParamStr(0)) + '1.log',
Format(':> [SendParentPaintMessage] DC=%d Moving WindowsOrg From %d,%d By DX=%d DY=%d',
[ControlDC, Point.X, Point.Y, P.X, P.Y]));
@ -500,7 +500,7 @@ Var
MoveWindowOrgEx(ControlDC, P.X, P.Y);
{$ifdef DEBUG_WINDOW_ORG}
GetWindowOrgEx(ControlDC, @Point);
LCLIntf.GetWindowOrgEx(ControlDC, @Point);
DbgAppendToFile(ExtractFilePath(ParamStr(0)) + '1.log',
':< [SendParentPaintMessage] Finish');
{$endif}

View File

@ -148,8 +148,8 @@ var
// * Windows control y position inside group box is too highe
// See: http://wiki.lazarus.freepascal.org/Windows_CE_Development_Notes#Regressions
GetWindowOrgEx(PaintMsg.DC, @Point);
SetWindowOrgEx(PaintMsg.DC, 0, 0, nil);
LCLIntf.GetWindowOrgEx(PaintMsg.DC, @Point);
LCLIntf.SetWindowOrgEx(PaintMsg.DC, 0, 0, nil);
// MoveWindowOrgEx(PaintMsg.DC,-ClientBoundRect.Left,-ClientBoundRect.Top);
try
{$IFDEF DEBUG_WINCE_LABELS}
@ -161,7 +161,7 @@ var
finally
// restore DC origin
// MoveWindowOrgEx(PaintMsg.DC, ClientBoundRect.Left, ClientBoundRect.Top);
SetWindowOrgEx(PaintMsg.DC, Point.X, Point.Y, nil);
LCLIntf.SetWindowOrgEx(PaintMsg.DC, Point.X, Point.Y, nil);
end;
{$IFDEF DEBUG_WINCE_LABELS}
DbgAppendToFile(ExtractFilePath(ParamStr(0)) + '1.log',
@ -1034,7 +1034,7 @@ var
{$ENDIF}
begin
{$IFDEF DEBUG_WINCE_LABELS}
GetWindowOrgEx(DC, @Point);
LCLIntf.GetWindowOrgEx(DC, @Point);
DbgAppendToFile(ExtractFilePath(ParamStr(0)) + '1.log',
Format('trace:> [TWinCEWidgetSet.DrawText] DC:0x%x, Str:''%s'','
+ 'Count: %d, Rect = %d,%d,%d,%d, Flags:%d WindowOrg: %d:%d',
@ -1467,7 +1467,7 @@ begin
begin
{$ifdef DEBUG_WINDOW_ORG}
lControl := TControl(LCLIntf.GetLCLOwnerObject(HWnd));
GetWindowOrgEx(Result, @Point);
LCLIntf.GetWindowOrgEx(Result, @Point);
DbgAppendToFile(ExtractFilePath(ParamStr(0)) + '1.log',
Format(':> [TWinCEWidgetSet.GetDC] Name=%s DC=%s Moving WindowOrg From %d,%d By %d,%d',
[lControl.Name, IntToHex(Result, 8), Point.X, Point.Y, ORect.Left, ORect.Top]));
@ -1525,7 +1525,7 @@ begin
if not Result then exit;
OriginDiff.X := DCOrg.X - winOrg.X - ORect.Left;
OriginDiff.Y := DCOrg.Y - winOrg.Y - ORect.Top;
Result := Self.GetWindowOrgEx(PaintDC, @winOrg) <> 0;
Result := LCLIntf.GetWindowOrgEx(PaintDC, @winOrg) <> 0;
if not Result then
begin
winOrg.X := 0;
@ -2019,8 +2019,10 @@ begin
{$ifdef Win32}
Result := Integer(Windows.GetWindowOrgEx(DC, P));
{$else}
// Result := 0;
Result := Integer(WinExt.GetWindowOrgEx(DC, P));
if WinExt.GetWindowOrgEx <> nil then
Result := Integer(WinExt.GetWindowOrgEx(DC, P))
else
Result := 0;
{$endif}
end;
@ -3045,7 +3047,7 @@ begin
{$ifdef Win32}
Result:= Windows.SetWindowOrgEx(dc, NewX, NewY, OldPoint);
{$else}
if GetWinCEVersion >= wince_5 then
if WinExt.SetWindowOrgEx <> nil then
Result:= WinExt.SetWindowOrgEx(dc, NewX, NewY, OldPoint)
else
Result := False;

View File

@ -244,15 +244,20 @@ type
POPENFILENAME = ^OPENFILENAME;
{$ifndef win32}
// See: http://msdn.microsoft.com/en-us/library/aa453954.aspx
// Available in Windows CE 5.0+
function SetWindowOrgEx(
dc:HDC;
x:longint;
y:longint;
point:LPPOINT):WINBOOL; cdecl; external KernelDLL name 'SetWindowOrgEx';
function GetWindowOrgEx(DC: HDC; Point: LPPoint): BOOL; cdecl;
external KernelDLL name 'GetWindowOrgEx';
type
// See: http://msdn.microsoft.com/en-us/library/aa453954.aspx
// Available in Windows CE 5.0+
TSetWindowOrgEx = function(
dc:HDC;
x:longint;
y:longint;
point:LPPOINT):WINBOOL; cdecl;
TGetWindowOrgEx = function(DC: HDC; Point: LPPoint): BOOL; cdecl;
var
SetWindowOrgEx: TSetWindowOrgEx;
GetWindowOrgEx: TGetWindowOrgEx;
lModule: HINST;
{$endif}
Implementation
@ -369,6 +374,12 @@ Initialization
TmpStr := StrNew('');
{$ifndef Win32}
lModule := LoadLibrary(KernelDLL);
GetWindowOrgEx := TGetWindowOrgEx(GetProcAddress(lModule, 'GetWindowOrgEx'));
SetWindowOrgEx := TSetWindowOrgEx(GetProcAddress(lModule, 'SetWindowOrgEx'));
{$endif}
Finalization
Try