This is a single function - SelectScreenMode() - which allows users to select the required screen mode from those available to them using the mouse.
Drop it into your program and call it with:
DisplayMode$=SelectScreenMode()
On exit from the function, the screen mode is already set and DisplayMode$ will contain the string returned from the perform checklist command (Eg: 800x600x32) which can be ignored if you have no use for it.
You could also put the function into it's own .DBA file and call it as a #Include file.
The following code is a 'paste into DBC and run' demo - just copy and paste the function itself into your own projects if it's of any use to you.
Rem ***** Display Mode Selector Function Demo *****
Rem ***** By TDK_Man December 2006 *****
Set Display Mode 800,600,16: Rem <<< Set whatever mode you want here
DisplayMode$=SelectScreenMode(): Rem <<< This calls the function. On return the new mode is already set
Center Text Screen Width()/2,Screen Height()/2, "Now In Screen Mode "+DisplayMode$: Rem <<< Selected screen mode returned in string (Eg 800x600x32)
Wait Key
End
Function SelectScreenMode()
Set Text Font "Arial": Set Text Size 14
Perform Checklist For Display Modes
ListNum = Checklist Quantity()
TRows = ListNum/4: TColumns = 4: THeight = Text Height("X")
BoxHeight = THeight*TRows+40: BoxWidth = TColumns*90
X=(Screen Width() - BoxWidth)/2: Y=(Screen Height() - BoxHeight)/2
Ink RGB(255,255,255),0: Box X,Y,X+BoxWidth,Y+BoxHeight
Ink RGB(180,180,180),0: Box X+1,Y+1,X+BoxWidth,Y+BoxHeight
Ink RGB(220,220,220),0: Box X+1,Y+1,X+BoxWidth-1,Y+BoxHeight-1
Ink RGB(255,255,255),0: Center Text Screen Width() / 2,Y+5,"Please Select The Required Screen Mode:"
Ink 0,0: Center Text Screen Width() / 2-1,Y+4,"Please Select The Required Screen Mode:"
TextLPos = X+10: TextTPos = Y+30: RowCount=0: Ink 0,0
For N=1 To ListNum
Text TextLPos,TextTPos,CHECKLIST STRING$(N)
Inc TextTPos,THeight: Inc RowCount
If RowCount = TRows
RowCount=0: TextTPos = Y+30
Inc TextLPos,90
Endif
Next N
Get Image 10000,X,Y,X+BoxWidth,Y+BoxHeight
Ink RGB(120,120,220),0: Set Text Transparent
Repeat
Mx=MouseX(): My=MouseY(): Mc=MouseClick()
If Mx>(X+10) and Mx<(X+BoxWidth-10) and My>(Y+10) and My<(Y+BoxHeight-10)
OverColumn = (Mx-(X+10))/90: OverRow = (My-(Y+30))/THeight
ItemNum = OverColumn*10+OverRow+1
If OldItemNum <> ItemNum
Paste Image 10000,X,Y
Text OverColumn*90+X+10,OverRow*THeight+30+Y,CHECKLIST STRING$(ItemNum)
OldItemNum = ItemNum
Endif
Endif
Until Mc=1
Mode$ = CHECKLIST STRING$(ItemNum)
Delete Image 10000
BitDepth = VAL(Right$(Mode$,2))
NewMode$=Left$(Mode$,Len(Mode$)-3)
For N=1 To Len(Mode$)
If Mid$(NewMode$,N)="x"
XRez = VAL(Left$(NewMode$,N-1))
YRez = VAL(Right$(NewMode$,Len(NewMode$)-N))
Exit
Endif
Next N
Set Display Mode XRez, YRez, BitDepth
Ink RGB(255,255,255),0
EndFunction Mode$
TDK_Man