创建一个状态条,然后
int widths[] = {150, 300, 400,  -1};
SendMessage(hwndStatus, SB_SETPARTS, (WPARAM)4, (LPARAM)widths);//分成4部分
SendMessage(hwndStatus, SB_SETTEXT, (WPARAM)(INT) 1 | 0, (LPARAM) (LPSTR) TEXT("second"));//设置第二部分 文本SendMessage(hwndStatus, SB_SIMPLE, TRUE, 0);//切换到简单模式
SendMessage(hwndStatus, WM_SETTEXT, 0, (LPARAM)(LPTSTR)TEXT("This is simple mode!"));//设置简单模式下的文本
问题:
切换到简单模式后设置的文本不显示,切换回4部分才把This is simple mode显示在第一部分
是不是用法错了?
还有个问题(显示调整大小的小格子):
(WS_CHILD| WS_VISIBLE)//该风格默认显示在底部 有小格子
(WS_CHILD| WS_VISIBLE| CCS_TOP)//该风格显示在顶部 没有小格子
(WS_CHILD| WS_VISIBLE| CCS_TOP| SBARS_SIZEGRIP)//该风格显示在顶部 有小格子
那么我想显示在底部 同时有没有小格子,又该怎么设置呢,网上查了一些,都没起作用
比如
(WS_CHILD| WS_VISIBLE)& ~SBARS_SIZEGRIP //显示在底部 还是有小格子

解决方案 »

  1.   

    我都是用MFC
    看到是sdk的就直接忽略了
      

  2.   

    A simple mode status bar displays only one part. When the text of the window is set, the window is invalidated, but it is not redrawn until the next WM_PAINT message. 
      

  3.   

    #6楼 得分:0回复于:2012-06-03 20:03:26引用 5 楼 schlafenhamster 的回复:A simple mode status bar displays only one part. When the text of the window is set, the window is invalidated, but it is not redrawn until the next WM_PAINT message.设置简单模式以后,用另一程序的窗口掩盖滚动条,迫使它重绘,也是不显示文本。
    还有切换回普通模式,文本才显示,这是在简单模式下设置的文本,不应该在普通模式下显示吧? 
      

  4.   

    可能:
    SendMessage(hwndStatus, SB_SIMPLE, TRUE, 0);//切换到简单模式
    不超过:
    BOOL ret=SendMessage(hwndStatus, SB_SIMPLE, TRUE, 0);//切换到简单模式
    ret=0?
      

  5.   

    用的是CStatusBar 还是 CStatusBarCtrl?
      

  6.   

    没用类  直接用的CreateWindow用CStatusBar CStatusBarCtrl简单模式能起作用不
      

  7.   

    MFC下用CStatusBar得到CStatusBarCtrl:
    然后SetSimple返回为0.
    但SetText可以起作用。
    你是sdk是系统控件吧。
      

  8.   

    是系统控件
    MFC的类也是用CreateWindow创建系统控件啊
      

  9.   

    SendMessage(hwndStatus, WM_SETTEXT, 0, (LPARAM)(LPTSTR)TEXT("This is simple mode!"));-->SendMessage(hwndStatus, SB_SETTEXT, (WPARAM)(INT)SB_SIMPLEID| 0, (LPARAM)TEXT("This is simple mode!"));
      

  10.   

     lResult = SendMessage(     // returns LRESULT in lResult
            (HWND) hWndControl,        // handle to destination control
            (UINT) SB_SETTEXT,         // message ID
            (WPARAM) wParam,           // = (WPARAM) (INT) iPart | uType
            (LPARAM) lParam            // = (LPARAM) (LPSTR) szText
            );ParametersiPart
    Zero-based index of the part to set. If this parameter is set to SB_SIMPLEID, the status window is assumed to be a simple window with only one part.
    uType
    Type of drawing operation. This parameter can be one of the following values.
    0
    The text is drawn with a border to appear lower than the plane of the window.
    SBT_NOBORDERS
    The text is drawn without borders.
    SBT_OWNERDRAW
    The text is drawn by the parent window.
    SBT_POPOUT
    The text is drawn with a border to appear higher than the plane of the window.
    SBT_RTLREADING
    The text will be displayed in the opposite direction to the text in the parent window.
    SBT_NOTABPARSING
    Version 5.80. Tab characters are ignored.
    szText
    Pointer to a null-terminated string that specifies the text to set. If uType is SBT_OWNERDRAW, this parameter represents 32 bits of data. The parent window must interpret the data and draw the text when it receives the WM_DRAWITEM message. In Microsoft Windows XP and earlier, the text for each part is limited to 127 characters. This limitation has been removed in Windows Vista.
      

  11.   

    还是一样的,郁闷了
    case WM_CREATE:
    //...创建status bar
    //然后
    fSimple = FALSE;//static BOOL
    SendMessage(hwndStatus, SB_SIMPLE, fSimple, 0);
    SendMessage(hwndStatus, SB_SETPARTS, (WPARAM)(sizeof(Statwidths)/sizeof(int)),
                                                                              (LPARAM)Statwidths);
    SendMessage(hwndStatus, SB_SETTEXT, (WPARAM)(INT) 1|SBT_RTLREADING,
                                                                (LPARAM) (LPSTR)  TEXT("second"));

    fSimple = !fSimple;
    SendMessage(hwndStatus, SB_SIMPLE, fSimple, 0);//切换到简单模式,然后设置文本
    i = SendMessage(hwndStatus, WM_SETTEXT, (WPARAM)(INT)SB_SIMPLEID| 0,
                                                 (LPARAM)(LPTSTR)TEXT("This is simple mode!"));

     return 0;
    case WM_SIZE:
    SendMessage(hwndStatus, message, wParam, lParam);
    return 0; case WM_LBUTTONDOWN:
    fSimple = !fSimple;
    SendMessage(hwndStatus, SB_SIMPLE, fSimple, 0); //切换
    return 0;是不是还有什么地方要设置啊?
      

  12.   

    i = SendMessage(hwndStatus, WM_SETTEXT, (WPARAM)(INT)SB_SIMPLEID| 0,
      (LPARAM)(LPTSTR)TEXT("This is simple mode!")); 
    请看清楚我写的第二个参数是什么?SB_SETTEXT
      

  13.   

    囧,copy代码你也要copy完整啊
      

  14.   

    囧,copy代码你也要copy完整啊
      

  15.   

    果然囧, 我错了收到下面这句话影响了,设置第一个一直用的WM_SETTEXT
    If your application uses a status bar that has only one part, you can use the WM_SETTEXT, WM_GETTEXT, and WM_GETTEXTLENGTH messages to perform text operations. These messages deal only with the part that has an index of zero, allowing you to treat the status bar much like a static text control.
    还有个问题
    那个调整大小的小格子怎么去不掉啊?
      

  16.   

    系统的msctls_statusbar32是一个CStatusBarCtrl
      

  17.   

    试试用ModifyStyle()看能不能去掉SBARS_SIZEGRIP 属性
      

  18.   

    lStyle = GetWindowLong(hwndStatus, GWL_STYLE);
    lStyle &= ~SBARS_SIZEGRIP;
    SetWindowLong(hwndStatus, GWL_STYLE, lStyle);还是不起作用
      

  19.   

    CStatusBar和CStatusBarCtrl用的都是这个类 STATUSCLASSNAME=msctls_statusbar32
    不过风格不同
      

  20.   

    CStatusBar包含CStatusBarCtrl不一样
    问题2:
    使用SetPaneStyle
    看看。