IonicWind Software

IWBasic => General Questions => Topic started by: pistol350 on November 08, 2007, 07:35:08 AM

Title: How to test if a screen is created using a function ?
Post by: pistol350 on November 08, 2007, 07:35:08 AM
Hello all!
I'm trying to write a function to test validity of displaymodes for a screen created with the CREATESCREEN() function
So far, i've got the body of my function but i don't know what to put into it .
BTW,I know that this job can be done easily without using a function, but i'd like to do it this way.

In fact i know that i have to make sure that the screen is created with the given parameters
and maybe the @message+ @idcreate constants can be useful, but how to use them properly ?
Any suggestions ?

Regards Peter B.


declare isscreenValid(width as int,height as int,bitdepth as int),int

createscreen(width,height,bitdepth)

SUB isscreenValid(width as int,height as int,bitdepth as int),int
int result
'........
RETURN result
ENDSUB


Here is an example of a case where this function can be useful.


Int width,height,bitdepth

width = 1024 : height = 768 : bitdepth = 16
if fullscreen = 1 then
createscreen(width,height,bitdepth)

if isscreenValid(width,height,bitdepth) then
createscreen(width,height,bitdepth)
else
width = 800 : height = 600 : bitdepth = 16
if isscreenValid(width,height,bitdepth) then
createscreen(width,height,bitdepth)
else
width = 640 : height = 480 : bitdepth = 16
if isscreenValid(width,height,bitdepth) then
createscreen(width,height,bitdepth)
else
messagebox 0,"The screen could not be created with any of the display modes below\n"+ _
"   1024x768x16\n"+ _
"   800x600x16\n"+ _
"   640x480x16\n\n"+ _
"Please update your display drivers.","FATAL ERROR",@mb_iconstop
end
endif
endif
endif

else
'.....
endif
Title: Re: How to test if a screen is created using a function ?
Post by: Ionic Wind Support Team on November 08, 2007, 07:38:55 AM
CreateScreen returns < 0 on failure.  Use it as a function

if CreateScreen(width,height,bitdepth) = 0
     'screen created
else
...
Title: Re: How to test if a screen is created using a function ?
Post by: pistol350 on November 09, 2007, 02:16:54 AM
Thanks Paul.
Such an easy solution.
Why on earth do i search for a far more difficult one  ???

Regards,
Peter