It is currently Mon Jan 27, 2020 11:22 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: [Win] WindowedScreen maximized and back
PostPosted: Sat Feb 20, 2010 12:45 am 
Offline
Addict
Addict
User avatar

Joined: Sun Mar 19, 2006 1:57 pm
Posts: 4828
Location: Germany
I messed around with the API a bit, to find out how to switch the frame and caption of a window on and off,
in order to be able to maximize a WindowedScreen fullscreen like, but have the caption on the window to be able to move it.

it works via SetWindowLongPtr and setting the styleflags
#WS_CLIPSIBLINGS | #WS_VISIBLE | #WS_CAPTION | #WS_SYSMENU for standard window and
#WS_CLIPSIBLINGS | #WS_VISIBLE | #WS_POPUP for the borderless window.

here is the code for the screen:
Code:
#Window = 0

EnableExplicit

Global Dim Border.i(1)

Dim Schlange.POINT (31)

Dim StatusText.s(2)
StatusText(0) = "Window"
StatusText(1) = "Maximized"

Global.l Win_Width, Win_Height
Global.l Win_X, Win_Y
Global.l Desk_Width, Desk_Height

Global.d Fact_X, Fact_Y

Define.l Scrn_Width, Scrn_Height
Define.l WMX, WMY, MX, MY
Define.l BorderFlag = 0
Define.l EXIT, Event
Define.l Counter, n, t

ExamineDesktops()
  Desk_Width  = DesktopWidth(0)
  Desk_Height = DesktopHeight(0)

InitSprite()
InitKeyboard()

Procedure ChangeSize( Flag.l )
  Select Flag
    Case 0
      SetWindowLongPtr_(WindowID(#Window), #GWL_STYLE, Border(Flag))
      SetWindowState( #Window, #PB_Window_Normal )
      ResizeWindow( #Window, Win_X, Win_Y, Win_Width, Win_Height )
    Case 1
      Win_X = WindowX(#Window)
      Win_Y = WindowY(#Window)
      SetWindowLongPtr_(WindowID(#Window), #GWL_STYLE, Border(Flag))
      SetWindowState( #Window, #PB_Window_Maximize )
      ExamineDesktops()
        Desk_Width  = DesktopWidth(0)
        Desk_Height = DesktopHeight(0)
  EndSelect
EndProcedure

Border(0) = #WS_CLIPSIBLINGS | #WS_VISIBLE | #WS_CAPTION | #WS_SYSMENU
Border(1) = #WS_CLIPSIBLINGS | #WS_VISIBLE | #WS_POPUP

Scrn_Width  = 1024
Scrn_Height =  768
Win_Width   = 1024
Win_Height  =  768

Fact_X = Desk_Width  / Scrn_Width
Fact_Y = Desk_Height / Scrn_Height

OpenWindow( #Window, 0,#PB_Ignore, Win_Width, Win_Height, "WindowedScreen Maximize Test", #PB_Window_SystemMenu | #PB_Window_ScreenCentered )
  Win_X = WindowX(#Window)
  Win_Y = WindowY(#Window)

OpenWindowedScreen( WindowID(#Window), 0,0, Scrn_Width,Scrn_Height, #True, 0, 0 )

For n=0 To 32
  Counter +1
  Schlange(0)\x = 512 + 256 * Sin( Counter / 20 )
  Schlange(0)\y = 384 + 192 * Cos( Counter / 15 )
  For t = 31 To 1 Step -1
    Schlange(t) = Schlange(t-1)
  Next
Next

Repeat
  Repeat
    Event = WindowEvent()
    If Event = #PB_Event_CloseWindow
      EXIT = 1
    EndIf
  Until Event = #Null

  WMX = WindowMouseX(0)
  WMY = WindowMouseY(0)
  If BorderFlag = 1
    MX = WMX / Fact_X
    MY = WMY / Fact_Y
  Else
    MX = WMX
    MY = WMY
  EndIf

  ExamineKeyboard()
  If KeyboardPushed(#PB_Key_F11) And BorderFlag <> 0
    BorderFlag = 0
    ChangeSize( BorderFlag )
  EndIf
  If KeyboardPushed(#PB_Key_F12) And BorderFlag <> 1
    BorderFlag = 1
    ChangeSize( BorderFlag )
  EndIf
  If KeyboardPushed( #PB_Key_Escape )
    EXIT = 1
  EndIf

  Counter +1
  If Counter > 100000 * #PI
    Counter = 0
  EndIf

  ClearScreen( $201008 )
  StartDrawing(ScreenOutput())

    Schlange(0)\x = 512 + 256 * Sin( Counter / 20 )
    Schlange(0)\y = 384 + 192 * Cos( Counter / 15 )
    For t = 31 To 1 Step -1
      Schlange(t) = Schlange(t-1)
      Circle( Schlange(t)\x, Schlange(t)\y, 2*t, RGB( 0, 255 - 8*t, 255 - 8*t ) )
    Next

    DrawingMode(#PB_2DDrawing_Transparent)
    DrawText( 1,  1, "[F11] Window    [F12] Maximize    [ESC] End", $0FF0FF )
    DrawText( 1, 25, "Status: " + StatusText( BorderFlag ), $0FF0FF )
    DrawText( 1, 49, "Position: " + Str(MX) + ", " + Str(MY), $0FF0FF )
  StopDrawing()
  FlipBuffers()
Until EXIT

_________________
oh... and have a nice day.


Top
 Profile  
Reply with quote  
 Post subject: Re: [Win] WindowedScreen maximized and back
PostPosted: Thu Feb 25, 2010 12:08 pm 
Offline
Enthusiast
Enthusiast

Joined: Fri Oct 24, 2008 2:07 pm
Posts: 228
very nice work, thanks Kaeru Gaman :D


Top
 Profile  
Reply with quote  
 Post subject: Re: [Win] WindowedScreen maximized and back
PostPosted: Thu Feb 25, 2010 12:40 pm 
Offline
Addict
Addict
User avatar

Joined: Sat Feb 19, 2005 2:46 pm
Posts: 1797
Location: Pas-de-Calais, France
:) Thank you!


Top
 Profile  
Reply with quote  
 Post subject: Re: [Win] WindowedScreen maximized and back
PostPosted: Thu Feb 25, 2010 12:46 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Fri Jun 26, 2009 3:51 pm
Posts: 216
Location: Westernmost tip of Norway
Thank you, this is very useful.

_________________
The best preparation for tomorrow is doing your best today.


Top
 Profile  
Reply with quote  
 Post subject: Re: [Win] WindowedScreen maximized and back
PostPosted: Wed Jun 30, 2010 4:07 pm 
Offline
Addict
Addict
User avatar

Joined: Wed Aug 31, 2005 11:09 pm
Posts: 3695
Location: Italy
Nice, thank you. :)

_________________
[ My little PureBasic review ]


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 9 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye