Emulation of window sizing

Everything else that doesn't fall into one of the other PB categories.
merendo
Enthusiast
Enthusiast
Posts: 449
Joined: Sat Apr 26, 2003 7:24 pm
Location: Germany
Contact:

Emulation of window sizing

Post by merendo »

Hello all.

I am coding a programme whose window uses a borderless GUI. Now I need an example how to tell windows that the user is actually re-sizing the window. This means, I need to tell windows that the user is re-sizing the window using the #PB_Window_SizeGadget . How to do this?

Thanks for any help, merendo
freedimension
Enthusiast
Enthusiast
Posts: 613
Joined: Tue May 06, 2003 2:50 pm
Location: Germany
Contact:

Post by freedimension »

Take a look at my example on Windowskinning, it's a little bit buggy, but should transport the idea ;-)

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
merendo
Enthusiast
Enthusiast
Posts: 449
Joined: Sat Apr 26, 2003 7:24 pm
Location: Germany
Contact:

Post by merendo »

I am sorry (not my fault), but I cannot execute your code. I get an error telling that USER32.DLL does not contain function called SetLayeredWindowAttributes. Is this function necessarily required for the code to work correctly?
User avatar
Rings
Moderator
Moderator
Posts: 1435
Joined: Sat Apr 26, 2003 1:11 am

Post by Rings »

SetLayeredWindowAttributes is not part of the Win95 or Win-NT user32.dll. for testing, you can comment that line
SPAMINATOR NR.1
freedimension
Enthusiast
Enthusiast
Posts: 613
Joined: Tue May 06, 2003 2:50 pm
Location: Germany
Contact:

Post by freedimension »

Yeah, this code was from back when I didn't know this and developing under WinXP had no errors for myself. Just give that part of my code a very hard kick ;-)
merendo
Enthusiast
Enthusiast
Posts: 449
Joined: Sat Apr 26, 2003 7:24 pm
Location: Germany
Contact:

Post by merendo »

Where are my steel-enforced boots? :lol: :lol: :lol: :lol:

The code works now and I fount what I was looking for. Thanks a lot!
Berikco
Administrator
Administrator
Posts: 1326
Joined: Wed Apr 23, 2003 7:57 pm
Location: Belgium
Contact:

Post by Berikco »

merendo wrote:Where are my steel-enforced boots? :lol: :lol: :lol: :lol:

The code works now and I fount what I was looking for. Thanks a lot!
I stole your boots :mrgreen:
merendo
Enthusiast
Enthusiast
Posts: 449
Joined: Sat Apr 26, 2003 7:24 pm
Location: Germany
Contact:

Post by merendo »

Give them back to me. I still haven't visited Fred :)
Post Reply