Hi
In Lazarus 1.0.12 (and previous releases), with Windows GTK widgetset, after any TBitBtn is clicked, and then the program is ended by 'Halt', we get an error message.
ThemesServices.ThemesAvailable is called in
win32wsbuttons.pp when calling BitBtnWndProc, but at this time ThemesServices is nil.
To avoid this, I suggest the following small change :
Function BitBtnWndProc(Window: HWnd; Msg: UInt; WParam: Windows.WParam;
LParam: Windows.LParam): LResult; stdcall;
var
Info: PWin32WindowInfo;
Control: TWinControl;
ButtonImageList: BUTTON_IMAGELIST;
ImageList: HIMAGELIST;
LMessage: TLMessage;
TS : TThemeServices ;
begin
Info := GetWin32WindowInfo(Window);
if (Info = nil) or (Info^.WinControl = nil) then
begin
Result := CallDefaultWindowProc(Window, Msg, WParam, LParam);
Exit;
end
else
Control := Info^.WinControl;
case Msg of
WM_DESTROY:
begin
TS := ThemeServices ;
if Assigned(TS) then
begin
if TS.ThemesAvailable and
(Windows.SendMessage(Window, BCM_GETIMAGELIST, 0, Windows.LPARAM(@ButtonImageList)) <> 0) then
begin
// delete and destroy button imagelist
if ButtonImageList.himl <> 0 then
begin
ImageList:=ButtonImageList.himl;
ButtonImageList.himl:=0;
Windows.SendMessage(Window, BCM_SETIMAGELIST, 0, Windows.LPARAM(@ButtonImageList));
ImageList_Destroy(ImageList);
end;
end;
Result := WindowProc(Window, Msg, WParam, LParam);
end ;
end;
WM_GETFONT:
begin
Result := LResult(Control.Font.Reference.Handle);
end;
WM_UPDATEUISTATE:
begin
Result := WindowProc(Window, Msg, WParam, LParam);
DrawBitBtnImage(TBitBtn(Control), TBitBtn(Control).Caption);
end;
WM_PAINT,
WM_ERASEBKGND:
begin
if not Control.DoubleBuffered then
begin
LMessage.msg := Msg;
LMessage.wParam := WParam;
LMessage.lParam := LParam;
LMessage.Result := 0;
Result := DeliverMessage(Control, LMessage);
end
else
Result := WindowProc(Window, Msg, WParam, LParam);
end;
WM_PRINTCLIENT:
Result := CallDefaultWindowProc(Window, Msg, WParam, LParam);
else
Result := WindowProc(Window, Msg, WParam, LParam);
end;
end;
From where I am, I have no access to svn (port is blocked
).
If someone wants to update for me, he is welcome !
Regards,