This might be outside the realm of Creative basic programing, but is it possible to change the screen size when displaying graphics without relying on DirectXT, simaler to using the CREATESCREEN command.
Not knowing too much about DirectXT I would appreciate any help on this subject.
Hi...
Do you mean something like this:
'GUI SetWindowSAize in Creative Basic
DEF win:WINDOW
DEF l,t,w,h:int
WINDOW win,0,0,640,480,@minbox,0,"Set Window Size",main
SETWINDOWCOLOR win,rgb(150,150,150)
CONTROL win,"B,Smaller,20,20,50,22,0x50000000,1"
SETFONT win,"Microsoft Sans Serif",8, 400,0,1
CONTROL win,"B,Bigger,20,50,50,22,0x50000000,2"
SETFONT win,"Microsoft Sans Serif",8, 400,0,2
run=1
WAITUNTIL run=0
CLOSEWINDOW win
END
SUB main
SELECT @CLASS
CASE @IDCLOSEWINDOW
run=0
CASE @IDCONTROL
IF @CONTROLID=1
Smaller()
ENDIF
IF @CONTROLID=2
Bigger()
ENDIF
ENDSELECT
RETURN
SUB Smaller
w=300
h=300
SETSIZE win, 0, 0, w, h
RETURN
SUB Bigger
w=600
h=400
SETSIZE win, 0, 0, w, h
RETURN
Just one idea - press button Close :)
'GUI SetWindowSAize in Creative Basic
DEF win:WINDOW
DEF l,t,w,h:int
WINDOW win,0,0,640,480,@minbox,0,"Set Window Size",main
SETWINDOWCOLOR win,rgb(150,150,150)
CONTROL win,"B,Smaller,10,10,50,22,0x50000000,1"
SETFONT win,"Microsoft Sans Serif",8, 400,0,1
CONTROL win,"B,Bigger,10,34,50,22,0x50000000,2"
SETFONT win,"Microsoft Sans Serif",8, 400,0,2
CONTROL win,"B,Close,300,240,50,22,0x50000000,3"
SETFONT win,"Microsoft Sans Serif",8, 400,0,3
run=1
WAITUNTIL run=0
CLOSEWINDOW win
END
SUB main
SELECT @CLASS
CASE @IDCLOSEWINDOW
run=0
CASE @IDCONTROL
IF @CONTROLID=1
Smaller()
ENDIF
IF @CONTROLID=2
Bigger()
ENDIF
IF @CONTROLID=3
CloseW()
ENDIF
ENDSELECT
RETURN
SUB Smaller
w=300
h=300
SETSIZE win, 0, 0, w, h
RETURN
SUB Bigger
w=600
h=400
SETSIZE win, 0, 0, w, h
RETURN
SUB CloseW
w=500
h=500
SETSIZE win, 0, 0, w, h
FOR w=500 to 100 step -1
h=h-1
SETSIZE win, 0, 0, w, h
Next w
'add this for close window
'run=0
RETURN
Thanks for the above info, I’m kind of looking for some Creative basic code that will adjust the
monitor screen resolution (not a window) similar to the CREATESCREEN(win,800,600,32)
command but without relying on DirectX.
I realy dont know way without using DX but maby with API :-\
This example changes the graphic mode to 640x480 without DirectX:)
declare "user32", EnumDisplaySettingsA(lpszDeviceName:pointer,iModeNum:int,lpDevMode:memory),int
declare "user32", ChangeDisplaySettingsA(lpDevMode:memory, dwflags:int),int
const CCHDEVICENAME = 32
const ENUM_CURRENT_SETTINGS = -1
type DEVMODE,2
def dmDeviceName[CCHDEVICENAME]:char
def dmSpecVersion:word
def dmDriverVersion:word
def dmSize:word
def dmDriverExtra:word
def dmFields:int
def reserved[16]:int
def dmPelsWidth:int
def dmPelsHeight:int
def reserved2:int
def dmDisplayFrequency:int
endtype
def lpDevMode:memory
def dmCurrent:DEVMODE
def dmNew:DEVMODE
def NULL:pointer
allocmem(lpDevMode, 1, len(dmCurrent))
dmCurrent.dmSize = len(dmCurrent)
writemem lpDevMode, 1, dmCurrent
' get the current settings
EnumDisplaySettingsA(NULL, ENUM_CURRENT_SETTINGS, lpDevMode)
readmem lpDevMode, 1, dmCurrent
readmem lpDevMode, 1, dmNew
messagebox 0, using("#x#", dmCurrent.dmPelsWidth, dmCurrent.dmPelsHeight), "current display mode"
dmNew.dmPelsWidth = 640
dmNew.dmPelsHeight = 480
writemem lpDevMode, 1, dmNew
if (ChangeDisplaySettingsA(lpDevMode, 0) = 0)
messagebox 0, using("changed to #x#", dmNew.dmPelsWidth, dmNew.dmPelsHeight), ""
writemem lpDevMode, 1, dmCurrent
ChangeDisplaySettingsA(lpDevMode, 0)
else
messagebox 0, using("failed to switch to #x#", dmNew.dmPelsWidth, dmNew.dmPelsHeight), ""
endif
freemem lpDevMode
Thank you for the screen switching code, It works perfectly. Could I have your permission to include
this code within a program I would like to submit to the Creative basic forum ?
Yes, why do you ask ;D