Pelles C forum

C language => Beginner questions => Topic started by: rp108 on August 22, 2014, 03:07:27 AM

Title: How to set foreground and background colors on Edit Box and Text Box
Post by: rp108 on August 22, 2014, 03:07:27 AM
Hi All,

I found some references on the MS Win32api pages but they seemed to be oriented to the MFC and I was not able to figure how to untangle them to use in Pelles C - which I have found to be wonderfully CLEAN.

Any help is much appreciated.   :)

Thanks,
rp108

NOTE: I am developing a Dialog-based app. What I mean by "Text Box" is using the drag and drop Pelles feature for text display, just as a label, and "edit Box" I mean where the user enters text.
Title: Re: How to set foreground and background colors on Edit Box and Text Box
Post by: Robert on August 22, 2014, 09:48:20 AM
Have a look at ctlcolor.zip in the Windows Samples/Windows Programming section of the Pelle's C Samples page at

http://www.smorgasbordet.com/pellesc/sourcecode.htm
Title: Re: How to set foreground and background colors on Edit Box and Text Box
Post by: TimoVJL on August 22, 2014, 02:35:23 PM
Look here (http://msdn.microsoft.com/en-us/library/windows/desktop/bb761691(v=vs.85).aspx)
Title: Re: How to set foreground and background colors on Edit Box and Text Box
Post by: rp108 on August 22, 2014, 05:04:39 PM
Thanks Gentlemen,

In the label-button project, there is a type conditional statement that I don't understand. It appears to be a compile time conditional but I do not understand WHAT is being tested.

#if 0
blah blah blah
#endif

I don't understand WHAT is being tested for:    0

Other than that, I will pare-down the example to only what I need (set color of text and background in a text or edit box), and see if I can get it running.

Can you tell me about the  #if above, please?

Thanks,
rp108

Title: Re: How to set foreground and background colors on Edit Box and Text Box
Post by: frankie on August 22, 2014, 05:25:50 PM
#if 0
..... //Test code that will never be compiled
#endif

It's a common practice to insert test code (or other optional code) that can be compiled only by manually enabling it changing the test condition to #if 1
#if 1
..... //Test code that will be compiled
#endif

It is more convenient that using // or /* ... */ (that can create problems with other comment, line extensions using backslash, etc).

PellesC IDE provides in context menu->surround by the option to surround selected lines with an #if0 ... #endif construct (context menu in source editor is triggered by right clicking).
Title: Re: How to set foreground and background colors on Edit Box and Text Box
Post by: rp108 on August 22, 2014, 05:34:51 PM
Thanks Frankie.