' gbox.cba- Egil ' Converted to IWB - Brian AUTODEFINE "off" $include "windowssdk.inc" window win UINT hDC INT textwidth,textheight OPENWINDOW win,0,0,640,480,@MINBOX|@MAXBOX|@SIZE,0,"GBOX Demo",&main drawmode win,@TRANSPARENT setwindowcolor win,rgb(100,250,250) SETFONT win,"Comic Sans MS",12,500,0 gbox(25,30,175,100,96,192,240," gbox1 ",255,255,128) gbox(210,150,175,60,192,192,240," gbox2 ",255,128,128) gbox(250,30,175,30,148,201,201," gbox3 ",204,204,152) SETFONT win,"Comic Sans MS",24,700,@SFITALIC gbox(50,260,475,150,255,222,186," IWB rules ",196,255,0) waituntil ISWINDOWCLOSED(win) closewindow win end SUB main(),INT select @MESSAGE Case @IDCREATE CenterWindow win case @idclosewindow CLOSEWINDOW win endselect RETURN 0 ENDSUB '-------------------------------------------------------------------------- ' Draw coloured box with rounded corners ' Adds self-dimensioning text labels with border if label text is supplied ' ' Parameters: ' x, y: Upper left corner of rounded box ' h: Box height ' w: Box with ' br: Box RED value ' bg: Box GREEN value ' bb: Box BLUE value ' msg$: Label text string - use "" if no label ' lr: Label RED value for label ' lg: Label GREEN value ' lb: Label BLUE value ' ' Note: To change radius of the rounded corners, change the values of ' of the last two parameters in the RoundRect call to suit your needs '-------------------------------------------------------------------------- SUB gbox(x:INT,y:INT,w:INT,h:INT,br:INT,bg:INT,bb:INT,msg$:STRING,lr:INT,lg:INT,lb:INT) hDC=GetHDC(win) RoundRect(hDC,x,y,x+w,y+h,9,9) ' draw rounded box FLOODFILL win,x+(w/2),y+(h/2),RGB(br,bg,bb) ' background colour if msg$<>"" ' text label exists? GETTEXTSIZE win,msg$,textwidth,textheight ' label dimensions RoundRect(hDC,x+12,y-(textheight/2),(x+12+(textwidth)),y+(textheight/2)+2,5,7) ' draw label border FLOODFILL win,x+12+(textwidth/2),y,RGB(lr,lg,lb) ' text label background colour move win,x+12,y-(textheight/2) ' positioning text label print win,msg$ ' printing text label endif RELEASEHDC(win,hDC) ENDSUB