Hello everybody,
I've been trawling through the source code for all of my unit's dependencies, and I've found a chunk of code that looks super relevant to what I'm trying to do - set the system stock image (save, save as, undo, redo, copy, paste bitmaps, etc.) as my button image.
Correct me if I'm wrong, but this is what this code does:
function GetButtonIcon(idButton: Integer): TCustomBitmap;
var
BitmapHandle, MaskHandle: HBitmap;
begin
if ThemeServices.GetStockImage(idButton, BitmapHandle, MaskHandle) then
begin
Result := TBitmap.Create;
Result.Handle := BitmapHandle;
if MaskHandle <> 0 then
Result.MaskHandle := MaskHandle;
end
else
Result := GetDefaultButtonIcon(idButton);
end;
^ From the source of "Buttons" within unit dependencies ([View] -> [Unit Dependencies] -> [find the appropriate source file]).
Does anybody know what this code does and why it's there. How do I force my button to 'get' the stock image depending on OS/Desktop Environment?
Obviously I don't want you to write a crap tonne of code for me, but is it simple to use this code to 'get' the stock image for my buttons on form create?
Thanks so much for your help!