Is there another function similar to this that can draw colored boxes?
I've had a change of plans with my project, and instead of pictures I think I might just want to use colors. :)
http://www.codeproject.com/bitmap/rplcolor.asp
QuoteWhen I wrote this function my problem was to replace one color by an other on transparent bitmaps. My images were resources bitmaps, which I store in an ImageList for easy transparency.
From the title and first paragraph it says replacing a color. I don't think this will allow me to draw a square and then color it. :/
Draw the square in black and change its color. Durrr.
Bleh, good idea, I'll try that. :)
Or just....
DrawRectangle!
http://windowssdk.msdn.microsoft.com/en-us/library/ms534038(VS.80).aspx
The following code assumes you know how to include the GDI+ headers, are using the flat C API, can figure out how to check the status variable, and have the HDC as hDC, int variables x, y, width, and height, and ARGB values foreColor and backColor.
GpGraphics* gfx;
GpStatus status = GdipCreateFromHDC(hDC, &gfx);
// check status
// create line and fill brushes
GpSolidFill* foreBrush, fillBrush;
status = GdipCreateSolidFill(foreColor, &foreBrush);
// check status
status = GdipCreateSolidFill(backColor, &fillBrush);
// check status
// draw the fill
status = GdipFillRectangleI(gfx, fillBrush, x, y, width, height);
// check status
status = GdipDrawRectangleI(gfx, foreBrush, x, y, width, height);
// check status
I highly recommend learning GDI+. It is a very robust system, and very slick in .NET. ;)
I'll look into that, looks like its what I want. :)
This works. Thanks for the help. :)
With lpRect
.Left = 0
.Top = 0
.Right = 50
.Bottom = 50
End With
hbrush = CreateSolidBrush(vbBlack)
Call FillRect(Picture1.hdc, lpRect, hBrush)
Oh, didn't know you were using VB. :P