mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 07:39:22 +02:00
wince: don't use TMap for SetProp, GetProp, use windows functions instead - they works very well
git-svn-id: trunk@18860 -
This commit is contained in:
parent
0aa059ecff
commit
d20b884a4a
@ -36,7 +36,7 @@ begin
|
||||
Assert(False, 'Trace:PropEnumProc - Start');
|
||||
Assert(False, Format('Trace:PropEnumProc - Property %S (with value 0x%X) from window 0x%X removed',
|
||||
[String(Str), Data, Window]));
|
||||
RemoveProp(Window{, Str});
|
||||
RemoveProp(Window, Str);
|
||||
Result := True;
|
||||
Assert(False, 'Trace:PropEnumProc - Exit');
|
||||
end;
|
||||
|
@ -73,11 +73,6 @@ const
|
||||
function DrawState(dc:HDC ; hbr : HBRUSH ; func: DRAWSTATEPROC ; lp:LPARAM; wp:WPARAM;x,y,cx,cy:integer;flags:UINT) : boolean;
|
||||
function GetTopWindow(hWnd:HWND):HWND;
|
||||
|
||||
function SetProp(Wnd: HWND; {lpString:LPCSTR;} hData:HANDLE):WINBOOL;
|
||||
function GetProp(Wnd: HWND{ lpString:LPCSTR}):HANDLE;
|
||||
function RemoveProp(Wnd: HWND{; lpString:LPCSTR}):HANDLE;
|
||||
function EnumProps(Wnd: HWND;lpEnumFunc:PROPENUMPROC) : integer;
|
||||
|
||||
// missing imagelist macros and constants
|
||||
|
||||
const
|
||||
@ -111,43 +106,6 @@ uses
|
||||
const
|
||||
wPattern55AA: array[1..8] of word = ($5555, $aaaa, $5555, $aaaa, $5555, $aaaa, $5555, $aaaa);
|
||||
|
||||
var
|
||||
MPropertyLists: TMap;
|
||||
|
||||
function SetProp(Wnd:HWND; {lpString:LPCSTR;} hData: HANDLE):WINBOOL;
|
||||
begin
|
||||
Result := true;
|
||||
if not MPropertyLists.SetData(Wnd, hData)
|
||||
then MPropertyLists.Add(Wnd, hData);
|
||||
end;
|
||||
|
||||
|
||||
function GetProp(Wnd:HWND{; lpString:LPCSTR}):HANDLE;
|
||||
begin
|
||||
Result := 0;
|
||||
MPropertyLists.GetData(Wnd, Result)
|
||||
end;
|
||||
|
||||
|
||||
function RemoveProp(Wnd:HWND{; lpString:LPCSTR}):HANDLE;
|
||||
begin
|
||||
Result := 0;
|
||||
if MPropertyLists.GetData(Wnd, Result)
|
||||
then MPropertyLists.Delete(Wnd);
|
||||
end;
|
||||
|
||||
//well we only have one property for each window handle so just find and call that
|
||||
// return -1 if none found!
|
||||
function EnumProps(Wnd:HWND;lpEnumFunc:PROPENUMPROC) : integer;
|
||||
var
|
||||
h:HANDLE;
|
||||
begin
|
||||
h := GetProp(Wnd);
|
||||
if h <> 0
|
||||
then Result := integer(lpEnumFunc(Wnd,'',h))
|
||||
else Result := -1;
|
||||
end;
|
||||
|
||||
function GetTopWindow(hWnd:HWND):HWND;
|
||||
begin
|
||||
Result := GetWindow(hWnd,GW_CHILD);
|
||||
@ -750,12 +708,6 @@ begin
|
||||
then Pointer(AlphaBlend) := p;
|
||||
end;
|
||||
{$endif}
|
||||
|
||||
{$if SizeOf(THandle) = 4}
|
||||
MPropertyLists := TMap.Create(itu4, 4);
|
||||
{$else}
|
||||
MPropertyLists := TMap.Create(itu8, 8);
|
||||
{$endif}
|
||||
end;
|
||||
|
||||
procedure Finalize;
|
||||
@ -764,8 +716,6 @@ begin
|
||||
if kerneldllhandle <> 0
|
||||
then FreeLibrary(kerneldllhandle);
|
||||
kerneldllhandle := 0;
|
||||
|
||||
FreeAndNil(MPropertyLists);
|
||||
end;
|
||||
|
||||
initialization
|
||||
|
@ -102,6 +102,7 @@ function GetWinCEPlatform: TApplicationType;
|
||||
|
||||
var
|
||||
DefaultWindowInfo: TWindowInfo;
|
||||
WindowInfoAtom: ATOM;
|
||||
OverwriteCheck: Integer = 0;
|
||||
ChangedMenus: TList; // list of HWNDs which menus needs to be redrawn
|
||||
|
||||
@ -1158,7 +1159,7 @@ begin
|
||||
New(WindowInfo);
|
||||
FillChar(WindowInfo^, sizeof(WindowInfo^), 0);
|
||||
WindowInfo^.DrawItemIndex := -1;
|
||||
WinCEExtra.SetProp(Window, {PChar(dword(WindowInfoAtom)),} dword(WindowInfo));
|
||||
Windows.SetProp(Window, PWideChar(DWord(WindowInfoAtom)), DWord(WindowInfo));
|
||||
Result := WindowInfo;
|
||||
end;
|
||||
|
||||
@ -1166,15 +1167,15 @@ function DisposeWindowInfo(Window: HWND): boolean;
|
||||
var
|
||||
WindowInfo: PWindowInfo;
|
||||
begin
|
||||
WindowInfo := PWindowInfo(WinCEExtra.GetProp(Window{, PChar(dword(WindowInfoAtom))}));
|
||||
Result := WinCEExtra.RemoveProp(Window{, PChar(dword(WindowInfoAtom))})<>0;
|
||||
WindowInfo := PWindowInfo(Windows.GetProp(Window, PWideChar(DWord(WindowInfoAtom))));
|
||||
Result := Windows.RemoveProp(Window, PWideChar(DWord(WindowInfoAtom)))<>0;
|
||||
if Result then
|
||||
Dispose(WindowInfo);
|
||||
end;
|
||||
|
||||
function GetWindowInfo(Window: HWND): PWindowInfo;
|
||||
begin
|
||||
Result := PWindowInfo(WinCEExtra.GetProp(Window{, PChar(dword(WindowInfoAtom))}));
|
||||
Result := PWindowInfo(Windows.GetProp(Window, PWideChar(DWord(WindowInfoAtom))));
|
||||
if Result = nil then
|
||||
Result := @DefaultWindowInfo;
|
||||
end;
|
||||
@ -1353,14 +1354,26 @@ begin
|
||||
ChangedMenus.Clear;
|
||||
end;
|
||||
|
||||
initialization
|
||||
procedure DoInitialization;
|
||||
begin
|
||||
FillChar(DefaultWindowInfo, sizeof(DefaultWindowInfo), 0);
|
||||
DefaultWindowInfo.DrawItemIndex := -1;
|
||||
WindowInfoAtom := Windows.GlobalAddAtom('WindowInfo');
|
||||
ChangedMenus := TList.Create;
|
||||
end;
|
||||
|
||||
procedure DoFinalization;
|
||||
begin
|
||||
Windows.GlobalDeleteAtom(WindowInfoAtom);
|
||||
WindowInfoAtom := 0;
|
||||
ChangedMenus.Free;
|
||||
end;
|
||||
|
||||
initialization
|
||||
DoInitialization;
|
||||
|
||||
finalization
|
||||
//roozbeh:unless i implement enumprop i should free my tpropertylist myself!
|
||||
ChangedMenus.Free;
|
||||
DoFinalization;
|
||||
|
||||
end.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user