Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TMemo Question

Status
Not open for further replies.

Leroy1981

Programmer
Jul 22, 2002
46
US
Does anyone know how I might get ahold of the TCanvas of
a TMemo component. All I really need is to be able to
check the pixels.
 
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.

Chris
 
Thanks supernat.

That is exactly what I was looking for
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top