{$REGION 'procedure ToolBarSubClass'}
procedure ToolBarSubClass(WinHandle: HWND);
begin
FToolBarInstance := MakeObjectInstance(OpenDialog.ToolBarSubClassProc);
FPrevToolBarProc := Pointer(GetWindowLongPtr(WinHandle, GWL_WNDPROC));
SetWindowLongPtr(WinHandle, GWL_WNDPROC, LPARAM(FToolBarInstance));
end;
{$ENDREGION}
{$REGION 'procedure ToolBarUnSubClass'}
procedure ToolBarUnSubClass(WinHandle: HWND);
begin
SetWindowLongPtr(WinHandle, GWL_WNDPROC, LPARAM(FPrevToolBarProc));
FreeObjectInstance(FToolBarInstance);
end;
{$ENDREGION}
{$REGION 'procedure ToolBarSubClassProc'}
procedure TSkinOpenSaveDialog.ToolBarSubClassProc(
var Message: TMessage);
begin
with Message do
begin
case Msg
of
WM_DESTROY:
Result := ToolBarProc(hToolbar, LRESULT(Msg),
Message.WPARAM,
Message.LPARAM);
WM_PAINT:
Result := ToolBarProc(hToolbar, LRESULT(Msg),
Message.WPARAM,
Message.LPARAM);
WM_PRINTCLIENT:
Result := ToolBarProc(hToolbar, LRESULT(Msg),
Message.WPARAM,
Message.LPARAM);
WM_ERASEBKGND:
Result := ToolBarProc(hToolbar, LRESULT(Msg),
Message.WPARAM,
Message.LPARAM);
end;
if (Result = 0)
then
Result := CallWindowProc(FPrevToolBarProc, hToolbar, Msg, WPARAM, LPARAM)
end;
end;
{$ENDREGION}
{$REGION 'function ToolBarProc'}
function ToolBarProc(WinHandle: HWND; Msg: UINT; wp: WPARAM; lp: LPARAM): LRESULT;
stdcall;
var
hDCTemp: HDC;
rc, rw: TRect;
ps: TPaintStruct;
lpt: TPoint;
DC: HDC;
hDCBack: HDC;
begin
Result := 0;
case Msg
of
WM_ERASEBKGND:
begin
RedrawWindow(WinHandle,
nil, 0, RDW_INVALIDATE
or RDW_ALLCHILDREN);
Result := 1;
Exit;
end;
WM_PAINT, WM_PRINTCLIENT:
begin
GetClientRect(WinHandle, rc);
if (wp = 0)
then
begin
BeginPaint(WinHandle, ps);
DC := ps.HDC;
end
else
DC := wp;
// Double Buffer erstellen
hDCTemp := SkinEngine.DoubleBuffer(
DC, rc.Right, rc.Bottom, CreateBuffer);
// Dimensionen der ToolBar auslesen
GetWindowRect(WinHandle, rw);
lpt.x := rw.Left;
lpt.y := rw.Top;
ScreenToClient(SKDialogHandle, lpt);
// Hintergrund Kopieren
hDCBack := CreateCompatibleDC(hDCTemp);
SelectObject(hDCBack, SkinEngine.GetBackBitmap(SKDialogHandle));
// Toolbar Hintergrund mit dem Parent Hintergrund füllen
BitBlt(hDCTemp, 0, 0, rc.Right, rc.Bottom, hDCBack, lpt.x, lpt.y, SRCCOPY);
// Resourcen freigeben
DeleteDC(hDCBack);
// Double Buffer freigeben
SkinEngine.DoubleBuffer(0, 0, 0, DestroyBuffer);
DeleteDC(hDCTemp);
if (wp = 0)
then
EndPaint(WinHandle, ps);
Result := 0;
Exit;
end;
WM_DESTROY:
begin
ToolBarUnSubClass(WinHandle);
Result := 1;
Exit;
end;
end;
if (Result = 0)
then
Result := CallWindowProc(FPrevToolBarProc, WinHandle, Msg, wp, lp);
end;
{$ENDREGION}