Hello again im sorry if this is the worng place my last thread was moved away from here...
I got a simple question i think, I want to get to the real buffer in a handle. I got a hIcon that i comes from ExtractAssociatedIcon and i want to open this handle and get to the real bits and later save it to a file, like a dump. i figured that GetObject may be the solution but i keep getting error with GetObject.
Anyone has a clue ??
Quote from: lilljocke on October 15, 2008, 02:24:17 PM
Hello again im sorry if this is the worng place my last thread was moved away from here...
When posts are moved by moderators then there is a reason for it. In this case "The Campus" is the correct place for your questions. The MASM32 is a place for questions about MASM32.
Please take a moment and choose the correct place to post... by doing this you will increase your chance of obtaining the answers faster.
As far as I know GetObject does not support icons, you will have to convert it to a bitmap first. I use the following routine in TBPaint to convert icons to bitmaps for use in a toolbar...
; hIcon = handle to a square icon
; ix = width of the icon (height is assumed to be equal)
IconToBmp PROC hICON :DWORD,ix:DWORD
LOCAL myDC :DWORD
LOCAL hDC :DWORD
LOCAL PrevBmp :DWORD
LOCAL hBrush :DWORD
LOCAL OldObj :DWORD
LOCAL hRgn :DWORD
LOCAL hBmp :DWORD
invoke GetDC, hManagerDlg
mov hDC,eax
invoke CreateCompatibleDC, hDC
mov myDC, eax
invoke CreateIndependantBitmap,hDC, ix, ix
mov hBmp, eax
invoke SelectObject, myDC, eax
mov PrevBmp, eax
invoke ReleaseDC,hManagerDlg,hDC
invoke CreateSolidBrush, 0FFFFFFh
mov hBrush,eax
invoke SelectObject, myDC, hBrush
mov OldObj,eax
invoke CreateRectRgn, 0, 0, ix, ix
mov hRgn,eax
invoke PaintRgn, myDC, hRgn
invoke DeleteObject,hRgn
invoke SelectObject,myDC,OldObj
invoke DeleteObject,hBrush
invoke DrawIconEx, myDC, 0, 0, hICON, ix, ix, 0, FALSE, DI_NORMAL
invoke SelectObject, myDC, PrevBmp
invoke DeleteDC, myDC
invoke DestroyIcon, hICON
mov eax,hBmp
ret
IconToBmp ENDP