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
#ifndef REMOTECONTROL_H
#define REMOTECONTROL_H #include <QObject>
#include <windows.h>
#include <winuser.h> class RemoteControl : public QObject
{
Q_OBJECT
public:
explicit RemoteControl(QObject *parent = );
bool FindWindow(QString title);
void SetControlRemove(int id);
void SetControlText(int id, QString text);
void SetControlCheck(int id,bool check);
void SetControlButton(int id);
UINT SetControlProcessbar(int id);
private:
HWND m_hWnd;
}; #endif // REMOTECONTROL_H
.cpp
#include "remotecontrol.h"
#include <Commctrl.h>
#include <QDebug> RemoteControl::RemoteControl(QObject *parent) :
QObject(parent)
{
} bool RemoteControl::FindWindow(QString title)
{
for(int i = ; i<; i++)
{
m_hWnd = ::FindWindowA(NULL, title.toStdString().c_str());
if(m_hWnd != NULL)
return true;
} qDebug()<<"Can't find window";
return false;
} //隐藏
void RemoteControl::SetControlRemove(int id)
{
HWND cid = ::GetDlgItem(m_hWnd,id);
if(cid == NULL)
return;
::ShowWindow(cid,SW_HIDE);
} //文本
void RemoteControl::SetControlText(int id,QString text)
{
HWND cid = ::GetDlgItem(m_hWnd,id);
if(cid == NULL)
return;
::SendMessage( cid ,WM_SETTEXT,,(LPARAM)text.toStdWString().data());
} //选中
void RemoteControl::SetControlCheck(int id,bool check)
{
HWND cid = ::GetDlgItem(m_hWnd, id);
if(cid == NULL)
return;
::CheckDlgButton(m_hWnd,id,check);
} //点击
void RemoteControl::SetControlButton(int id)
{
HWND cid = ::GetDlgItem(m_hWnd,id);
if(cid == NULL)
return;
::SendMessage(cid ,BM_CLICK,,);
} //进度条
UINT RemoteControl::SetControlProcessbar(int id)
{
HWND cid = ::GetDlgItem(m_hWnd,id);
if(cid == NULL)
return ;
::SendMessage(cid, PBM_SETPOS, , );
UINT result =::SendMessage(cid, PBM_GETPOS, (WPARAM), (LPARAM));
return result;
}