IonicWind Software

IWBasic => GUI Central => Topic started by: pistol350 on April 07, 2008, 06:45:29 AM

Title: How to display Jpg images in a dialog
Post by: pistol350 on April 07, 2008, 06:45:29 AM
Hi all!
As said above, my wish is to display a Jpg image in a Dialog.
At first i thought doing it the same way as for a Window would work,
but using loadimage and showimage does not do the trick.

I know that i can display bmp images in a dialog using a @Static flag for my control and that works for me.
By the way, is there another simple way to do it?

thanks.

Title: Re: How to display Jpg images in a dialog
Post by: Ionic Wind Support Team on April 07, 2008, 08:05:25 AM
open a captionless window as a child of the dialog the size of the image, and display the image in there.
Title: Re: How to display Jpg images in a dialog
Post by: pistol350 on April 07, 2008, 10:20:53 AM
I'll try it.
thanks.
Title: Re: How to display Jpg images in a dialog
Post by: pistol350 on April 07, 2008, 10:32:28 AM
What is my option if i want to use the jpg image as the background of my Dialog ?
Title: Re: How to display Jpg images in a dialog
Post by: Ionic Wind Support Team on April 07, 2008, 11:12:46 AM
Make the child window as big as the client area of the dialog.

Paul.
Title: Re: How to display Jpg images in a dialog
Post by: pistol350 on April 07, 2008, 12:19:50 PM
I'm doing something wrong but i can't find what it is.
Any suggestions ?



CONST BUTTON_1 = 1

DIALOG d1
WINDOW w1
uint backimage
int run

'create main dialog and child windw
CREATEDIALOG d1,0,0,640,480,0x80CB0080,0,"my main dialog",&d1_handler
OPENWINDOW w1,0,0,640,480,@NOCAPTION,d1,"Simple child Window",&w1_handler

CONTROL d1,@BUTTON,"Button1",285,230,70,20,0x50000000,BUTTON_1

'load Jpg image
backimage = LOADIMAGE(GETSTARTPATH + "background.jpg", @IMGSCALABLE)

showdialog d1

SHOWIMAGE(w1,backimage,@IMGSCALABLE,0,0,640,480)

run = 1
WAITUNTIL run = 0
deleteimage backimage,@IMGSCALABLE
CLOSEWINDOW w1
END

SUB w1_handler
    IF @MESSAGE = @IDCLOSEWINDOW
        run=0
    ENDIF
RETURN
ENDSUB

'__________________________________________________

SUB d1_handler
SELECT @MESSAGE
CASE @IDINITDIALOG
CENTERWINDOW d1
CENTERWINDOW w1
/* Initialize any controls here */
CASE @IDCLOSEWINDOW
run=0
CLOSEDIALOG d1,@IDOK

CASE @IDCONTROL
SELECT @CONTROLID
CASE BUTTON_1
IF @NOTIFYCODE = 0
/*button clicked*/
ENDIF
ENDSELECT
ENDSELECT
RETURN
ENDSUB

Title: Re: How to display Jpg images in a dialog
Post by: LarryMc on April 07, 2008, 01:21:45 PM
try this version of your program:
CONST BUTTON_1 = 1

DIALOG d1
WINDOW w1
uint backimage
int run

'create main dialog and child windw
CREATEDIALOG d1,0,0,640,480,0x80CB0080,0,"my main dialog",&d1_handler
cONTROL d1,@BUTTON,"Button1",285,230,70,20,0x50000000,BUTTON_1

'load Jpg image
backimage = LOADIMAGE(GETSTARTPATH + "background.jpg", @IMGSCALABLE)

showdialog d1



run = 1
WAITUNTIL run = 0
deleteimage backimage,@IMGSCALABLE
CLOSEWINDOW w1
END

SUB w1_handler
    IF @MESSAGE = @IDCLOSEWINDOW
        run=0
    ENDIF
RETURN
ENDSUB

'__________________________________________________

SUB d1_handler
SELECT @MESSAGE
CASE @IDINITDIALOG
CENTERWINDOW d1
OPENWINDOW w1,0,0,640,480,@nocaption,d1,"Simple child Window",&w1_handler
CENTERWINDOW w1
SHOWIMAGE(w1,backimage,@IMGSCALABLE,0,0,640,480)
/* Initialize any controls here */
CASE @IDCLOSEWINDOW
run=0
CLOSEDIALOG d1,@IDOK

CASE @IDCONTROL
SELECT @CONTROLID
CASE BUTTON_1
IF @NOTIFYCODE = 0
/*button clicked*/
ENDIF
ENDSELECT
ENDSELECT
RETURN
ENDSUB



Dialogs are funny.  There are a lot of things that have to be done in the initdialog that won't get done at all if you put them in the "regular" place like windows.

Larry
Title: Re: How to display Jpg images in a dialog
Post by: pistol350 on April 07, 2008, 01:43:47 PM
OK!!!
I did not know that things had to be done that way to get the expected result.
Indeed, dialogs are very funny. :)

Thank you Larry!
Title: Re: How to display Jpg images in a dialog
Post by: LarryMc on April 07, 2008, 01:55:33 PM
remember that when you want to change the font or colors or text or use a "sendmessage" function of a control when using dialogs.

Paul told me that controls do not actually exist when using a dialog until idinitdialog.  So if you try to do anything to them before that it won't happen.  I guess, based upon your program, that what we call "windows" when it is a child of a dialog has to obey the same rules as controls since all controls are really windows.

Larry