Sample how to center the window

Started by blostec, April 02, 2009, 02:00:38 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

blostec


Hi, I make a sample for center the window in the desktop. This is the code. Also I leave the example attached.

[code language="bennu"]
//Sample how to center the window on the screen
//compiled with r34

PROGRAM Center;

import "mod_key.dll";
import "mod_video.dll";
import "mod_proc.dll";
import "mod_map.dll";
import "mod_text.dll";
import "mod_screen.dll";
import "mod_wm.dll";

//******************************************************************

GLOBAL

pantalla_x = 320;      //screen mode x
pantalla_y = 200;      //screen mode y
colores = 16;          //color 8, 16, 32 bits
alto, ancho;           //to keep resolution screen
ventana_x, ventana_y;  //to keep windows size


//******************************************************************

BEGIN

set_mode(pantalla_x, pantalla_y, colores);

//get resolution screen
get_desktop_size(&ancho, &alto);

//get windows size and screen mode 
get_window_size(&ventana_x, &ventana_y, &pantalla_x, &pantalla_y);                         

                         
//center the window
set_window_pos((ancho/2)-(ventana_x/2), (alto/2)-(ventana_y/2));     

load_fpg("centrar.fpg");
put_screen(0,1);

write(0,60,165,3,"Press ALT and ENTER to change");
write(0,60,175,3,"between fullscreen or window");
write(0,60,190,3,"Press ESC to exit.");

while (!(key(_esc)))
      //to change at fullscreen or window view
      if  ((key(_ALT))  and (key(_ENTER))) 
           full_screen = not full_screen;
           set_mode(pantalla_x, pantalla_y, colores);
     end
     frame;
end

let_me_alone();

END

//********************************EOF*******************************

[/code]

SplinterGU

Download Lastest BennuGD Release: http://www.bennugd.org/node/2