Set/Change Dialog Image

Creating macros. Working with QM.

Set/Change Dialog Image

Postby BJ on Tue Dec 05, 2017 5:01 pm

I know the basics of displaying an image in a dialog, but Is it possible to make a button in the dialog or an outside macro change the path of the specified image so that the image will change?

Function dialog_image     ?
Trigger F12     ?
;\Dialog_Editor

str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 248 152 "Set Image"
;3 Static 0x5400000E 0x0 16 16 96 96 ""
;4 Static 0x5400000E 0x4 136 16 96 96 ""
;7 Button 0x54032000 0x0 12 128 48 14 "Set 1"
;8 Button 0x54032000 0x0 68 128 48 14 "Set2"
;9 Button 0x54032000 0x0 132 128 48 14 "Set 1"
;10 Button 0x54032000 0x0 188 128 48 14 "Set2"
;5 Button 0x54020007 0x0 8 4 114 117 ""
;6 Button 0x54020007 0x0 128 4 112 117 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2040500 "*" "" "" ""

str controls = "3 4"
str sb3 sb4
sb3 = "$desktop$\img\1.png"
sb4 = "$desktop$\img\2.png"
if(!ShowDialog(dd &sub.DlgProc &controls)) ret


#sub DlgProc
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam

,case 7
,out "Change to img\2"

,case 8
,out "Change to img\1"

,case IDOK
,case IDCANCEL
ret 1

BJ
 
Posts: 21
Joined: Sat Nov 19, 2011 3:37 pm

Re: Set/Change Dialog Image

Postby BJ on Tue Dec 05, 2017 6:11 pm

Update:

I found the dlg_button_images function in the archive. Is there a way to make this work with the static bitmap that can be used in the dialog?
BJ
 
Posts: 21
Joined: Sat Nov 19, 2011 3:37 pm

Re: Set/Change Dialog Image

Postby Gintaras on Tue Dec 05, 2017 6:30 pm

Function StaticControlSetImage     ?
;/
function hwnd [$imageFile] [hbitmap]

;Displays image in a static control in a dialog.

;hwnd - static control handle.
;imageFile - image file. Can be bmp, png, gif, jpg. The function uses <help>LoadPictureFile</help>. If not used, can be "".
;hbitmap - bitmap handle. Can be used instead of imageFile. The caller can delete it immediately (this function copies it). If omitted or 0, the function uses imageFile.

;REMARKS
;If the control has style SS_REALSIZEIMAGE, resizes it to display whole image.
;Unlike STM_SETIMAGE, correctly displays alpha bitmaps.


if(hbitmap) hbitmap=CopyImage(hbitmap IMAGE_BITMAP 0 0 0)
else hbitmap=LoadPictureFile(imageFile); if(hbitmap=0) end "LoadPictureFile failed"

type __SICSB4249 __MemBmp'mb wid hei

__SICSB4249* p=+GetProp(hwnd "__SICSB4249")
if(!p) SetWindowSubclass(hwnd &sub.SubclassProc 1 p._new)

p.mb.Attach(hbitmap)

BITMAP b; GetObject p.mb.bm sizeof(BITMAP) &b
p.wid=b.bmWidth; p.hei=b.bmHeight

InvalidateRect hwnd 0 1
if(GetWinStyle(hwnd)&SS_REALSIZEIMAGE) siz p.wid p.hei hwnd


#sub SubclassProc
function# hwnd message wParam lParam uIdSubclass dwRefData

__SICSB4249* p=+dwRefData

sel message
,case WM_PAINT
,PAINTSTRUCT ps; int dc=BeginPaint(hwnd &ps)
,RECT rc; GetClientRect hwnd &rc; FillRect dc &rc GetSysColorBrush(COLOR_BTNFACE) ;;erase
,BitBlt dc 0 0 p.wid p.hei p.mb.dc 0 0 SRCCOPY ;;memory bitmap -> display
,EndPaint hwnd &ps
,ret
,
,case WM_ERASEBKGND
,ret

int R=DefSubclassProc(hwnd message wParam lParam)

sel message
,case WM_NCDESTROY
,RemoveWindowSubclass(hwnd &sub.SubclassProc uIdSubclass)
,p._delete

ret R



example
,case 7
,out "Change to img\2"
,StaticControlSetImage id(3 hDlg) "$desktop$\img\2.png"



See also: viewtopic.php?p=28660&sid=d8d8ed781d8ad426db879aeeb7bf0d2f#p28664
Gintaras
Site Admin
 
Posts: 10411
Joined: Thu Dec 19, 2002 7:36 pm
Location: Lithuania

Re: Set/Change Dialog Image

Postby BJ on Tue Dec 05, 2017 6:50 pm

Thank you very much sir! Works like a charm :D
BJ
 
Posts: 21
Joined: Sat Nov 19, 2011 3:37 pm


Return to General

Who is online

Users browsing this forum: No registered users and 2 guests