Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 881
  • Last Modified:

VC++ Read-only Controls

How do I make CComboBox and CDateTimeCtrl controls to appear read-only (that is, greyed background and unchangable)?

CEdit's have a nice SetReadOnly() method, but the best I can do for combos and date pickers is to disable them - yuk!

Hope you can help,

Mr Leemon.
0
mrleemon
Asked:
mrleemon
  • 2
  • 2
1 Solution
 
jhanceCommented:
Use the EnableWindow() member function.

object->EnableWindow(TRUE);  // control is editable
object->EnableWindow(FALSE); // control is read only
0
 
mrleemonAuthor Commented:
jhance,

your suggestion is what I was talking about when I said I could disable them.

Unfortunately, it does not give me what I want.  Disabling a control makes any text in it appear grey.  Is there any way of locking the control so that the background is grey but the text stays black?

Any suggestions short of writing my own control, please!

LMN.
0
 
mrleemonAuthor Commented:
jhance,

your suggestion is what I was talking about when I said I could disable them.

Unfortunately, it does not give me what I want.  Disabling a control makes any text in it appear grey.  Is there any way of locking the control so that the background is grey but the text stays black?

Any suggestions short of writing my own control, please!

LMN.
0
 
jhanceCommented:
How the individual controls respond to being disabled (i.e. put into read-only) mode is up to the individual controls.

So if you don't like the behavior of a specific control in this respect, you must either override that behavior or write your own control.
0
 
bcladdCommented:
No comment has been added lately, so it's time to clean up this TA. I will
leave a recommendation in the Cleanup topic area that this question is:

Answered: Points to jhance: Grade A

Please leave any comments here within the next seven days.

Experts: Silence means you don't care. Grading recommendations are made in light
of the posted grading guidlines (http://www.experts-exchange.com/help.jsp#hi73).

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

-bcl (bcladd)
EE Cleanup Volunteer
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now