Theos PowerBasic Museum 2017

Webmaster: José Roca (PBWIN 10+/PBCC 6+) (SDK Forum) => Discussion => Topic started by: John Thompson on January 14, 2012, 12:20:57 AM

Title: CWindow AddStatusBar
Post by: John Thompson on January 14, 2012, 12:20:57 AM
Hi,

I'm adding a status bar using:


pWindow.AddStatusBar ( pWindow.hWnd, %IDC_STATUSBAR, "StatusBar", 0, 0, 0, 0  )


It shows up so that the very top line is visible at the very bottom, but I have to resize the window (larger) to see it entirely.  Once I do, the StatusBar remains in its position until I click AND drag the sizing grip at which point it resizes to be entirely visible at the bottom of the window.

Unfortunately, if I resize the window again the StatusBar stays in the same place until I click and drag the sizing grip again.

I'd tried adjusting the 0,0,0,0 values to position it myself, but it didn't do anything.

Any advice on having it properly placed, permanently, would be greatly appreciated!

Thanks,

-John
Title: Re: CWindow AddStatusBar
Post by: John Thompson on January 14, 2012, 12:32:14 AM
I guess posting is giving me enough luck to find the answer!  Well, in case this helps anyone else in the future:

In %WM_SIZE:

         ' // Gets the handle of the status bar
         LOCAL hStatusBar AS DWORD
         hStatusBar = GetDlgItem(hwnd, %IDC_STATUSBAR)
         ' // Resizes it
         SendMessage hStatusBar, %WM_SIZE, wParam, lParam
         ' // Redraws it
         InvalidateRect hStatusBar, BYVAL %NULL, %TRUE
         EXIT FUNCTION
Title: Re: CWindow AddStatusBar
Post by: José Roca on January 14, 2012, 02:55:16 AM
I also forget very often these details. This is why I write many examples: to remember what I have to do. Besides the status bar, toolbars also need to be updated in the WM_SIZE message, e.g. ToolBar_AutoSize GetDlgItem(hWnd, %IDC_TOOLBAR).