Page 1 of 1

Fixed Window on desktop like Taskbar?!

Posted: Tue Jun 24, 2003 4:44 pm
by Tranquil
Hi all!

I'm searching for a Trick to align an own Window on the left side of my desktop where all other opened windows aligns to.

Like the Taskbar at the bottom of a screen. If I switch a window to fullscreen the window fits to the maximum size of the desktopheight-taskbarheight.

Is this possible in PB?

Cheers
Mike

Re: Fixed Window on desktop like Taskbar?!

Posted: Tue Jun 24, 2003 5:27 pm
by PB
I don't understand (sorry). Do you want to open your own window at the
left of the screen, and force all other windows to not cover it when opened,
but to have their left edge aligned with the right edge of your window?

Re: Fixed Window on desktop like Taskbar?!

Posted: Tue Jun 24, 2003 5:48 pm
by Tranquil
PB wrote:I don't understand (sorry). Do you want to open your own window at the
left of the screen, and force all other windows to not cover it when opened,
but to have their left edge aligned with the right edge of your window?
PB you understand right! That is 100% that what I mean. sorry my bad frozen english. :o)

Mike

Re: Fixed Window on desktop like Taskbar?!

Posted: Tue Jun 24, 2003 5:52 pm
by PB
> That is 100% that what I mean

Cool! 8) Here's a really bad example then... there must be better ways to
do it than this. This simply checks the position of every window and moves
it to the right of your window if it covers it. Not a good way to do it, but
perhaps someone else can come up with a better solution?

A funny tip: If you add the #PB_Window_Invisible flag to your window, then
you get an area on the Desktop that no other window can cover... nice!

Code: Select all

If OpenWindow(0,0,0,50,999,#PB_Window_SystemMenu,"test")
  SetWindowPos_(WindowID(),#HWND_TOPMOST,0,0,0,0,#SWP_NOMOVE|#SWP_NOSIZE)
  Repeat
    Sleep_(1) : ev=WindowEvent()
    r=GetWindow_(GetDesktopWindow_(),#GW_CHILD)
    Repeat
      GetWindowRect_(r,win.RECT) : x=win\left : y=win\top : w=win\right-win\left : h=win\bottom-win\top
      If x<WindowWidth() And r<>WindowID()
        MoveWindow_(r,WindowWidth()+GetSystemMetrics_(#SM_CXFRAME),y,w,h,#TRUE)
      EndIf
      r=GetWindow_(r,#GW_HWNDNEXT)
    Until r=0    
  Until ev=#PB_Event_CloseWindow
EndIf

Posted: Tue Jun 24, 2003 5:58 pm
by Tranquil
Thanks for fast replay PB! Thats a first step in the right direction. But there should be another solution which resizes other windows to the correct size. Possible by simple set some flags on the window behaviors!?

Mike

Posted: Tue Jun 24, 2003 9:16 pm
by freak
Took some time to find out, but this works quite well...

Note:
You only need to take care of MAXIMIZED windows, as non-maximized
windows can also be moved over the area of the real Taskbar, only
Maximized Windows do not overlap it. This code behaves like the real
Taskbar, the only difference is it's look, but maybe you can change that
with some flags also, to make it look the same.

Hope it helps...

Timo

Code: Select all

; Callback to update all non-child maximized windows
Procedure.l UpdateWindowsProc(hWnd.l, *desktop.RECT)
  If IsZoomed_(hWnd)
    MoveWindow_(hWnd, *desktop\left, *desktop\top, *desktop\right-*desktop\left, *desktop\bottom-*desktop\top, #TRUE)
  EndIf
  ProcedureReturn #TRUE
EndProcedure


; Get actual desktop size (without Taskbar)
SystemParametersInfo_(#SPI_GETWORKAREA, 0, @desktop.RECT, 0)

If OpenWindow(0, desktop\left, desktop\top, 0, 0, #PB_Window_SystemMenu, "")

  ; resize Window to not overlap the Taskbar, and to 50 pixel width
  SetWindowPos_(WindowID(),#HWND_TOPMOST,0,0,50,desktop\bottom-desktop\top,#SWP_NOMOVE) 
  
  ; now calculate the new desktop rectangle
  desktopnew.RECT
  desktopnew\left = desktop\left + WindowWidth() + GetSystemMetrics_(#SM_CXFIXEDFRAME)*2
  desktopnew\right = desktop\right
  desktopnew\top = desktop\top
  desktopnew\bottom = desktop\bottom
  
  ; set new desktop rectangle
  SystemParametersInfo_(#SPI_SETWORKAREA, 0, @desktopnew, #SPIF_SENDWININICHANGE)
  
  ; update all windows (because most do not react to the #WM_SETTINGCHANGE message
  EnumWindows_(@UpdateWindowsProc(), @desktopnew)

  ; here comes all the rest of your prog (in my case, only wait)
  Repeat
  Until WaitWindowEvent() = #PB_EventCloseWindow
  
  ; reset desktop to old size
  SystemParametersInfo_(#SPI_SETWORKAREA, 0, @desktop, #SPIF_SENDWININICHANGE)  
  ; update windows again
  EnumWindows_(@UpdateWindowsProc(), @desktop)

EndIf
End

Posted: Wed Jun 25, 2003 6:27 am
by Tranquil
Thanks Timo, that is exactly what I'm was searching for!! Works very fine.

Thanks again!

Mike

AppBars

Posted: Wed Jun 25, 2003 4:41 pm
by Hi-Toro
Though I'm sure that works much the same (can't try right now!), I believe this is 'meant' to be done with AppBars:

http://msdn.microsoft.com/library/en-us ... ppbars.asp

I tried once, but only got it partly working...

Posted: Thu Jun 26, 2003 4:17 pm
by Tranquil
you are right hi-toro!

Its an appbar which I want to create. I will take a look on the msdn reference. I did not know the name appbar for this.
Thanks a lot to all who tried to help!


Mike