how to add system icon into resouce file?

Windows specific questions.
oyster
Posts: 216
Joined: Oct 11, 2005 10:46

how to add system icon into resouce file?

Postby oyster » Nov 10, 2018 3:40

As we know,

1. we can add a disk file into resource file

Code: Select all

1000 ICON "images\\wNim.ico"


2. for VB-like, we can use

Code: Select all

msgbox "are you sure", vbQuestion

to draw a question mark icon on the dialog

so my question is, if I want to use the icon which vbQuestion shows, but I don't want to include real icon file in compiled resource file for little file reason, how can write resource file?

Code: Select all

1000 ICON "images\\wNim.ico"
1002 ICON vbQuestion

will not be compiled by windres

thanks
UEZ
Posts: 614
Joined: May 05, 2017 19:59
Location: Germany

Re: how to add system icon into resouce file?

Postby UEZ » Nov 10, 2018 14:19

You can use WinApi to extract icons using e.g.

ExtractIconEx
SHGetFileInfoW

Searching for those functions will provide a lot of examples.
Pierre Bellisle
Posts: 42
Joined: Dec 11, 2016 17:22

Re: how to add system icon into resouce file?

Postby Pierre Bellisle » Nov 11, 2018 16:56

To elaborate a little...
You don't need anything in the resource file.
You can load the questionmark icon dynamically by using

Code: Select all

hIco = LoadImage(NULL, MAKEINTRESOURCE(OIC_QUES), IMAGE_ICON, 0, 0,  LR_SHARED)

or the older

Code: Select all

hIco = LoadIcon(NULL, IDI_QUESTION)


A MsgBox with the questionmark can be called this way

Code: Select all

MessageBox(hWnd, "My message", "AppName", MB_ICONQUESTION OR MB_OK OR MB_TOPMOST)

Return to “Windows”

Who is online

Users browsing this forum: No registered users and 2 guests