diff --git a/lcl/interfaces/win32/win32extra.pas b/lcl/interfaces/win32/win32extra.pas index 2a62db5501..84ecaa5ab4 100644 --- a/lcl/interfaces/win32/win32extra.pas +++ b/lcl/interfaces/win32/win32extra.pas @@ -79,6 +79,7 @@ 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; const // ComCtlVersions @@ -545,6 +546,11 @@ begin Result := GDI_ERROR; end; +function _SetLayeredWindowAttributes(HWND:hwnd;crKey :COLORREF;bAlpha : byte;dwFlags : DWORD):WINBOOL; stdcall; +begin + Result := False; +end; + const msimg32lib = 'msimg32.dll'; user32lib = 'user32.dll'; @@ -595,6 +601,7 @@ begin Pointer(GetComboboxInfo) := @_GetComboboxInfo; Pointer(GetMenuBarInfo) := @_GetMenuBarInfo; Pointer(GetWindowInfo) := @_GetWindowInfo; + Pointer(SetLayeredWindowAttributes) := @_SetLayeredWindowAttributes; user32handle := LoadLibrary(user32lib); if user32handle <> 0 then @@ -610,6 +617,10 @@ begin p := GetProcAddress(user32handle, 'GetWindowInfo'); if p <> nil then Pointer(GetWindowInfo) := p; + + p := GetProcAddress(user32handle, 'SetLayeredWindowAttributes'); + if p <> nil + then Pointer(SetLayout) := p; end; // Defaults @@ -633,6 +644,7 @@ begin if p <> nil then Pointer(SetLayout) := p; end; + end; procedure Finalize; diff --git a/lcl/interfaces/win32/win32wsextdlgs.pp b/lcl/interfaces/win32/win32wsextdlgs.pp index ed0fcb5453..54c0852b90 100644 --- a/lcl/interfaces/win32/win32wsextdlgs.pp +++ b/lcl/interfaces/win32/win32wsextdlgs.pp @@ -96,7 +96,7 @@ type implementation -{$r win32wsextdlgs.rc} +{.$r win32wsextdlgs.rc} function OpenPictureDialogCallBack(hWnd: Handle; uMsg: UINT; wParam: WPARAM; lParam: LPARAM): UINT; stdcall; diff --git a/lcl/interfaces/win32/win32wsforms.pp b/lcl/interfaces/win32/win32wsforms.pp index 7122c55dff..67766c01a2 100644 --- a/lcl/interfaces/win32/win32wsforms.pp +++ b/lcl/interfaces/win32/win32wsforms.pp @@ -85,7 +85,7 @@ type class procedure SetIcon(const AForm: TCustomForm; const Small, Big: HICON); override; class procedure SetShowInTaskbar(const AForm: TCustomForm; const AValue: TShowInTaskbar); override; class procedure ShowModal(const ACustomForm: TCustomForm); override; - class procedure SetAlphaBlend(const ACustomForm: TCustomForm; AlphaValue: single); override; + class procedure SetAlphaBlend(const ACustomForm: TCustomForm; Alpha: single); override; end; { TWin32WSForm } @@ -483,28 +483,24 @@ begin BringWindowToTop(ACustomForm.Handle); end; -var - SetLayeredWindowAttributes_ : function (HWND:hwnd;crKey :COLORREF;bAlpha : byte;dwFlags : DWORD):WINBOOL; stdcall = nil; // external 'user32' name 'SetLayeredWindowAttributes'; - -class procedure TWin32WSCustomForm.SetAlphaBlend(const ACustomForm: TCustomForm; AlphaValue: single); +class procedure TWin32WSCustomForm.SetAlphaBlend(const ACustomForm: TCustomForm; Alpha: single); var style : LongWord; begin - if not Assigned(SetLayeredWindowAttributes_) then - Pointer(SetLayeredWindowAttributes_):=GetProcAddress(GetModuleHandle('user32.dll'), 'SetLayeredWindowAttributes'); - if not Assigned(SetLayeredWindowAttributes_) then Exit; + if not WSCheckHandleAllocated(ACustomForm, 'SetAlphaBlend') then + Exit; if Alpha<0 then Alpha:=0 else if Alpha>1 then Alpha:=1; - style:=GetWindowLong(AForm.Handle,GWL_EXSTYLE); + style:=GetWindowLong(ACustomForm.Handle,GWL_EXSTYLE); if Alpha<1 then begin - if (style and WS_EX_LAYERED) = 0 then SetWindowLong(AForm.Handle, GWL_EXSTYLE, style or WS_EX_LAYERED); - SetLayeredWindowAttributes_(AForm.Handle, 0, Round(Alpha*255), LWA_ALPHA); + if (style and WS_EX_LAYERED) = 0 then SetWindowLong(ACustomForm.Handle, GWL_EXSTYLE, style or WS_EX_LAYERED); + Win32Extra.SetLayeredWindowAttributes(ACustomForm.Handle, 0, Round(Alpha*255), LWA_ALPHA); end else begin - SetWindowLong(AForm.Handle, GWL_EXSTYLE, style and not WS_EX_LAYERED); - RedrawWindow(AForm.Handle, nil, 0, RDW_ERASE or RDW_INVALIDATE or RDW_FRAME or RDW_ALLCHILDREN); + SetWindowLong(ACustomForm.Handle, GWL_EXSTYLE, style and not WS_EX_LAYERED); + RedrawWindow(ACustomForm.Handle, nil, 0, RDW_ERASE or RDW_INVALIDATE or RDW_FRAME or RDW_ALLCHILDREN); end; end;