[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Disableing CEdit controls

Posted on 1998-09-10
8
Medium Priority
?
368 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
[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
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
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 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.

656 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