Posts: 763
Threads: 261
Joined: Jul 2012
How can I change the image within a bitmap static control
For example I have this:
...
36 Static 0x5400000E 0x0 16 40 12 14 ""
...
Which is a static bitmap.
How can I change the bitmap within it? (AND is the same method also usable to clear it?)
The closest topic about this:
Change bitmap
But I could not construct the correct syntax.
Posts: 12,072
Threads: 140
Joined: Dec 2002
Search for STM_SETIMAGE.
Or draw directly on dialog, don't use a Static control.
Posts: 763
Threads: 261
Joined: Jul 2012
Oh, I thought the static was also used for this purpose because when you are in the dialog editor under "Static" (in the leftside where you can select the various dialog controls such as inputfields) you see "Bitmap".
But I'll keep STM_SETIMAGE in mind!
Thank you!
Posts: 1,336
Threads: 61
Joined: Jul 2006
something like this should be what your after
Function
Dialog2
\Dialog_Editor
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 224 136 "Dialog"
;3 Static 0x5400000E 0x0 40 40 16 16 ""
;4 Button 0x54032000 0x0 112 40 48 14 "Button" "Click to change image"
;1 Button 0x54030001 0x4 116 116 48 14 "OK"
;2 Button 0x54030000 0x4 168 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040202 "*" "" "" ""
str controls = "3"
str sb3
if(!ShowDialog(dd &sub.DlgProc &controls)) ret
#sub DlgProc
function# hDlg message wParam lParam
sel message
,case WM_INITDIALOG
,int- _hbb=LoadPictureFile("image location");;change to first image location
,SendMessage id(3 hDlg) STM_SETIMAGE IMAGE_BITMAP _hbb
,__GdiHandle-- _hbb1=SendMessage(id(3 hDlg) STM_GETIMAGE IMAGE_BITMAP 0); if(_hbb1!=_hbb) DeleteObject(_hbb)
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
,case 4 ;;Button
,_hbb=LoadPictureFile("image location");;change to new image location
,SendMessage id(3 hDlg) STM_SETIMAGE IMAGE_BITMAP _hbb
,_hbb1.Delete
,_hbb1=SendMessage(id(3 hDlg) STM_GETIMAGE IMAGE_BITMAP 0); if(_hbb1!=_hbb) DeleteObject(_hbb)
,InvalidateRect hDlg 0 1
ret 1
Posts: 12,072
Threads: 140
Joined: Dec 2002
Need _hbb1.Delete before the second _hbb1=....
Posts: 1,336
Threads: 61
Joined: Jul 2006
oops :oops: yes thank you forgot that ...corrected above post
Posts: 763
Threads: 261
Joined: Jul 2012
Posts: 12,072
Threads: 140
Joined: Dec 2002