• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 372
  • Last Modified:

Disableing CEdit controls

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
tdsrick
Asked:
tdsrick
1 Solution
 
tdsrickAuthor Commented:
Adjusted points to 200
0
 
tdsrickAuthor Commented:
Edited text of question
0
 
warmcatCommented:
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
nietodCommented:
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
 
psdavisCommented:
I agree, if you did it in your constructor, then you're just Enabling a null window.

Phillip

0
 
cmainCommented:
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
 
nietodCommented:
So what was the problem?
0
 
tdsrickAuthor Commented:
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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