win32: implement dock image using alpha-transparent window for windows >= vista (issue #0016782)

git-svn-id: trunk@26309 -
This commit is contained in:
paul 2010-06-28 08:22:32 +00:00
parent 1ad23b7d4a
commit 7ddd34c18c
3 changed files with 41 additions and 7 deletions

View File

@ -79,7 +79,9 @@ var
GetMenuBarInfo: function(hwnd: HWND; idObject: LONG; idItem: LONG; pmbi: PMENUBARINFO): BOOL; stdcall;
GetWindowInfo: function(hwnd: HWND; pwi: PWINDOWINFO): BOOL; stdcall;
SetLayout: function(dc: HDC; l: DWord): DWord; stdcall;
SetLayeredWindowAttributes: function (HWND:hwnd;crKey :COLORREF;bAlpha : byte;dwFlags : DWORD):WINBOOL; stdcall;
SetLayeredWindowAttributes: function (HWND: hwnd; crKey: COLORREF; bAlpha: byte; dwFlags: DWORD): BOOL; stdcall;
UpdateLayeredWindow: function(hWnd: HWND; hdcDst: HDC; pptDst: PPoint; psize: PSize;
hdcSrc: HDC; pptSrc: PPoint; crKey: COLORREF; pblend: PBlendFunction; dwFlags: DWORD): BOOL; stdcall;
const
// ComCtlVersions
@ -546,7 +548,13 @@ begin
Result := GDI_ERROR;
end;
function _SetLayeredWindowAttributes(HWND:hwnd;crKey :COLORREF;bAlpha : byte;dwFlags : DWORD):WINBOOL; stdcall;
function _SetLayeredWindowAttributes(HWND: hwnd; crKey: COLORREF; bAlpha: byte; dwFlags: DWORD): BOOL; stdcall;
begin
Result := False;
end;
function _UpdateLayeredWindow(hWnd: HWND; hdcDst: HDC; pptDst: PPoint; psize: PSize;
hdcSrc: HDC; pptSrc: PPoint; crKey: COLORREF; pblend: PBlendFunction; dwFlags: DWORD): BOOL; stdcall;
begin
Result := False;
end;
@ -602,6 +610,7 @@ begin
Pointer(GetMenuBarInfo) := @_GetMenuBarInfo;
Pointer(GetWindowInfo) := @_GetWindowInfo;
Pointer(SetLayeredWindowAttributes) := @_SetLayeredWindowAttributes;
Pointer(UpdateLayeredWindow) := @_UpdateLayeredWindow;
user32handle := LoadLibrary(user32lib);
if user32handle <> 0 then
@ -621,6 +630,10 @@ begin
p := GetProcAddress(user32handle, 'SetLayeredWindowAttributes');
if p <> nil
then Pointer(SetLayeredWindowAttributes) := p;
p := GetProcAddress(user32handle, 'UpdateLayeredWindow');
if p <> nil
then Pointer(UpdateLayeredWindow) := p;
end;
// Defaults

View File

@ -122,7 +122,8 @@ type
// 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;
FAppHandle,
FDockWndHandle: HWND;
FCommonControlsVersion: DWord;
FMetrics: TNonClientMetrics;

View File

@ -331,10 +331,30 @@ const
end;
begin
if AOperation in [disMove, disHide] then
DefaultDockImage(AOldRect);
if AOperation in [disMove, disShow] then
DefaultDockImage(ANewRect);
if WindowsVersion >= wvVista then
begin
case AOperation of
disShow:
begin
FDockWndHandle := CreateWindowEx(WS_EX_LAYERED or WS_EX_TRANSPARENT or WS_EX_TOPMOST or WS_EX_TOOLWINDOW,
ClsName, 'LazDockWnd', WS_POPUP or WS_VISIBLE,
ANewRect.Left, ANewRect.Top, ANewRect.Right - ANewRect.Left, ANewRect.Bottom - ANewRect.Top, 0, 0, HINSTANCE, nil);
SetLayeredWindowAttributes(FDockWndHandle, 0, $30, LWA_ALPHA);
end;
disHide: DestroyWindow(FDockWndHandle);
disMove:
with ANewRect do
SetWindowPos(FDockWndHandle, 0, Left, Top, Right - Left, Bottom - Top, SWP_NOZORDER or SWP_NOACTIVATE);
end;
end
else
begin
if AOperation in [disMove, disHide] then
DefaultDockImage(AOldRect);
if AOperation in [disMove, disShow] then
DefaultDockImage(ANewRect);
end;
end;
procedure TWin32WidgetSet.DrawGrid(DC: HDC; const R: TRect; DX, DY: Integer);