Assign and image

I am working with dialog boxes and am looking for a way to change an image within the dialog box by code to one from a resource file.

I have used LoadImage to load the image with no problem but cannot figure out how to assign it to the control in the dialog box (i have tried SendMessge, SendDlgItemMessage and others but they don't work)

Can anyone help?
GroundFloorAsked:
Who is Participating?
 
Slick812Commented:
if you are using API then you better get use to constantly looking at and reading the Win32 Help, if you look at the Help for static controls you can see the messages that are just for STATIC controls, these messages include -
STM_SETIMAGE


here is some code from the Help -

SendDlgItemMessage(hDlg,  /* dialog box window handle */
               IDI_ICON,              /* icon identifier          */
               STM_SETIMAGE,          /* message to send          */
               (WPARAM) IMAGE_ICON,   /* image type               */
               (LPARAM) aIcons[i++]); /* icon handle              */


in Pascal -

SendDlgItemMessage(hDlg, 188,  STM_SETIMAGE, IMAGE_BITMAP, hBitmap);

maybe this will work?
0
 
Slick812Commented:
what is the control?
STATIC
BUTTON

some other?
 I am guessing that the dialog control already is showing an Image?

and what message do you use?
0
 
mikelittlewoodCommented:
If your trying to change the image for a message dialog, take a look at

http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_10037334.html
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
GroundFloorAuthor Commented:
its a CONTROL, SS_BITMAP with an ID of 188

I can add the graphic if i add the resource into the same dialog creation script but if i add the graphic as a resource and try to add it it is then i run into the problem of what command to use to assign the image to the control.
0
 
GroundFloorAuthor Commented:
aslo, i looked through http://www.angelfire.com/hi5/delphizeus/dialogs.html and couldn't find anything about it.
0
 
GroundFloorAuthor Commented:
Thanks Slick812

I looked in the Win32 Help and on MSDN but didn't find anything about STM_IMAGE.

I am using your suggestion of SendDlgItemMessage but the image is not displaying - but i think that may be something i am doing wrong and am trying different ways to see if i can get it to work.

Maybe you should write a book about all of this - i would buy it because there is nothing of use out there.

0
 
Slick812Commented:
OK,
are you sure that your LoadImage is not returning Zero? You need a valid bitmap Handle, , , ,
there are only 5 parameters in the SendDlgItemMessage( ), have you checked all 5 to see if they are valid?

as to the MSDN Library, I could not beleive that you got nothing for a STM_SETIMAGE search so I went to the MSDN Library and did a search for -
STM_SETIMAGE

and got more than 30 hits

the MSDN page for the STM_SETIMAGE in Win32 API is -

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/staticcontrols/staticcontrolreference/staticcontrolmessages/stm_setimage.asp

and it specifically lists the   SS_BITMAP  STATIC control style

anyway I meant that you read the whole section about Static controls, at -

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/staticcontrols/staticcontrols.asp

you might read the overviews and stuff about messages and the others

the Win32 Help Files that came with delphi, may also be used, reading the stuff about controls like , , index

Button Controls

Static Controls

Scroll Bars

Dialogs

ect.

. . . . . . . . . .

can give you very helpful info for API
0
 
GroundFloorAuthor Commented:
Yep, the problem was with no handle being returned - seems if i add in a # in front of the resource number it works.

What i did a search on was for SendDlgItemMessage on MSDN and got nothing more than what was in the Win32 help.

Again, thanks very much for the help and sorry to be such a pain in the a** :)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.