Solved

Disableing CEdit controls

Posted on 1998-09-10
8
353 Views
Last Modified: 2008-03-03
I would like to create a property page with mulitple CEdit objects it. How can I disable/enable the CEdit controls dynamically?  I have tried EnableWindow() but it has no effect.
0
Comment
Question by:tdsrick
8 Comments
 

Author Comment

by:tdsrick
Comment Utility
Adjusted points to 200
0
 

Author Comment

by:tdsrick
Comment Utility
Edited text of question
0
 
LVL 2

Expert Comment

by:warmcat
Comment Utility
tds,

*Where* did you do the EnableWindow(FALSE); ?  Override WM_INITDIALOG and stick one at the end of that.  See if it works then.

Regards,

-Andy
0
 
LVL 22

Expert Comment

by:nietod
Comment Utility
EnableWindow() should work.  As warmcat suggested, you may be using it at the wrong time, or, as is often the case, you may be using it on the wrong window handles.
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 7

Expert Comment

by:psdavis
Comment Utility
I agree, if you did it in your constructor, then you're just Enabling a null window.

Phillip

0
 
LVL 1

Accepted Solution

by:
cmain earned 200 total points
Comment Utility
Hi,
You can try these suggestions. I have tested both, and they definitely work.

m_Edit.EnableWindow(FALSE);
I have tried it myself on a property sheet and it seems to work.
Another method you could try is.
m_Edit.SetReadOnly(TRUE);

One way to check if it will work is to do the following.
ASSERT(m_Edit.GetSafeHwnd())
That will throw an exception if the window handle for the edit control is in a state in which the above methods will fail.

If the above line works and you still cannot disable the window (button) then I'll eat my hat.

You will then need to move your code around to find an appropriate place for it.
0
 
LVL 22

Expert Comment

by:nietod
Comment Utility
So what was the problem?
0
 

Author Comment

by:tdsrick
Comment Utility
I it seems that I must be using EnableWindow at the wrong time.  Certainly using it in the constructor si wrong as psdavis pointed out.  In the real application I am programming for, I have written a function that gets called from the main body of an application (this is part of the applications API) so I don't know the exact timing when I get called and I don't have access to the OnInitDialog event.  I had tried calling Enable Window from an OnInitDialog in some sample code where I had full control and it didn't work.  I may have done something wrong but I'm not sure what it would be.  I will have to test some more. cmain's cooment about the ASSERT is very useful (as is everyone else's) but my code is going into a DLL and the main program hasn't been compiled with the debugging options.  All comments have been greatly appreciated.  I'm new to MFC programming though I've worked with other windowing systems.  Some allow you to make changes to the window state even before the real window is realized, then apply the changes at creation time...obviously MFC doesn't do that.   Thanks.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

763 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now