| 56 | |
| 57 | private: |
| 58 | void SetColor(QMouseEvent* e) |
| 59 | { |
| 60 | QPoint ms = e->pos(); |
| 61 | QPoint pt(ms.x() + 25, ms.y() + 25); |
| 62 | POINT ams; GetCursorPos(&ams); |
| 63 | COLORREF rgb = GetPixel(hdc, ams.x, ams.y); |
| 64 | if ((pt.x() > vrect.width() - 25) && (pt.y() > vrect.height() - 25)) pt.setX(ms.x() - 45), pt.setY(ms.y() - 45); |
| 65 | else { if (pt.x() > vrect.width() - 25) pt.setX(vrect.width() - 25); if (pt.y() > vrect.height() - 25) pt.setY(vrect.height() - 25); } |
| 66 | color = qRgb(GetRValue(rgb), GetGValue(rgb), GetBValue(rgb)); |
| 67 | colorBox.setColor(color); |
| 68 | colorBox.move(pt); |
| 69 | } |
| 70 | |
| 71 | protected: |
| 72 | void paintEvent(QPaintEvent*) { if (!end) { QPainter pa(this); pa.fillRect(this->rect(), QColor(127, 127, 127, 1)); } } |