resize window without flickering

Share your advanced PureBasic knowledge/code with the community.
User avatar
eddy
Addict
Addict
Posts: 1479
Joined: Mon May 26, 2003 3:07 pm
Location: Nantes

resize window without flickering

Post by eddy »

Code updated For 5.20+

Purpose : ZERO flickering in my PB app :twisted:

Code: Select all

 
;*******************************************
; READ ME
;uncomment this line if you want to force the Full-Drawing mode :
;*******************************************
;SystemParametersInfo_( #SPI_SETDRAGFULLWINDOWS, 1, 0, #SPIF_SENDWININICHANGE)
;

;Get state of Full-Drawing mode
Global CurrentDrawMode
Global DrawLocked
SystemParametersInfo_( #SPI_GETDRAGFULLWINDOWS, 0, @CurrentDrawMode, 0) ;-> CurrentDrawMode=1

#WM_CAPTURECHANGED=$215     

Procedure CB(Window, Message, wParam, lParam)
  Result = #PB_ProcessPureBasicEvents
  
  If Window=WindowID(0)
    Select Message
      Case #WM_NCLBUTTONDOWN
        If DrawLocked=0
          ;disable full-drawing mode
          SystemParametersInfo_( #SPI_SETDRAGFULLWINDOWS, 0, 0, #SPIF_SENDWININICHANGE)
          Debug "draw OFF"
          DrawLocked=1 
        EndIf
        
      Case #WM_CAPTURECHANGED
        Debug "draw ON"
        If DrawLocked And lParam<>Window
          ;restore full-drawing mode
          SystemParametersInfo_( #SPI_SETDRAGFULLWINDOWS, CurrentDrawMode, 0, #SPIF_SENDWININICHANGE   )           
          Debug "enable"               
          DrawLocked=0
        EndIf
        
        ;Case #WM_NCLBUTTONUP
        ;   Debug "test button UP"
        ;Case #WM_SIZING
        ;   Debug "resize"
        ;Case #WM_SIZE
        ;   Debug "resize END" 
        ;Case #WM_WINDOWPOSCHANGING
        ;   Debug "winpos changing"
        ;Case #WM_WINDOWPOSCHANGED
        ;   Debug "winpos changed"
    EndSelect
  EndIf
  
  ProcedureReturn Result
EndProcedure

If OpenWindow(0,100,100,200,200,"No Drawing",#PB_Window_SystemMenu|#PB_Window_SizeGadget)
  OpenWindow(1,400,100,200,200,"Full Drawing",#PB_Window_SystemMenu|#PB_Window_SizeGadget)   
  SetWindowCallback(@CB())
  
  Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow
EndIf
Last edited by eddy on Fri Sep 02, 2005 3:41 am, edited 4 times in total.
Imagewin10 x64 5.72 | IDE | PB plugin | Tools | Sprite | JSON | visual tool
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

you change the userconfiguration for all windows. :shock:
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
User avatar
eddy
Addict
Addict
Posts: 1479
Joined: Mon May 26, 2003 3:07 pm
Location: Nantes

Post by eddy »

LOL its just an example.
You have to code your own function.
Imagewin10 x64 5.72 | IDE | PB plugin | Tools | Sprite | JSON | visual tool
Post Reply