Jump to content
  • Advertisement
Sign in to follow this  

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

This topic is 3015 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post

Link to post
Share on other sites
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 bar
const DWORD x_cStatusBarSizes = 5;

// 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
INT lpParts[x_cStatusBarSizes+1];
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.

You may need this in your app initialization, prior to creating the statusbar.

ccx.dwSize = sizeof(ccx);

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!