Solved

Disableing CEdit controls

Posted on 1998-09-10
8
355 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
ID: 1172454
Adjusted points to 200
0
 

Author Comment

by:tdsrick
ID: 1172455
Edited text of question
0
 
LVL 2

Expert Comment

by:warmcat
ID: 1172456
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
ID: 1172457
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 7

Expert Comment

by:psdavis
ID: 1172458
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
ID: 1172459
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
ID: 1172460
So what was the problem?
0
 

Author Comment

by:tdsrick
ID: 1172461
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Want to delete all my personal data 13 137
Getting IP address 8 71
I could not build boost code, 10 78
Microsoft C++ code failing in executable that worked 9 84
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 …
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 use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

914 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

14 Experts available now in Live!

Get 1:1 Help Now