Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
change image in bitmap static control
#1
How can I change the image within a bitmap static control

For example I have this:
Code:
Copy      Help
...
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.
#2
Search for STM_SETIMAGE.

Or draw directly on dialog, don't use a Static control.
#3
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!
#4
something like this should be what your after
Function Dialog2
Code:
Copy      Help
\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
#5
Need _hbb1.Delete before the second _hbb1=....
#6
oops :oops: yes thank you forgot that ...corrected above post
#7
Thank you both for this!
#8
See also: Set/Change Dialog Image


Forum Jump:


Users browsing this thread: 1 Guest(s)