IonicWind Software

IWBasic => General Questions => Topic started by: TGN on September 14, 2012, 12:47:34 AM

Title: Graphics in a dialogue group box
Post by: TGN on September 14, 2012, 12:47:34 AM
How can you display graphics in a dialogue group box  ???
like the CPU Usage History in Task Manager


Thanks
Torben
Title: Re: Graphics in a dialogue group box
Post by: LarryMc on September 14, 2012, 10:43:07 AM
Well, just as a @GROUPBOX doesn't work correctly in a window (bleed-through) it also appears that in a dialog you can't stick a child window inside a groupbox(the window is over written)
The easiest thing that I could come up with was to create a child window and use the RECT command to draw my own groupbox box and I added a @STATIC text to the dialog for a groupbox title(it automatically overwrites and appears on top)
I then displayed my scaled image inside the child window allowing for spacing for the rect and the text.

I used GetSysColor to get the dialog color for the STATIC background and the color of the child window.

Now, there probably is a more sophisticated way to do it but this is the best i can do.

Hope this helps a little.
The zip contains the sorce code and the image to create the dialog displayed below.
Title: Re: Graphics in a dialogue group box
Post by: LarryMc on September 14, 2012, 06:13:15 PM
I decided to play with it some more.
This is a modified version (of the one above) which forces the window to the top of the dialogs Z-order.
It uses the @GROUPBOX control.
It's a little easier to set up.
It uses the image that is in the above zip.

DECLARE extern GetSysColor(nIndex:INT),INT
DECLARE extern SetWindowPos(hwnd:INT, hWndInsertAfter:INT, x:INT, y:INT, cx:INT, cy:INT, wFlags:INT),INT
CONST SWP_NOMOVE = 0x2
CONST SWP_NOSIZE = 0x1
const COLOR_3DFACE =15

DIALOG d1
WINDOW w1
uint backimage

'create main dialog and child windw
CREATEDIALOG d1,0,0,400,300,0x80CB0080,0,"my main dialog",&d1_handler
CONTROL d1,@BUTTON,"Button1",285,230,70,20,0x50000000,1
CONTROL d1,@groupbox,"Example",10,10,200,200,0x50000000,2
'load Jpg image
backimage = LOADIMAGE(GETSTARTPATH + "d28.jpg", @IMGSCALABLE)

showdialog d1

WAITUNTIL iswindowclosed(d1)

END

SUB w1_handler(),int
SELECT @MESSAGE
CASE @IDCLOSEWINDOW
closewindow w1
CASE @IDCREATE
setwindowcolor w1,GetSysColor(COLOR_3DFACE)
ENDSELECT
RETURN 0
ENDSUB

'__________________________________________________

SUB d1_handler(),int
int x, y, cx, cy
int wFlags=SWP_NOMOVE|SWP_NOSIZE

SELECT @MESSAGE
CASE @IDINITDIALOG
CENTERWINDOW d1
OPENWINDOW w1,15,25,191,180,@nocaption,d1,"Simple child Window",&w1_handler
SetWindowPos(w1.hwnd, 0, x, y, cx, cy, wFlags)
SHOWIMAGE(w1,backimage,@IMGSCALABLE,0,0,191,180)
CASE @IDCLOSEWINDOW
deleteimage backimage,@IMGSCALABLE
CLOSEWINDOW w1
CLOSEDIALOG d1,@IDOK
CASE @IDCONTROL
SELECT @CONTROLID
CASE 1
IF @NOTIFYCODE = 0
deleteimage backimage,@IMGSCALABLE
CLOSEWINDOW w1
CLOSEDIALOG d1,@IDOK
ENDIF
ENDSELECT
ENDSELECT
RETURN 0
ENDSUB



Title: Re: Graphics in a dialogue group box
Post by: TGN on September 24, 2012, 01:52:47 AM
Thanks Larry  !!