May 09, 2024, 02:13:43 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


How to test if a screen is created using a function ?

Started by pistol350, November 08, 2007, 07:35:08 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

pistol350

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
Regards,

Peter B.

Ionic Wind Support Team

CreateScreen returns < 0 on failure.  Use it as a function

if CreateScreen(width,height,bitdepth) = 0
     'screen created
else
...
Ionic Wind Support Team

pistol350

Thanks Paul.
Such an easy solution.
Why on earth do i search for a far more difficult one  ???

Regards,
Peter
Regards,

Peter B.