Software Archive
Read-only legacy content
17061 Discussions

Displaying Image in Dialog Box

Intel_C_Intel
Employee
497 Views
Hi,

I am learning Quick Win and am trying to display a Text and Image using the following commands:

retlog = DlgSet(dig, DC_EDIT1, Test' )
retlog = DlgSet(dig, DC_STATIC1, IDB_BITMAP2)

The text works fine, but not the static image. I thought of trying DLGSENDCTRLMESSAGE, but not sure what T_MSG in documentation refers to:

retint = DLGSENDCTRLMESSAGE (dlg, IDC_STATIC1, T_MSG???,0,IDB_BITMAP2)

I would appreciate any help on this.

Thanks
Rajesh
0 Kudos
3 Replies
Jugoslav_Dujic
Valued Contributor II
497 Views
Hi Rajesh,
The message you're looking for is STM_SETIMAGE, with arguments IMAGE_BITMAP and hImage; hImage, however, is Windows handle of the bitmap. You can load a bitmap from resource
using
 
USE DFWIN 
... 
hImage=LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_BITMAP2)) 


However, this makes sense only if you want to change the bitmap at run-time; you can add a bitmap into the dialog at design-time, from resource editor -- just add a "Picture" control from the "Controls" toolbar,
select "Type: Bitmap" in its "Properties" dialog, and then select bitmap's ID from the "Image" combo. Even if you use DlgSendCtrlMessage, the control you want to assign the bitmap must be of type "Picture" as described above.

Jugoslav
0 Kudos
Intel_C_Intel
Employee
497 Views
Jugoslav,

Thanks. Yes, I want to change the image during run time. And so I tried:

hImage=LoadBitmap(GetModuleHandle(Null), MAKEINTRESOURCE(IDB_BITMAP2))

n = DLGSENDCTRLMESSAGE(dlg,idc_static1, STM_SETIMAGE,
IMAGE_BITMAP,hImage)

n = DlgModal(dlg)

But I get a message to the effect that STM_SETIMAGE and IMAGE_BITMAP are not defined. Should I be declaring them as some type, or did I interpret your instructions incorrectly?

Thanks
Rajesh
0 Kudos
Jugoslav_Dujic
Valued Contributor II
497 Views
You did interpret them correctly; however, the "compilability" of the code depends on version of CVF you have: older versions (up to 6.0 AFAIK) don't have complete declarations in DFWIN module. Here are the correct declarations for names in question which you may include in a separate module or declare them directly in the code:


 
INTEGER,PARAMETER:: STM_SETIMAGE        =#0172 
INTEGER,PARAMETER:: STM_GETIMAGE        =#0173 
 
INTEGER,PARAMETER:: IMAGE_BITMAP            =0 
INTEGER,PARAMETER:: IMAGE_ICON              =1 
INTEGER,PARAMETER:: IMAGE_CURSOR            =2 
INTEGER,PARAMETER:: IMAGE_ENHMETAFILE       =3 
 
INTEGER,PARAMETER:: LR_DEFAULTCOLOR         =#0000 
INTEGER,PARAMETER:: LR_MONOCHROME           =#0001 
INTEGER,PARAMETER:: LR_COLOR                =#0002 
INTEGER,PARAMETER:: LR_COPYRETURNORG        =#0004 
INTEGER,PARAMETER:: LR_COPYDELETEORG        =#0008 
INTEGER,PARAMETER:: LR_LOADFROMFILE         =#0010 
INTEGER,PARAMETER:: LR_LOADTRANSPARENT      =#0020 
INTEGER,PARAMETER:: LR_DEFAULTSIZE          =#0040 
INTEGER,PARAMETER:: LR_LOADMAP3DCOLORS      =#1000 
INTEGER,PARAMETER:: LR_CREATEDIBSECTION     =#2000 
INTEGER,PARAMETER:: LR_COPYFROMRESOURCE     =#4000 
INTEGER,PARAMETER:: LR_SHARED               =#8000     
 
!DEC$OBJCOMMENT LIB: 'User32.lib'  
INTERFACE 
      INTEGER(4) FUNCTION  LoadImageA(hInst,lpszName,uType,cxDesired,    & 
                                     cyDesired,fuLoad) 
      !MS$ATTRIBUTES STDCALL, ALIAS : '_LoadImageA@24' :: LoadImageA 
      INTEGER                 hInst 
      INTEGER                 lpszName 
      INTEGER                 uType 
      INTEGER                 cxDesired 
      INTEGER                 cyDesired 
      INTEGER                 fuLoad 
      END FUNCTION LoadImageA 
END INTERFACE 
 



With declarations above, replace LoadImage with LoadImageA in the code.
(uh, it's difficult to explain why renaming is necessary).

One more note: be aware that DlgSendCtrlMessage (as far as I know) works only from callback functions (the ones you register with DlgSetSub);
it won't work in the same routine where you call DlgInit...DlgModal. If you
want to set the bitmap initially in the dialog, make a dialog "startup" routine, in the following way:


 
iSt=DlgInit(... 
iSt=DlgSetSub(Dlg, IDD_DIALOG_1, OnDlgInit) 
... 
 
SUBROUTINE OnDlgInit(Dlg, ID, iAction) 
... 
iSt=DlgSendCtrlMessage(... 
 
END SUBROUTINE 



Regards

Jugoslav
0 Kudos
Reply