Page 1 of 1

Resizing a borderless window?

Posted: Fri Oct 24, 2003 7:58 pm
by merendo
Hi @ll

There seem to be conflicts between #PB_Window_Borderless and #PB_Window_SizeGadget when I use both at the same time. Try!

Code: Select all

if OpenWindow(0,0,0,400,300,#PB_Window_SizeGadget|#PB_Window_Borderless,"")
repeat
until waitwindowevent()=#PB_EventCloseWindow
endif
Is there any solution for this problem?

Thanks! merendo

Posted: Thu Nov 13, 2003 9:44 pm
by merendo
Still waiting for help ... :( :( :( :(

Posted: Thu Nov 13, 2003 10:17 pm
by Codemonger
Don't think you can resize a borderless window... you would have to manually program that in. Hard thing to do. Pls. correct me if I am wrong ?

Posted: Thu Nov 13, 2003 10:21 pm
by tinman
I don't think you can have a resizable borderless Window. At least there is no native Windows API flag for opening windows to say "turn off borders", the best you can do is just not to have any flags which create borders. I hope you understand that, I'm confusing myself :)

And I could be wrong - I'm no WinAPI expert.

Codemonger: it should be easy enough (!?!) to resize a window manually. Try searching on this forum for some code that either Paul or Beriko posted showing you how to resize gadgets in real time (it was for a discussion about visual form designers) - the same principles could be applied to a window. I think.

Posted: Fri Nov 14, 2003 12:33 am
by freedimension
Here's a small code I've written some time ago, still a little buggy, but could help you out a bit.

Code: Select all

#Window1 = 1 
#TRUE  = 1 
#FALSE = 0 

Global hWnd.l 


Procedure SetWinOpacity (hWin.l, Opacity.l)       ; 0: Durchsichtig  <--->  255: Opak 
  SetWindowLong_(hWin, #GWL_EXSTYLE, $00080000)    ; #WS_EX_LAYERED = $00080000 
  SetLayeredWindowAttributes_(hWin, 0, Opacity, 2) ; 
EndProcedure 
Procedure PaintWindowBackground() 
  ww.l = WindowWidth() 
  wh.l = WindowHeight() 

  hBmp.l    = CreateImage(0, ww, wh) 
  hRgn1.l   = CreateRoundRectRgn_( 4, 4, ww-4, wh-4, 17, 17) 
  hRgn2.l   = CreateRoundRectRgn_( 0, 0, ww  , wh  , 16, 16) 
  hBrush1.l = CreateSolidBrush_( RGB($D4, $D0, $C8) ) 

  hDC = StartDrawing( ImageOutput() )              ; Zeichnen des Fensterhintergrunds in der Bitmap 
    Box( 0, 0, ww, wh, RGB($54, $B5, $FF) ) 
    FillRgn_( hDC, hRgn1, hBrush1 ) 
    Line( ww-30,  8, 20, 20, 0) 
    Line( ww-30, 28, 20,-20, 0) 
    
    Line( ww-30, wh-10, 20,-20, 0) 
    Line( ww-20, wh-10, 10,  0, 0) 
    Line( ww-10, wh-10,  0,-10, 0) 
    Line( ww-10, wh-10,-10,-10, 0) 
    
    Line( 10, 20, 20,  0, 0) 
    Line( 20, 10,  0, 20, 0) 
  StopDrawing() 

  hBrush2.l = CreatePatternBrush_(hBmp)            ; Erzeugung einer Brush mit der Bitmap von oben 
  SetClassLong_(hWnd, #GCL_HBRBACKGROUND, hBrush2) ; Setzen des Fensterhintergrundes auf diese Brush 
  InvalidateRect_(hWnd, #NULL, #TRUE)              ; Neuzeichnen des Fensters anregen 

  SetWindowRgn_(hwnd, hRgn2, #TRUE)                ; "Beschneiden" des Fensters auf die neuen Maße 

  DeleteObject_( hRgn1 )                           ; Löschen aller temporären GDI-Objekte 
  DeleteObject_( hRgn2 ) 
  DeleteObject_( hBrush1 ) 
  DeleteObject_( hBrush2 ) 
EndProcedure 

hWnd = OpenWindow( #Window1, 100, 100, 1, 1, #PB_Window_BorderLess, "SkinTest") 

; Das Fenster für DoubleClicks empfänglich machen 
dLong = GetClassLong_(hWnd, #GCL_STYLE) | #CS_DBLCLKS   ; alten Style ermitteln und mit CS_DBLCLKS versehen 
SetClassLong_(hWnd, #GCL_STYLE, dLong)                  ; neuen Style setzen 


If hwnd <> 0 
  SetWinOpacity( hWnd, 0) 
  ResizeWindow(400, 600) 
  PaintWindowBackground() 
  For i=0 To 255 Step 10 
    SetWinOpacity( hWnd, i) : While WindowEvent() : Wend 
  Next 
  SetWinOpacity( hWnd, 255) 

  Repeat 
    EventID.l = WaitWindowEvent() 
    ww.l = WindowWidth() 
    wh.l = WindowHeight() 
    mx.l = WindowMouseX() 
    my.l = WindowMouseY() 

    Select EventID 
      Case #WM_SIZE 
        ; Minimalgröße des Fensters einstellen 
        If ww<90 
          ww=90 
        EndIf 
        If wh<60 
          wh=60 
        EndIf 
        ResizeWindow(ww, wh) 

      Case #WM_PAINT 
        PaintWindowBackground() 

      Case #WM_LBUTTONDBLCLK 
        ; Minimieren des Fensters ohne MinimizeButton 
        If (mx > 30 And (mx < ww-30) And my > 0 And my < 30) 
          ShowWindow_(hWnd, #SW_MINIMIZE) 
        EndIf 

      Case #WM_LBUTTONDOWN 
        ; Bewegen des Fensters ohne Titelleiste 
        If ((mx > 0 And mx < 30) And (my > 0 And my < 30)) 
          ReleaseCapture_() 
          SendMessage_(hWnd, #WM_NCLBUTTONDOWN, #HTCAPTION, NULL) 
        EndIf 
        
        ; Programm beenden 
        If ((mx > ww-30 And mx < ww-10) And (my > 8 And my < 28)) 
          result.l = MessageRequester("Programm schließen", "Wollen Sie das Programm wirklich beenden?", #PB_MessageRequester_YesNo | #MB_ICONQUESTION) 
          If(result = #IDYES) 
            EventID = #PB_EventCloseWindow 
          EndIf 
        EndIf 

        ; WindowResize ohne Fensterrahmen 
        If ((mx > ww-30 And mx < ww) And (my > wh-30 And my < wh)) 
          ReleaseCapture_() 
          SendMessage_(hWnd, #WM_NCLBUTTONDOWN, #HTBOTTOMRIGHT , NULL) 
        EndIf 

    EndSelect 
  Until EventID = #PB_EventCloseWindow 
EndIf 
End 
; ExecutableFormat=Windows
; EOF