创建一个状态条,然后
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 //显示在底部 还是有小格子
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 //显示在底部 还是有小格子
解决方案 »
- 写过VB、VC混编进,VB调用C++ DLL can't find dll entry point mConSendExample in *.dll
- 调用DLL的问题
- VC中如何判断编辑框(EDIT)是否有输入
- OpenFileMapping为何总是失败?
- 拷贝代码中——简单的问题!!
- VC中水晶表报怎么连接数据库?
- ■■■■■ ObjectARX的几个问题,小弟很菜,请进来看看 ■■■■■■
- 谁有Bounds Checker V601_D的serial No.?
- C++ 中的类的向前声明用法
- 求用C语言或用SDK开发的编辑器的源代码
- RichEdit EM_AUTOURLDETECT支持超链接自动检测 不准确
- 请各位前辈推荐一本学习VC++2008或VC++2010的好书,谢谢!
看到是sdk的就直接忽略了
还有切换回普通模式,文本才显示,这是在简单模式下设置的文本,不应该在普通模式下显示吧?
SendMessage(hwndStatus, SB_SIMPLE, TRUE, 0);//切换到简单模式
不超过:
BOOL ret=SendMessage(hwndStatus, SB_SIMPLE, TRUE, 0);//切换到简单模式
ret=0?
然后SetSimple返回为0.
但SetText可以起作用。
你是sdk是系统控件吧。
MFC的类也是用CreateWindow创建系统控件啊
(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.
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;是不是还有什么地方要设置啊?
(LPARAM)(LPTSTR)TEXT("This is simple mode!"));
请看清楚我写的第二个参数是什么?SB_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.
还有个问题
那个调整大小的小格子怎么去不掉啊?
lStyle &= ~SBARS_SIZEGRIP;
SetWindowLong(hwndStatus, GWL_STYLE, lStyle);还是不起作用
不过风格不同
问题2:
使用SetPaneStyle
看看。