Below you will find a simple skeleton program using a dialog. I have found that setwindowcolor will not change the color of a dialog. If color is wanted, is it easier to use a window instead and make it behave like a dialog.
'Demonstrating how easy it is to create a window in Creative Basic
' also includes a Text Box control to display some text ..
def d1:dialog
def d,style,x1:int
def a$,newline:string
dstyle = @caption|@sysMenu
newline = chr$(10)
'--------------------------Dialog Controls--------------------
DIALOG d1,0,0,320,575,0x80C80080,0,"Options",OptionsPage
'
CONTROL d1,"C,Group,36,369,260,140,0x50000007,9"
CONTROL d1,"E,Edit1,59,407,70,20,0x50800000,10"
CONTROL d1,"T,Static,55,503,70,20,0x5000010B,11"
CONTROL d1,"E,Edit2,56,467,70,20,0x50800000,12"
CONTROL d1,"T,Width,140,408,70,20,0x5000010B,13"
CONTROL d1,"T,Height,137,474,70,20,0x5000010B,14"
CONTROL d1,"B,Reset,206,447,70,20,0x50000000,15"
CONTROL d1,"B,OK,127,530,70,35,0x50000000,16"
CONTROL d1,"C,OutLine On,50,35,150,30,0x50000003,17"
CONTROL d1,"C,Links On,50,85,150,35,0x50000003,18"
CONTROL d1,"C,Graphing Numbers On,50,135,160,35,0x50000003,19"
CONTROL d1,"C,Snap to Grid,50,185,150,35,0x50000003,20"
CONTROL d1,"C,Image Resize On,50,235,150,35,0x50000003,21"
CONTROL d1,"C,Save as Bmp,50,285,150,35,0x50000003,22"
CONTROL d1,"C,Maintain Aspect Ratio,50,335,160,35,0x50000003,23"
'--------------------------End Page Controls
result = domodal d1
END
SUB OptionsPage
SELECT @CLASS
CASE @IDCONTROL
SELECT @CONTROLID
CASE 9
answer = GETCONTROLTEXT(d1, 2)
CLOSEDIALOG d1,@IDOK
case 10
case 11
case 12
case 13
case 14
case 15
case 16
case 17
case 18
case 19
case 20
case 21
case 22
case 23
ENDSELECT
'All controls should be initialized while processing the @IDINITDIALOG message
CASE @IDINITDIALOG
setfont d1,"Comic Ms Sans", 14, 700, @SFITALIC,9
for x1= 16 to 23
setfont d1,"Comic Ms Sans", 10, 700, @SFITALIC,x1
next x1
' SetWindowColor d1,rgb(0,0,40)
CENTERWINDOW d1
SETCONTROLTEXT d1,12,"Yipee!"
ENDSELECT
RETURN
CLOSEdialog d1
endif
return
Thanks
Texas Pete
If there are any other blatant errors, comments would be appreciated. Also note that " @IDINITDIALOG". All Text changes will not appear until after that message.
is recieve from the system.
You can add a child window to the dialog that is the size of the dialog client area and color that window.
It will look like the dialog is colored.
Larry
Thanks Larry, I was thinking something along those lines. That what I had to do in Lb.
I dont get it what is the point of your example ???
Of course you can use dialog as base of your program and then put window inside dialog as child.
From my point of view I almost never use dialogs in my programs.
becose i dont see any advantages of use dialogs instead of windows.
QuoteI almost never use dialogs in my programs.
Same here. Very rarely do I use a dialog. But thats just personal preference. There are certain things to remember, such as common controls are actually designed for dialogs, and not windows, even though they do work in both, however in some cases, certain controls will not redraw themselves properly in a window, and have to be repainted manually.
Ditto .. I can't remember using a dialog, I always use windows .. :)
But ZD .. you mention some controls won't re-draw properly in a window .. can you remember which?
I can't recall ocming across any problems myself ..
all the best, :)
Graham
IN EB @Group boxes don't refresh properly in a window.
Don't know if that's true in CB or not.
Larry
Ah. now I know what you're referring to - it's easy to correct .. :)
Here's an example test program ..
def w:WINDOW
def wstyle:int
def a:string
wstyle = @SIZE|@MINBOX|@MAXBOX
openwindow w,50,50,800,600,wstyle,0,"Window Title",&main
SETWINDOWCOLOR w,RGB(0,0,40)
control w,@button,"Exit",600, 500, 80, 40, 0, 1
'control w,@static,"",6,20,450,500,0,2
control w,@groupbox,"Panel",6,20,450,500,0x50000007,3
'Microsoft turns off the 'bits' under a group box so other controls can show through.
'With a dialog this is not usually a problem but since IBasic 'cookie' cuts controls
'onto a window so you can't draw over them accidentally (called clipping) you get what your seeing.
'The solution is to create a static control the same size as the group box with no text in it.
'Make sure its created before the groupbox and you won't have any sticky remnents.
'This method also allows you to color match the area under the box to the color of the window.
' Paul ====
WAITUNTIL w = 0
END
SUB main
SELECT @CLASS
case @IDCLOSEWINDOW
closewindow w
' clicking the Exit button ...
case @IDCONTROL
select @CONTROLID
case 1
closewindow w
endselect
endselect
RETURN
endsub
With the static control commented out, if you run the program and then open Wordpad on top of it - nasty things happen.
If you enable the static text box, all is well.
Note Paul's comments inside the test program.
Yes, that happens in CB as well - it's a long-standing problem.
all the best, :)
Graham
Edit: Oops what am I doing, we're in the Creative section and that example was for EB .. ::) It's young Larry's fault for mentioning EB .. :)
No problem, here's the Creative version ..
def w:WINDOW
def wstyle:int
def a:string
wstyle = @SIZE|@MINBOX|@MAXBOX
WINDOW w,50,50,800,600,wstyle,0,"Window Title",main
SETWINDOWCOLOR w,RGB(0,0,40)
control w,"B,Exit,600, 500, 80, 40, 0, 1"
control w,"T,,6,20,450,500,0,2"
control w,"C,Panel,6,20,450,500,0x50000007,3"
WAITUNTIL w = 0
END
SUB main
SELECT @CLASS
case @IDCLOSEWINDOW
closewindow w
' clicking the Exit button ...
case @IDCONTROL
select @CONTROLID
case 1
closewindow w
endselect
endselect
RETURN
Graham ,
Thank you all.
Big Help
Texas Pete