WINAPI, how to make status bar (I don't know where WINAPI forum)

Started by
0 comments, last by Buckeye 13 years, 9 months ago
I heard that WINAPI cam create status bar(the bottom bar in window program)
but I still cannot find the tutorial that is easy to understand.
Maybe I used the wrong name??
If someone know please tell....thanks
Advertisement
This a copy/paste from an app. You'll have to customize.
 const DWORD x_rgStatusBarSizes[5] = {80, 60, 80, 80, 80}; // whatever size in pixels for each segment in the barconst DWORD x_cStatusBarSizes = 5;#define CHILDNUM_STATUSBAR 200//......   // Create the status bar.	//=============== add a status bar ===============	hwndStatusbar = CreateWindowEx(         0,                       // no extended styles         STATUSCLASSNAME,                // name of status bar class         (LPCTSTR) NULL,          // no text when first created         WS_CHILD | WS_VISIBLE,                // creates a child window         0, 0, 0, 0,              // ignores size and position         m_hwnd,                  // handle to parent window         (HMENU) CHILDNUM_STATUSBAR,               // child window identifier         m_hInstance,             // handle to application instance         NULL);                   // no window creation data 	DWORD lError = 0;	if( hwndStatusbar==NULL ) {		lError = GetLastError();		// 1407 = CANNOT find window class - if this error, load the control library	}//....    RECT r;    INT lpParts[x_cStatusBarSizes+1];    DWORD iCur;    INT iPart;    GetClientRect( m_hwnd, &r );    iCur = r.right - r.left;    for (iPart = x_cStatusBarSizes - 1; iPart >= 0; iPart--)    {        lpParts[iPart+1] = iCur;        iCur -= x_rgStatusBarSizes[iPart];    }    lpParts[0] = iCur;    SendMessage(hwndStatusbar, SB_SETPARTS, (WPARAM) x_cStatusBarSizes+1, (LPARAM) lpParts); // .... in some function, e.g., UpdateStatusBar()	SendMessage(hwndStatusbar, SB_SETTEXT, (WPARAM) 0, (LPARAM) "1st msg" );	SendMessage(hwndStatusbar, SB_SETTEXT, (WPARAM) 1, (LPARAM) "2nd msg" );	SendMessage(hwndStatusbar, SB_SETTEXT, (WPARAM) 2, (LPARAM) "3rd msg" );

Note: in some drawing calls to the client, you may have to compensate for the height of the statusbar.

EDIT:
You may need this in your app initialization, prior to creating the statusbar.
	INITCOMMONCONTROLSEX ccx;	ccx.dwSize = sizeof(ccx);	ccx.dwICC = ICC_BAR_CLASSES;	InitCommonControlsEx(&ccx);

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

This topic is closed to new replies.

Advertisement