minimize-maximize-close window in fbgfx.bi

New to FreeBASIC? Post your questions here.
Post Reply
N3trunn3r
Posts: 110
Joined: Feb 14, 2008 15:48

minimize-maximize-close window in fbgfx.bi

Post by N3trunn3r »

When I for example init a screen with screen 18,
I will get a normal minimize-maximize-close window.
How do I access what happens when I click on for example close or maximize, without using WinAPI?
fxm
Moderator
Posts: 12145
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Post by fxm »

Some ideas to detect the graphic window state:

Testing the current window position (x, y), in desktop coordinates, you can detect:
- the minimize window state (x=-32000, y=-32000).
- the maximize window state (always x=0, y=0), but it is not a test absolutely sure, because the position (0, 0) can exist for a normal window.

- Testing the screenptr value, you can detect the closing window state (screenptr=0)


Test program which monitors on console window the parameters (x, y, screenptr) of the graphic window:
- click on 'x' to close the graphic window
- enter 'escape' to exit

Code: Select all

screen 18

dim as integer x, y
dim as string c

do
  screencontrol(0, x, y)
  shell("echo." + str(x) + ", " + str(y) + ", " + str(screenptr))
  c = inkey
  if c = chr(255) + "k" then
    screen 0
  end if
  sleep 1000
loop until c = chr(27)
N3trunn3r
Posts: 110
Joined: Feb 14, 2008 15:48

Post by N3trunn3r »

What has chr(255) + "k" to do with clicking on the "X" / close button?
How are they related?
fxm
Moderator
Posts: 12145
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Post by fxm »

N3trunn3r wrote:What has chr(255) + "k" to do with clicking on the "X" / close button?
How are they related?
Extract of the FreeBASIC manual, keyword "Screen (Graphics)", paragraph "Other details":
While in windowed mode, clicking on the window close button will add a keypress of Chr(255)&"k" to the Inkey buffer.

For a graphic window only, clicking the "X" / close button has no other effect than to simulate receiving of this string.
N3trunn3r
Posts: 110
Joined: Feb 14, 2008 15:48

Post by N3trunn3r »

aww and I just read the help page on screenres not screen X)
Thanks!!
greenllll
Posts: 57
Joined: Jul 02, 2007 19:33

Re: minimize-maximize-close window in fbgfx.bi

Post by greenllll »

Thanks Thanks Thanks. Screen 0, and The X close window keyboard trick worked perfectly. Big help.
Post Reply