Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long Private Const CCM_FIRST = &H2000 Private Const CCM_SETBKCOLOR = (CCM_FIRST + 1) Private Const SB_SETBKCOLOR = CCM_SETBKCOLORPrivate Sub Form_Load() SendMessage StatusBar1.hwnd, SB_SETBKCOLOR, 0, ByVal RGB(128, 128, 255) End Sub
楼上的这个不错,可以用,我试过! Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long Private Const CCM_FIRST = &H2000 Private Const CCM_SETBKCOLOR = (CCM_FIRST + 1) Private Const SB_SETBKCOLOR = CCM_SETBKCOLORPrivate Sub Form_Load() SendMessage StatusBar1.hwnd, SB_SETBKCOLOR, 0, ByVal RGB(128, 128, 255) End Sub
要是我的话我肯定会这样推断: ToolBar的专用消息是TB_ (ToolBar),键入API浏览器一看,成了! 同理StatusBar的就是SB_。如果你走歪路找了TBM_也没关系。看一下这些函数后面的名称:TBM_CLEARSEL TBM_CLEARTICS TBM_GETBUDDY TBM_GETCHANNELRECT ... 好像没什么关系哦,估计是错了。于是找TB_ TB_ADDBUTTONS TB_ADDBITMAP TB_ENABLEBUTTON TB_GETBUTTON ... 很像吧,SB_也是一样的(S……B……汗)接下来就是看名字: Private Const SB_SETBKCOLOR As Long = CCM_SETBKCOLOR毋庸置疑,就是不对也是相关了。把这个打到MSDN里面去找一找:SB_SETBKCOLOR Message (Windows Explorer and Controls) Sets the background color in a status bar. 进一步查看: SB_SETBKCOLOR Message --------------------------------------------------------------------------------Sets the background color in a status bar. Syntax To send this message, call the SendMessage function as follows. lResult = SendMessage( // returns LRESULT in lResult (HWND) hWndControl, // handle to destination control (UINT) SB_SETBKCOLOR, // message ID (WPARAM) wParam, // = 0; not used, must be zero (LPARAM) lParam // = (LPARAM) (COLORREF) clrBk; ); ParameterswParam Must be zero. clrBk COLORREF value that specifies the new background color. Specify the CLR_DEFAULT value to cause the status bar to use its default background color. Return ValueReturns the previous background color, or CLR_DEFAULT if the background color is the default color. 好了,到这里什么都明白了。E文很重要
Private Const CCM_FIRST = &H2000
Private Const CCM_SETBKCOLOR = (CCM_FIRST + 1)
Private Const SB_SETBKCOLOR = CCM_SETBKCOLORPrivate Sub Form_Load()
SendMessage StatusBar1.hwnd, SB_SETBKCOLOR, 0, ByVal RGB(128, 128, 255)
End Sub
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const CCM_FIRST = &H2000
Private Const CCM_SETBKCOLOR = (CCM_FIRST + 1)
Private Const SB_SETBKCOLOR = CCM_SETBKCOLORPrivate Sub Form_Load()
SendMessage StatusBar1.hwnd, SB_SETBKCOLOR, 0, ByVal RGB(128, 128, 255)
End Sub
Private Const CCM_FIRST = &H2000
Private Const CCM_SETBKCOLOR = (CCM_FIRST + 1)
Private Const SB_SETBKCOLOR = CCM_SETBKCOLOR
头都晕死了#$%^& 不如一句话:
Private Const SB_SETBKCOLOR = &H2001
【操作系统】
Win9X:Yes
WinNT:Yes
【说明】
调用一个窗口的窗口函数,将一条消息发给那个窗口。除非消息处理完毕,否则该函数不会返回。SendMessageBynum,
SendMessageByString是该函数的“类型安全”声明形式
【返回值】
Long,由具体的消息决定
【其它】
【参数表】
hwnd ----------- Long,要接收消息的那个窗口的句柄
wMsg ----------- Long,消息的标识符
wParam --------- Long,具体取决于消息
lParam --------- Any,具体取决于消息
可不可以解释一下这个API啊,
对于第二个参数wMsg ----------- Long,消息的标识符
你将它的值定为SB_SETBKCOLOR 是什么意思啊?
你是怎样知道的?
ToolBar的专用消息是TB_ (ToolBar),键入API浏览器一看,成了!
同理StatusBar的就是SB_。如果你走歪路找了TBM_也没关系。看一下这些函数后面的名称:TBM_CLEARSEL TBM_CLEARTICS TBM_GETBUDDY TBM_GETCHANNELRECT ...
好像没什么关系哦,估计是错了。于是找TB_
TB_ADDBUTTONS TB_ADDBITMAP TB_ENABLEBUTTON TB_GETBUTTON ...
很像吧,SB_也是一样的(S……B……汗)接下来就是看名字:
Private Const SB_SETBKCOLOR As Long = CCM_SETBKCOLOR毋庸置疑,就是不对也是相关了。把这个打到MSDN里面去找一找:SB_SETBKCOLOR Message (Windows Explorer and Controls)
Sets the background color in a status bar.
进一步查看:
SB_SETBKCOLOR Message --------------------------------------------------------------------------------Sets the background color in a status bar. Syntax
To send this message, call the SendMessage function as follows.
lResult = SendMessage( // returns LRESULT in lResult (HWND) hWndControl, // handle to destination control (UINT) SB_SETBKCOLOR, // message ID (WPARAM) wParam, // = 0; not used, must be zero (LPARAM) lParam // = (LPARAM) (COLORREF) clrBk; );
ParameterswParam
Must be zero.
clrBk
COLORREF value that specifies the new background color. Specify the CLR_DEFAULT value to cause the status bar to use its default background color.
Return ValueReturns the previous background color, or CLR_DEFAULT if the background color is the default color.
好了,到这里什么都明白了。E文很重要