NO

Author Topic: How to set foreground and background colors on Edit Box and Text Box  (Read 3210 times)

rp108

  • Guest
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.

Offline Robert

  • Member
  • *
  • Posts: 247
Re: How to set foreground and background colors on Edit Box and Text Box
« Reply #1 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

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2115
Re: How to set foreground and background colors on Edit Box and Text Box
« Reply #2 on: August 22, 2014, 02:35:23 PM »
Look here
May the source be with you

rp108

  • Guest
Re: How to set foreground and background colors on Edit Box and Text Box
« Reply #3 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


Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2113
Re: How to set foreground and background colors on Edit Box and Text Box
« Reply #4 on: August 22, 2014, 05:25:50 PM »
Code: [Select]
#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
Code: [Select]
#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).
« Last Edit: August 22, 2014, 05:28:46 PM by frankie »
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide

rp108

  • Guest
Re: How to set foreground and background colors on Edit Box and Text Box
« Reply #5 on: August 22, 2014, 05:34:51 PM »
Thanks Frankie.