[comp.windows.ms.programmer] Status/Message bars - suggestions?

6600phnx@ucsbuxa.ucsb.edu (Phoenix / Fig) (05/16/91)

This has probably been asked before but does anyone have a good
suggestion on how to implement status/message bars on the top and bottom
of the window client area, with and without MDI?  You know, for
description of menu items and such ala W4W.  That be all ...

 ..Mike Figueroa..........................        _______________________
 . 6600phnx@ucsbuxa.ucsb.edu  (Internet) .       /        //     /
 . \-> %ucsbuxa@uunet.uu.net   (Bitnet)  .      /----    //     /   __
 .........................................     /        //     /     / 
 " ...my mind is going ... I can feel it"     /      ------    ------

risto@tuura.UUCP (Risto Lankinen) (05/17/91)

6600phnx@ucsbuxa.ucsb.edu (Phoenix / Fig) writes:

>This has probably been asked before but does anyone have a good
>suggestion on how to implement status/message bars on the top and bottom
>of the window client area, with and without MDI?  You know, for
>description of menu items and such ala W4W.  That be all ...

Hi!

I'll employ maximum brevity, so that FAQ could be updated if appropriate.

Add the following code fragments to the indicated places in the WinProc()
of an application, or the FrameWinProc() of a MDI application.
    ...
  case WM_CREATE:
    hWndClient = CreateWindow( "MDIClient",...,
          WS_CHILD|WS_VISIBLE|WS_CLIBSIBLINGS|WS_HSCROLL|WS_VSCROLL,... );
    hWndStatus = CreateWindow( "Static",...,
          WS_CHILD|WS_VISIBLE|SS_LEFT|SS_NOPREFIX,... );
    ...
  case WM_SIZE:
    GetClientRect( hWnd,&rect );
    // Calculate DIVIDING_LINE s.t. rect.top < DIVIDING_LINE < rect.bottom
    // One choice: DIVIDING_LINE = rect.bottom-GetSystemMetrics(SM_CYMENU);
    MoveWindow( hWndClient,rect.left,rect.top,
          rect.right,DIVIDING_LINE,TRUE );
    MoveWindow( hWndStatus,rect.left,DIVIDING_LINE,
          rect.right,rect.bottom,TRUE );
    ...
    break;  // Do *not* pass to DefFrameProc() of a MDI application !!!
    ...
    // To change the status text:
    SendMessage( hWndStatus,WM_SETTEXT,0,(LONG)(LPSTR)szStatusText );

Notes:
  - For non-MDI applications, all references to hWndClient above will simply
    be removed.
  - Menu selection can be tracked by setting the status text at a response to
    the WM_MENUSELECT message.
  - To draw a line between status bar and the rest of the client area, the
    DIVIDING_LINE should be adjusted in either MoveWindow() call to leave a
    gap between, which is called InvalidateRect() for, and actually being
    painted in response to the WM_PAINT .
  - The parent window should have WS_CLIPCHILDREN style bit set.

Terveisin: Risto Lankinen
-- 
Risto Lankinen / product specialist ***************************************
Nokia Data Systems, Technology Dept *  2                              3   *
THIS SPACE INTENTIONALLY LEFT BLANK * 2 +1 is PRIME!  Now working on 2 -1 *
replies: risto@yj.data.nokia.fi     ***************************************