1. Writing text in colors
- Posted by Andy Drummond <kestrelandy at xalt.co.uk> May 27, 2002
- 471 views
I posted a problem with getDC:SaveDC() recently, and was advised to avoid using graphics routines - like, I suspect, setText(). i trued Win32Lib v0.57.6 but that doesn't help and is veerrryyyy sllooowwwww at times or in some routines. wPuts() & wPrintf() are nasty - they leave the rest of the text box with its old text, and use the system default background. I can't seem to get around these - so please can someone advise me what is a basically simple Windows task: I want to write text, over & over again, into the same text box controls, in different foreground OR background color without the resources getting eaten up like they are when I use setWindowBkColor() and setText(). Anyone with a working technique (should be easy!!!) i will buy a beer when I see them! Andy Drummond
2. Re: Writing text in colors
- Posted by tone.skoda at siol.net May 27, 2002
- 448 views
----- Original Message ----- From: "Andy Drummond" <kestrelandy at xalt.co.uk> > I want to write text, over & over again, into the same text box > controls, in different foreground OR background color without the > resources getting eaten up like they are when I use setWindowBkColor() > and setText(). If you do this in C: while 1 do brush = CreateSolidBrush (RGB (rand ()%255, rand ()%255, rand ()%255) SelectObject (hdc, brush) Ellipse (hdc, 0, 0, 100, 100) DeleteObject (brush) end while it won't work. After some time brush won't be created correct, it will be allways white (or something similar). That's what has happend to me several times when I was programming in C on win9x. What I suggest is to pre-create all your brushes, pens on program startup and save them in sequence. Delete them when program closes.
3. Re: Writing text in colors
- Posted by Wolf <wolfritz at KING.IGS.NET> May 27, 2002
- 451 views
> while 1 do > brush = CreateSolidBrush (RGB (rand ()%255, rand ()%255, rand ()%255) The problem is not with 'brush', but with 'object' . ... SelectObject() should be a *function*, so you can do: while 1 do brush = CreateSolidBrush (RGB (rand ()%255, rand ()%255, rand ()%255) previous = SelectObject (hdc, brush) -- returns handle of previous brush Ellipse (hdc, 0, 0, 100, 100) -- draw with new brush previous = SelectObject(hdc, previous) -- restore previous brush success = DeleteObject (brush) if success = 0 then -- ( we have a problem ! ) < snip > end while < quote from win32.hlp, re: SelectObject() > This function returns the previously selected object of the specified type. An application should always replace a new object with the original, default object after it has finished drawing with the new object.