Unfortunately, the TMemo has no canvas. It is derived from a windowed control, which doesn't support that. You can use GDI functions to get the color of a pixel on the screen at a point though if you'd like.
COLORREF GetPixel(
HDC hdc, // handle of device context
int XPos, // x-coordinate of pixel
int nYPos // y-coordinate of pixel
);
COLORREF contains the r, g, and b value of the pixel.
HDC can be obtained by calling GetDeviceContext() from a TWinControl or TControl. Unforunately, again, it's not accessible from TMemo! So you have to grab the HDC yourself.
HDC dc = GetDC(MainForm->Handle);
COLORREF color = GetPixel(dc, xCoord, yCoord);
ReleaseDC(MainForm->Handle, dc);
Byte Red = GetRValue(color);
Byte Green = GetGValue(color);
Byte Blue = GetBValue(color);
I haven't tried this, if it doesn't work, let me know, and I'll see what I did wrong.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.