Position a maximized window (negative values)

Windows specific forum
User avatar
chi
Addict
Addict
Posts: 1087
Joined: Sat May 05, 2007 5:31 pm
Location: Austria

Position a maximized window (negative values)

Post by chi »

I'd like to set the x/y position of a maximized window to negative values while the bottom-right corner of the window should touch the bottom-right corner of the desktop. Simple eh?

Problem seems to be #WM_WINDOWPOSCHANGED, which starts right after redrawing the window with my custom settings. Does anyone know how to intercept this "feature"?

Code: Select all

Global oldProc

Procedure WndCallback(hWnd, Msg, wParam, lParam)
  Select Msg
      
    Case #WM_GETMINMAXINFO
      *MinMax.MINMAXINFO = lParam
      *MinMax\ptMaxPosition\x = -100
      *MinMax\ptMaxPosition\y = -100
      *MinMax\ptMaxSize\x = GetSystemMetrics_(#SM_CXSCREEN) ; -1 
      *MinMax\ptMaxSize\y = GetSystemMetrics_(#SM_CYSCREEN)
      ProcedureReturn 0
      
  EndSelect
  ProcedureReturn CallWindowProc_(oldProc, hWnd, Msg, wParam, lParam)
EndProcedure

OpenWindow(0, 0, 0, 800, 500, "", #WS_OVERLAPPEDWINDOW|1)
SetWindowTheme_(WindowID(0), "", "")
oldProc = SetWindowLongPtr_(WindowID(0), #GWL_WNDPROC, @WndCallback())
While WaitWindowEvent() ! #PB_Event_CloseWindow : Wend
Thx, chi
Et cetera is my worst enemy
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4997
Joined: Sun Apr 12, 2009 6:27 am

Re: Position a maximized window (negative values)

Post by RASHAD »

Hi
I am not sure what you want to do
If you want to hide the Caption why do not you toggle between Border & No Border
Anyhow here it is as per your request

# 1 :

Code: Select all

Global oldProc,DW,DH

ExamineDesktops()
DW = DesktopWidth(0)
DH = DesktopHeight(0)

Procedure WndCallback(hWnd, Msg, wParam, lParam)
  Select Msg
     
    ;Case #WM_GETMINMAXINFO
      ;*MinMax.MINMAXINFO = lParam
      ;*MinMax\ptMaxTrackSize\x =3000
      ;*MinMax\ptMaxTrackSize\y = 3000
      ;*MinMax\ptMaxSize\x = 3000
      ;*MinMax\ptMaxSize\y = 3000
      ;ProcedureReturn 0
      
    Case #WM_WINDOWPOSCHANGED
         SetWindowPos_(WindowID(0),0,-100,-100,DW+100,DH + 100,#SWP_NOSENDCHANGING)
         
  EndSelect
  ProcedureReturn CallWindowProc_(oldProc, hWnd, Msg, wParam, lParam)
EndProcedure


OpenWindow(0, 0,-100,800,600, "",#WS_OVERLAPPEDWINDOW|1)
SetWindowTheme_(WindowID(0), "", "")
oldProc = SetWindowLongPtr_(WindowID(0), #GWL_WNDPROC, @WndCallback())
While WaitWindowEvent() ! #PB_Event_CloseWindow : Wend
# 2:

Code: Select all

Global oldProc,DW,DH

ExamineDesktops()
DW = DesktopWidth(0)
DH = DesktopHeight(0)

Procedure WndCallback(hWnd, Msg, wParam, lParam)
result = #PB_ProcessPureBasicEvents 

  Select Msg
     
    Case #WM_GETMINMAXINFO
      *MinMax.MINMAXINFO = lParam
      *MinMax\ptMaxTrackSize\x =3000
      *MinMax\ptMaxTrackSize\y = 3000
      *MinMax\ptMaxSize\x = 3000
      *MinMax\ptMaxSize\y = 3000
      
    Case #WM_WINDOWPOSCHANGED
         MoveWindow_(WindowID(0),-100,-100,DW+100,DH+100,1)
         
  EndSelect
  ProcedureReturn result
EndProcedure


OpenWindow(0, 0,-100,800,600, "",#WS_OVERLAPPEDWINDOW|1)
SetWindowTheme_(WindowID(0), "", "")
SetWindowCallback(@WndCallback())
While WaitWindowEvent() ! #PB_Event_CloseWindow : Wend
Egypt my love
User avatar
chi
Addict
Addict
Posts: 1087
Joined: Sat May 05, 2007 5:31 pm
Location: Austria

Re: Position a maximized window (negative values)

Post by chi »

Hey, thanks a lot! I'm pretty sure I tried the way you took with #1... Guess #SWP_NOSENDCHANGING was missing ;) Thx again!
Et cetera is my worst enemy
Post Reply