By mistake: you are trying to get the handle of the bitmap - HBITMAP, not TBitmap. These are different types, which you are informed about.
In fact. Absolutely the right decision I do not know, I will share my thoughts and pitfalls. Getting pictures on the start button depends on the version of Windows.
For a start, about the "old" Windows (for example, win2k3 server, xp apparently too).
Get the picture from the button does not work (why? - another question). The bitmap handle on SendMessage returns zero.
It remains to get the Device context (DC) function GetWindowDC and copy from there, making a "screenshot". Code like this:
function CreateWindowBitmap(Wnd: HWND): TBitmap; var R: TRect; W, H: Integer; DC: HDC; begin GetWindowRect(Wnd, R); W:=R.Right-R.Left; H:=R.Bottom-R.Top; DC:=GetWindowDC(Wnd); Result:=TBitmap.Create; try Result.Width:=w; Result.Height:=h; BitBlt(Result.Canvas.Handle,0,0,w,h,DC,0,0,SRCCOPY); finally ReleaseDC(Wnd, DC); end; end;
To transfer to this function, you need to get the handle of the button window earlier:
btm:=CreateWindowBitmap( FindWindowEx(FindWindow('Shell_TrayWnd', nil), 0, 'Button', nil);
Further it will be more difficult. About 7ku speech.
Here, the "start" button, firstly, is a separate window, it should be looked up like this:
FindWindow('Button','Start');
Secondly, it does not help, because the button also has no bitmap, SendMessage will also return 0. And the animation when you hover the mouse over the button hints that it’s unlikely there is a bitmap only.
Thirdly, the “screenshot” of the button itself will not be removed either, a black square will return, without a picture.
However, here you can still remove the "screenshot". Only it will have to be removed from the Shell_TrayWnd window. True, this window has significantly larger dimensions than we would like, and will have to take the dimensions and position of the button itself, having previously calculated the displacement of one relative to the other. Those. Take GetWindowRect for the button and substitute it in BitBlt ... (I will not paint in detail here, it should be easy to do).
These are the thoughts, if someone offers another option, I will look with interest.