http://club.excelhome.net/viewthread.php?tid=257625&replyID=&skin=0 看到一个状态栏进度条,原理是加载 progressbar 到状态栏,利用发送消息指挥 progressbar 动作。如果看到excel的消息传递,这种用法实在是太奢侈! Private Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long Private Const SM_CXSCREEN = 0 Private Declare Function FindWindowA Lib "user32" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long Private Declare Function WindowFromDC Lib "user32" (ByVal hdc As Long) As Long Private Declare Function IsWindowEnabled Lib "user32" (ByVal hwnd As Long) As Long Private Declare Function EnableWindow Lib "user32" (ByVal hwnd As Long, ByVal fEnable As Long) As Long Private Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long Private Declare Function SetActiveWindow Lib "user32" (ByVal hwnd As Long) As Long Private Declare Function LockWindowUpdate Lib "user32" (ByVal hwndLock As Long) As Long
Private Declare Function GetUpdateRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT, ByVal bErase As Long) As Long Private Declare Function ValidateRect Lib "user32" (ByVal hwnd As Long, lpRect As Any) As Long Private Declare Function InvalidateRect Lib "user32" (ByVal hwnd As Long, lpRect As Any, ByVal bErase As Long) As Long Private Declare Function RedrawWindow Lib "user32" (ByVal hwnd As Long, lprcUpdate As RECT, ByVal hrgnUpdate As Long, ByVal fuRedraw As Long) As Long Private Const RDW_ALLCHILDREN = &H80 Private Const RDW_ERASE = &H4 Private Const RDW_ERASENOW = &H200 Private Const RDW_FRAME = &H400 Private Const RDW_INTERNALPAINT = &H2 Private Const RDW_INVALIDATE = &H1 Private Const RDW_NOCHILDREN = &H40 Private Const RDW_NOERASE = &H20 Private Const RDW_NOFRAME = &H800 Private Const RDW_NOINTERNALPAINT = &H10 Private Const RDW_UPDATENOW = &H100 Private Const RDW_VALIDATE = &H8 Private Declare Function GetClientRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long Private Declare Function OffsetRect Lib "user32" (lpRect As RECT, ByVal x As Long, ByVal y As Long) As Long '------------------- Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long Private Declare Function GetDCEx Lib "user32" (ByVal hwnd As Long, ByVal hrgnclip As Long, ByVal fdwOptions As Long) As Long Private Const DCX_LOCKWINDOWUPDATE = &H400& Private Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As Long Private Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hdc As Long) As Long '-------------------- Private Declare Function SetTextColor Lib "gdi32" (ByVal hdc As Long, ByVal crColor As Long) As Long Private Declare Function TextOut Lib "gdi32" Alias "TextOutA" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal lpString As String, ByVal nCount As Long) As Long Private Declare Function ExtTextOut Lib "gdi32" Alias "ExtTextOutA" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal wOptions As Long, lpRect As RECT, ByVal lpString As String, ByVal nCount As Long, lpDx As Long) As Long Private Declare Function GetTextExtentPoint32& Lib "gdi32" Alias "GetTextExtentPoint32A" (ByVal hdc As Long, ByVal lpsz As String, ByVal cbString As Long, lpSize As Size) '-------------------- Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long Private Declare Function GetObject Lib "gdi32" Alias "GetObjectA" (ByVal hObject As Long, ByVal nCount As Long, lpObject As Any) As Long Private Declare Function GetStockObject Lib "gdi32" (ByVal nIndex As Long) As Long Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long Private Declare Function CreateFontIndirect Lib "gdi32" Alias "CreateFontIndirectA" (lpLogFont As LOGFONT) As Long Private Declare Function CreateFont Lib "gdi32" Alias "CreateFontA" (ByVal h As Long, ByVal W As Long, ByVal E As Long, ByVal O As Long, ByVal W As Long, ByVal i As Long, ByVal u As Long, ByVal S As Long, ByVal C As Long, ByVal OP As Long, ByVal CP As Long, ByVal Q As Long, ByVal PAF As Long, ByVal F As String) As Long Private Declare Function SetDCBrushColor Lib "gdi32.dll" (ByVal hdc As Long, ByVal colorref As Long) As Long Private Declare Function GetDCBrushColor Lib "gdi32.dll" (ByVal hdc As Long) As Long Private Declare Function CreateSolidBrush Lib "gdi32" (ByVal crColor As Long) As Long Private Declare Function GetSysColorBrush Lib "user32" (ByVal nIndex As Long) As Long Private Const COLOR_BTNFACE = 15 Private Declare Function FillRect Lib "user32" (ByVal hdc As Long, lpRect As RECT, ByVal hBrush As Long) As Long Private Declare Function InflateRect Lib "user32" (lpRect As RECT, ByVal x As Long, ByVal y As Long) As Long Private Declare Function CopyRect Lib "user32" (lpDestRect As RECT, lpSourceRect As RECT) As Long '-------------------- Private Declare Function DrawEdge Lib "user32" (ByVal hdc As Long, qrc As RECT, ByVal edge As Long, ByVal grfFlags As Long) As Long Private Const DC_ACTIVE = &H1 Private Const DC_NOTACTIVE = &H2 Private Const DC_ICON = &H4 Private Const DC_TEXT = &H8 Private Const BDR_RAISEDOUTER = &H1 Private Const BDR_SUNKENOUTER = &H2 Private Const BDR_RAISEDINNER = &H4 Private Const BDR_SUNKENINNER = &H8 Private Const BDR_INNER = &HC Private Const EDGE_BUMP = (BDR_RAISEDOUTER Or BDR_SUNKENINNER) Private Const EDGE_ETCHED = (BDR_SUNKENOUTER Or BDR_RAISEDINNER) Private Const EDGE_RAISED = (BDR_RAISEDOUTER Or BDR_RAISEDINNER) Private Const EDGE_SUNKEN = (BDR_SUNKENOUTER Or BDR_SUNKENINNER) Private Const BF_LEFT = &H1 ' 左边缘 Private Const BF_TOP = &H2 ' 上边缘 Private Const BF_RIGHT = &H4 ' 右边缘 Private Const BF_BOTTOM = &H8 ' 下边缘 Private Const BF_DIAGONAL = &H10 ' 对角线 Private Const BF_MIDDLE = &H800 ' 填充矩形内部 Private Const BF_SOFT = &H1000 ' MSDN: Soft buttons instead of tiles. Private Const BF_ADJUST = &H2000 ' 调整矩形, 预留客户区 Private Const BF_FLAT = &H4000 ' 平面边缘 Private Const BF_MONO = &H8000 ' 一维边缘 Private Const BF_RECT = (BF_LEFT Or BF_TOP Or BF_RIGHT Or BF_BOTTOM) Private Const BF_TOPLEFT = (BF_TOP Or BF_LEFT) Private Const BF_TOPRIGHT = (BF_TOP Or BF_RIGHT) Private Const BF_BOTTOMLEFT = (BF_BOTTOM Or BF_LEFT) Private Const BF_BOTTOMRIGHT = (BF_BOTTOM Or BF_RIGHT) Private Const BF_DIAGONAL_ENDTOPLEFT = (BF_DIAGONAL Or BF_TOP Or BF_LEFT) Private Const BF_DIAGONAL_ENDTOPRIGHT = (BF_DIAGONAL Or BF_TOP Or BF_RIGHT) Private Const BF_DIAGONAL_ENDBOTTOMLEFT = (BF_DIAGONAL Or BF_BOTTOM Or BF_LEFT) Private Const BF_DIAGONAL_ENDBOTTOMRIGHT = (BF_DIAGONAL Or BF_BOTTOM Or BF_RIGHT) '-------------------- Private Const LF_FACESIZE = 32 Private Const LF_FULLFACESIZE = 64 Private Const DEFAULT_PITCH = 0 '默认(值) Private Const FIXED_PITCH = 1 '固定的 Private Const VARIABLE_PITCH = 2 '可变的 Private Const FF_DECORATIVE = 80 ' 特殊字体 Private Const FF_DONTCARE = 0 ' 无所谓 Private Const FF_MODERN = 48 '具有规定的宽度,衬线可有可无 Private Const FF_ROMAN = 16 ' 字体宽度可变 Private Const FF_SCRIPT = 64 '手稿, Private Const FF_SWISS = 32 '宽度可变,带衬线 '*************************************************** |