1. Progress Bar Control Messages
PBM_DELTAPOS
PBM_GETPOS
PBM_GETRANGE
PBM_SETBARCOLOR
PBM_SETBKCOLOR
PBM_SETPOS
PBM_SETRANGE
PBM_SETRANGE32
PBM_SETSTEP
PBM_STEPIT
.h

1 #ifndef REMOTECONTROL_H 2 #define REMOTECONTROL_H 3 4 #include <QObject> 5 #include <windows.h> 6 #include <winuser.h> 7 8 class RemoteControl : public QObject 9 { 10 Q_OBJECT 11 public: 12 explicit RemoteControl(QObject *parent = 0); 13 bool FindWindow(QString title); 14 void SetControlRemove(int id); 15 void SetControlText(int id, QString text); 16 void SetControlCheck(int id,bool check); 17 void SetControlButton(int id); 18 UINT SetControlProcessbar(int id); 19 private: 20 HWND m_hWnd; 21 }; 22 23 #endif // REMOTECONTROL_H
.cpp

1 #include "remotecontrol.h" 2 #include <Commctrl.h> 3 #include <QDebug> 4 5 RemoteControl::RemoteControl(QObject *parent) : 6 QObject(parent) 7 { 8 } 9 10 bool RemoteControl::FindWindow(QString title) 11 { 12 for(int i = 0; i<5000; i++) 13 { 14 m_hWnd = ::FindWindowA(NULL, title.toStdString().c_str()); 15 if(m_hWnd != NULL) 16 return true; 17 } 18 19 qDebug()<<"Can't find window"; 20 return false; 21 } 22 23 //隐藏 24 void RemoteControl::SetControlRemove(int id) 25 { 26 HWND cid = ::GetDlgItem(m_hWnd,id); 27 if(cid == NULL) 28 return; 29 ::ShowWindow(cid,SW_HIDE); 30 } 31 32 //文本 33 void RemoteControl::SetControlText(int id,QString text) 34 { 35 HWND cid = ::GetDlgItem(m_hWnd,id); 36 if(cid == NULL) 37 return; 38 ::SendMessage( cid ,WM_SETTEXT,0,(LPARAM)text.toStdWString().data()); 39 } 40 41 //选中 42 void RemoteControl::SetControlCheck(int id,bool check) 43 { 44 HWND cid = ::GetDlgItem(m_hWnd, id); 45 if(cid == NULL) 46 return; 47 ::CheckDlgButton(m_hWnd,id,check); 48 } 49 50 //点击 51 void RemoteControl::SetControlButton(int id) 52 { 53 HWND cid = ::GetDlgItem(m_hWnd,id); 54 if(cid == NULL) 55 return; 56 ::SendMessage(cid ,BM_CLICK,0,0); 57 } 58 59 //进度条 60 UINT RemoteControl::SetControlProcessbar(int id) 61 { 62 HWND cid = ::GetDlgItem(m_hWnd,id); 63 if(cid == NULL) 64 return 0; 65 ::SendMessage(cid, PBM_SETPOS, 10, 0); 66 UINT result =::SendMessage(cid, PBM_GETPOS, (WPARAM)0, (LPARAM)0); 67 return result; 68 }