Solved

Disableing CEdit controls

Posted on 1998-09-10
8
360 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
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
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
 
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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
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 user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

831 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