Ooops
November 25, 2020, 05:18:33 AM

Author Topic: [bmx] Minimize / Maximize buttons by Grisu [ 1+ years ago ]  (Read 438 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
Title : Minimize / Maximize buttons
Author : Grisu
Posted : 1+ years ago

Description : Minimize / Maximize buttons for windowed App [Non MAXGUI]

Code :
Code: BlitzMax
  1. ' --------------------------------------------------------------
  2. ' BMX: Minimize / Maximize buttons for windowed App [Non MAXGUI].
  3. ' Very special thanks go to Diablo & Zawran!
  4. ' --------------------------------------------------------------
  5. Strict
  6.  
  7. Framework BRL.D3D7Max2D ' Framework, minimal stuff you need
  8. '  Import brl.glmax2d
  9.   Import BRL.EventQueue
  10.   Import BRL.Event
  11.  
  12. Extern "win32" ' Crazy WinAPI stuff
  13.         Function GetActiveWindow%()
  14.         Function IsZoomed%(hwnd%)
  15. End Extern
  16.  
  17. AppTitle = " Grisu and his crazy buttons - Version 1.0"
  18. Graphics 800,600,0
  19. Global hWnd% = GetActiveWindow() ' Save current Window handle
  20.  
  21. ' Init Buttons
  22. enableMinimize( hwnd% )
  23. enableMaximize( hwnd% )
  24.  
  25. ' --------------------------------------------------------------
  26. ' Main Loop
  27. While Not KeyHit(KEY_ESCAPE)
  28.  
  29.         Cls
  30.                 DrawText "BMX: Minimize / Maximize buttons [Non MAXGUI].",20,20
  31.                 DrawText "Very special thanks go to Diablo & Zawran!",20,40
  32.  
  33.                 DrawText "Push a button or hit ESC to exit....",20,560
  34.         Flip
  35.        
  36.     If AppTerminate() Then
  37.        Notify("Close button clicked. App killed. :)")
  38.        ' insert garbage clear up here <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  39.        End
  40.     EndIf
  41.    
  42.     If AppSuspended() Then
  43.        Notify("Minimize button clicked. App suspended.")
  44.        ' insert idle mode here <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  45.     EndIf
  46.  
  47.         If iszoomed(hWnd) Then
  48.         Notify("Maximize button clicked. App getting large.")
  49.         ' insert screenmode change here <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  50.                 EndGraphics()
  51.                 Graphics(800, 600, 32, 60)
  52.         EndIf
  53.     GCCollect() ' Garbage Collect, just to be 100% sure  
  54. Wend
  55. End
  56. ' End of a little cute App!
  57. ' --------------------------------------------------------------
  58.  
  59. Function enableMaximize(hWnd:Long)
  60. ' Adds the Maximize Button "[]"
  61.         Local tmp:Int = GetWindowLongA( hWnd, GWL_STYLE )
  62.         tmp = tmp | WS_MAXIMIZEBOX
  63.         SetWindowLongA( hWnd, GWL_STYLE, tmp )
  64.         DrawMenuBar( hWnd )
  65. End Function
  66.  
  67. Function enableMinimize(hWnd:Long)
  68. ' Adds the Minimize Button "_"
  69.         Local tmp:Long = GetWindowLongA( hWnd, GWL_STYLE )
  70.         tmp = tmp | WS_MINIMIZEBOX
  71.         SetWindowLongA( hWnd, GWL_STYLE, tmp )
  72.         DrawMenuBar( hWnd )
  73. End Function


Comments :


MGE(Posted 1+ years ago)

 Is there a cross platform version of this available?


 

SimplePortal 2.3.6 © 2008-2014, SimplePortal