-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmainwindow.cpp
More file actions
60 lines (48 loc) · 1.57 KB
/
Copy pathmainwindow.cpp
File metadata and controls
60 lines (48 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
setWindowFlags(windowFlags()& ~Qt::WindowMaximizeButtonHint & Qt::MSWindowsFixedSizeDialogHint);
setFixedSize(this->width(), this->height());
m_pPixelColorProxy = new PixelColorProxy();
m_pProxyThread = new QThread();
__initConnection();
m_pPixelColorProxy->moveToThread(m_pProxyThread);
m_pProxyThread->start();
emit mouseMove();
m_hDesktopDC = GetDC(NULL);
m_screenWidth = GetDeviceCaps(m_hDesktopDC, HORZRES);
m_screenHeight = GetDeviceCaps(m_hDesktopDC, VERTRES);
}
void MainWindow::__initConnection()
{
connect( this , SIGNAL(mouseMove()), m_pPixelColorProxy , SLOT(onMouseMove()));
connect( m_pPixelColorProxy , SIGNAL(proxyFinish(BYTE,BYTE,BYTE,int,int)),this , SLOT(onColorProxyFinished(BYTE,BYTE,BYTE,int,int)),Qt::DirectConnection);
}
MainWindow::~MainWindow()
{
delete ui;
DeleteDC(m_hDesktopDC);
unHook();
}
void MainWindow::receiveMoseEvent( int Msg , int x , int y )
{
if(x<0) x=0;
else if(x>m_screenWidth-1) x = m_screenWidth-1;
if(y<0) y=0;
else if(y>m_screenHeight-1) y = m_screenHeight-1;
m_pPixelColorProxy->setMousePos(x , y);
}
void MainWindow::onColorProxyFinished( BYTE r , BYTE g , BYTE b , int x , int y)
{
QString R = QString::number(r);
QString G = QString::number(g);
QString B = QString::number(b);
QString X = QString::number(x);
QString Y = QString::number(y);
QString text = "RGB("+R+","+G+","+B+")\nPosition("+X+","+Y+")";
ui->m_oLabel2->setText(text);
}