?
Solved

VC++ Read-only Controls

Posted on 2003-02-26
5
Medium Priority
?
847 Views
Last Modified: 2007-12-19
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
Comment
Question by:mrleemon
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 32

Accepted Solution

by:
jhance earned 120 total points
ID: 8027255
Use the EnableWindow() member function.

object->EnableWindow(TRUE);  // control is editable
object->EnableWindow(FALSE); // control is read only
0
 

Author Comment

by:mrleemon
ID: 8032022
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
 

Author Comment

by:mrleemon
ID: 8032263
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
 
LVL 32

Expert Comment

by:jhance
ID: 8032351
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
 
LVL 11

Expert Comment

by:bcladd
ID: 9846916
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question