winapivisual-c++-2010

Unable to create StatusBar in Visual C++ express 2010 using plain win32 api


I am using plain Win32 API (no MFC I mean) to create a simple app. I use CreateWindowEx with STATUSCLASSNAME as specified in MSDN but the handle returned is NULL. I made a call to InitCommonControlsEx as indicated but that returns FALSE! So I suspect that's the reason why the bar isn't created. What's going on? Please help.

I am on Windows 7 64 bit.

hStatusBar = ::CreateWindowExW(
  0,
  L"STATUSCLASSNAME",
  L"",
  WS_VISIBLE|WS_CHILD|WS_BORDER,
  0,0,0,0, hWnd, 0, hInstance, NULL
);

Solution

  • There is one simple mistake in your code. STATUSCLASSNAME is not a value this is a constant from < commctrl.h >. So you code actually should looks like this:

     #include <commctrl.h>
     .
     .
     .
     hStatusBar = ::CreateWindowExW(
     0,
     STATUSCLASSNAME,
     L"",
     WS_VISIBLE|WS_CHILD|WS_BORDER,
     0,0,0,0, hWnd, 0, hInstance, NULL
    );
    

    I suppose you was looking into this http://msdn.microsoft.com/en-us/library/bb775491%28v=VS.85%29.aspx#STATUSCLASSNAME but as it specified, there are constants in the left column not values