News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Changing colours and fonts

Started by Roger, October 16, 2008, 06:58:15 PM

Previous topic - Next topic

Roger

Hi All,

I am still stuck on a few details of the basic window for my project posted below.

While I can process text from the keyboard and display the results (thanks to Hutch's suggestion), I am unable to change colours or font as I require.

I am using SetTextColor but it seems to have two ways of working in different places.
When typing in, to the bottom edit,  the colour changes apply only to the new text whereas when copying to the top edit the change is applied to all the existing text. I cannot see what is different about the edit boxes to cause this difference.

If you type upper case or a-o you should get magenta, if you type p or above you get green. On the upper part 0 -9 chars should be blue, 10 or more should be magenta. The change is made but it changes back!

I can change the font by the code in the WM_PAINT handler but it does not stay changed. If I try the same code elsewhere I can't make it work. SelectObject in the WM_CREATE in WndProc returns the same handle (that of the replaced font) that it returns in WM_PAINT which suggests to me that it has worked, except that the font remains the same.

The EditWndProcTop never gets a WM_CREATE message so it does not get the chance to work. I do not understand why there is no WM_CREATE message.

Note the effects when the window is minimised and restored. Eliminating the WM_PAINT handler cures this but then I have no way to  change the font.

Any suggestions or enlightenment would be greatly appreciated.

Regards Roger


[attachment deleted by admin]

Tedd

It doesn't work because the Edit control only displays text with one colour.
So, the text in the top window changes to the colour you set last.
The bottom window 'works' because you're drawing the text directly onto the window - this will get trashed as soon as there's a repaint (cover the window with another and then reshow it, or minimize and then restore - the text isn't really there, it's just left over from when you drew it.)

If you use a Rich-Edit control then you can specify the colours, fonts and all sorts of styles for any sections of text.
Simple example attached - it only changes the text colour, but should get you started (setting styles isn't much different.)


[attachment deleted by admin]
No snowflake in an avalanche feels responsible.

Roger

Tedd,

Thank you for the enlightenment and the code suggestion, I can now proceed onwards.

The next stages are:-
1 Serial link
2 Forth compiler/interpreter

I will keep every one posted with any progress.

Regards Roger