PDA

View Full Version : (800*600 and 16 bit) what is the code .



orwa
20-10-2003, 04:44 PM
hi
what is the code to :
change the screen mode (to 800*600 ).
and change the color depth (to 16 bit) ,.

thanks for help ..

tux
20-10-2003, 06:19 PM
this is taken directly from my game so im not sure if its any use for you.


to change the screen res....


var
dmScreenSettings : DEVMODE;

...

if Fullscreen then
begin
ZeroMemory(@dmScreenSettings, SizeOf(dmScreenSettings));
with dmScreenSettings do begin
dmSize := SizeOf(dmScreenSettings);
dmPelsWidth := Width;
dmPelsHeight := Height;
dmBitsPerPel := PixelDepth;
dmFields := DM_PELSWIDTH or DM_PELSHEIGHT or DM_BITSPERPEL;
end;


if (ChangeDisplaySettings(dmScreenSettings, CDS_FULLSCREEN) = DISP_CHANGE_FAILED) then
begin
MessageBox(0, 'Unable to switch to fullscreen!', 'Error', MB_OK or MB_ICONERROR);
Fullscreen := False;
end;
end;

and to set it back...


if Fullscreen then
begin
ChangeDisplaySettings(devmode(nil^), 0);
ShowCursor(True);
end;


hope it helps :)

orwa
23-10-2003, 09:55 AM
thanks alot DumasS , i think it can be usefull .

and thats another code :

procedure TForm1.setscreen(width,hight,deep:integer);

Var OldVal: _devicemodeA;
index:integer;
Begin
index:=1;
While EnumDisplaySettings(nil, i, OldVal) do
begin

if OldVal.dmPelsWidth=width then
if OldVal.dmPelsHeight=hight then
if OldVal.dmBitsPerPel = deep then begin
If EnumDisplaySettings(nil, i, OldVal) Then
ChangeDisplaySettings( OldVal, 0);
break;
end;
I:= I+1;
end;
end;