Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Status Bar

Status Bar

Scheduled Pinned Locked Moved C / C++ / MFC
wpfdata-structureshelpquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Paddy
    wrote on last edited by
    #1

    Hi, Hope someone can help me out here please. I'm trying to create a status bar in my app so I added the function: // DoCreateStatusBar - creates a status bar and divides it into // the specified number of parts. // Returns the handle to the status bar. // hwndParent - parent window for the status bar. // nStatusID - child window identifier. // hinst - handle to the application instance. // nParts - number of parts into which to divide the status bar. HWND DoCreateStatusBar(HWND hwndParent, int nStatusID, HINSTANCE hinst, int nParts) { HWND hwndStatus; RECT rcClient; HLOCAL hloc; LPINT lpParts; int i, nWidth; // Ensure that the common control DLL is loaded. InitCommonControls(); // Create the status bar. hwndStatus = CreateWindowEx( 0, // no extended styles STATUSCLASSNAME, // name of status bar class (LPCTSTR) NULL, // no text when first created SBARS_SIZEGRIP | // includes a sizing grip WS_CHILD, // creates a child window 0, 0, 0, 0, // ignores size and position hwndParent, // handle to parent window (HMENU) nStatusID, // child window identifier hinst, // handle to application instance NULL); // no window creation data // Get the coordinates of the parent window's client area. GetClientRect(hwndParent, &rcClient); // Allocate an array for holding the right edge coordinates. hloc = LocalAlloc(LHND, sizeof(int) * nParts); lpParts = (LPINT)LocalLock(hloc); // Calculate the right edge coordinate for each part, and // copy the coordinates to the array. nWidth = rcClient.right / nParts; for (i = 0; i < nParts; i++) { lpParts[i] = nWidth; nWidth += nWidth; } // Tell the status bar to create the window parts. SendMessage(hwndStatus, SB_SETPARTS, (WPARAM) nParts, (LPARAM) lpParts); // Free the array, and return. LocalUnlock(hloc); LocalFree(hloc); return hwndStatus; } Which I got from MSDN. Then in my wndproc case: WM_CREATE I put in: statusbar = DoCreateStatusBar(hwnd, ID_STATUSBAR, hInst, 4); Everything compiles fine but unfortunately I don't get a status bar, is there some message I have to send it to make it display itself?

    G 1 Reply Last reply
    0
    • P Paddy

      Hi, Hope someone can help me out here please. I'm trying to create a status bar in my app so I added the function: // DoCreateStatusBar - creates a status bar and divides it into // the specified number of parts. // Returns the handle to the status bar. // hwndParent - parent window for the status bar. // nStatusID - child window identifier. // hinst - handle to the application instance. // nParts - number of parts into which to divide the status bar. HWND DoCreateStatusBar(HWND hwndParent, int nStatusID, HINSTANCE hinst, int nParts) { HWND hwndStatus; RECT rcClient; HLOCAL hloc; LPINT lpParts; int i, nWidth; // Ensure that the common control DLL is loaded. InitCommonControls(); // Create the status bar. hwndStatus = CreateWindowEx( 0, // no extended styles STATUSCLASSNAME, // name of status bar class (LPCTSTR) NULL, // no text when first created SBARS_SIZEGRIP | // includes a sizing grip WS_CHILD, // creates a child window 0, 0, 0, 0, // ignores size and position hwndParent, // handle to parent window (HMENU) nStatusID, // child window identifier hinst, // handle to application instance NULL); // no window creation data // Get the coordinates of the parent window's client area. GetClientRect(hwndParent, &rcClient); // Allocate an array for holding the right edge coordinates. hloc = LocalAlloc(LHND, sizeof(int) * nParts); lpParts = (LPINT)LocalLock(hloc); // Calculate the right edge coordinate for each part, and // copy the coordinates to the array. nWidth = rcClient.right / nParts; for (i = 0; i < nParts; i++) { lpParts[i] = nWidth; nWidth += nWidth; } // Tell the status bar to create the window parts. SendMessage(hwndStatus, SB_SETPARTS, (WPARAM) nParts, (LPARAM) lpParts); // Free the array, and return. LocalUnlock(hloc); LocalFree(hloc); return hwndStatus; } Which I got from MSDN. Then in my wndproc case: WM_CREATE I put in: statusbar = DoCreateStatusBar(hwnd, ID_STATUSBAR, hInst, 4); Everything compiles fine but unfortunately I don't get a status bar, is there some message I have to send it to make it display itself?

      G Offline
      G Offline
      georgiek50
      wrote on last edited by
      #2

      Did you forget to call InitCommonControls() or InitCommonControlsEx(). If so then that is the reason.

      P 1 Reply Last reply
      0
      • G georgiek50

        Did you forget to call InitCommonControls() or InitCommonControlsEx(). If so then that is the reason.

        P Offline
        P Offline
        Paddy
        wrote on last edited by
        #3

        Thanks for the help, I was calling InitCommonControls() but I forgot to include the WS_VISIBLE flag when I was creating the status bar!

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups