News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

How to save an ICON to Disk

Started by Smith2008, February 20, 2010, 07:01:11 AM

Previous topic - Next topic

Smith2008

Hi
My question is:
How to save an ICON to Disk using icon handle.

my code is this:

.const
szFileName             DB  "C:\app.exe",0

.data?
hInstance dd ?
hIcon1  dd ?;   // icon handle   
hdc1 dd ?;        // handle of display context
.
.
.
invoke ExtractIcon,hInstance,offset szFileName,0
mov hIcon1,eax
invoke GetDC,hWin
mov hdc1,eax
invoke DrawIcon,hdc1, 10, 20, hIcon1



I have got the HICON and assigned to hdc1 ,but have to save to harddisk? ::)

any help or hint will be appreciated.

BlackVortex

I think you have to use GetDIBits to get a buffer with the actual bitmap bits. I'm not sure how it should be saved to disk (don't know about the bmp format)

You may need to load the handle with LoadImage. Can you at least show the ico correctly at the moment ? Leave the disk saving for last.

Smith2008

invoke DrawIcon,hdc1, 10, 20, hIcon1
with this code the main form which has hWin handle,And yes it draws and shows the icon in the Form.
I have the handle of ICON on app.exe which is in other directory.

BlackVortex

Ok, then get the bits with that function I mentioned.

Nordwind64

Greetings, Nordwind.
Windows 7 (64Bit), JWASM/PoLink