Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / January 2007

Tip: Looking for answers? Try searching our database.

Enabling/disabling a control

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Chris Saunders - 26 Jan 2007 07:20 GMT
I'm hoping that this question is not off topic on this newsgroup.  If it is
please redirect me if you know an appropriate group.  I'm actually writing a
program in another language (Eiffel) but if I can learn how to accomplish
this in C I can convert the solution.  What I wish to do is use
PostThreadMessage() to send a message to a control so that it will become
enabled/disabled.  Reading the documentation on WM_ENABLE leads me to
believe that this message will not accomplish this.  Can anyone assist?

Regards
Chris Saunders
William DePalo [MVP VC++] - 26 Jan 2007 07:57 GMT
> I'm hoping that this question is not off topic on this newsgroup.  If it
> is please redirect me if you know an appropriate group.

You may want to post follow-up in the user interface group

   microsoft.public.win32.programmer.ui

but SDK questions are not unheard-of in here.

> I'm actually writing a program in another language (Eiffel) but if I can
> learn how to accomplish this in C I can convert the solution.

OK.

> What I wish to do is use PostThreadMessage() to send a message to a
> control so that it will become enabled/disabled.  Reading the
> documentation
> on WM_ENABLE leads me to believe that this message will not accomplish
> this.  Can anyone assist?

What you do is to pass the handle to the control to EnableWindow(). If you
don't have a handle to the control but you now its ID and the handle to its
parent, you call GetDlgItem() first whether or not the parent is a dialog.
That will get a handle which you can enable.

The message you found is a noticication that actually comes of changing the
enabled state of the window.

Regards,
Will

www.ivrforbeginners.com
Chris Saunders - 26 Jan 2007 09:44 GMT
First, thanks for the response Will.  I'll continue posting here as your
response dosn't make that seem objectionable and I see no one else posting
"off-topic" messages.  The first thing that I attempted to do was just what
you suggested - I was searching in the MSDN documentation and came across
EnableWindow() but that was not working for me.  Since this application is
not written in C so I was reluctant to discuss it too much but I guess I
described too little.

In my application I am launching a thread procudure and am then attempting
to change the enabled state of some controls on my main window (not a
dialog).  I know that on windows the state of controls is not supposed to be
altered by a separate thread.  In C# I have seen code that overcomes this
restriction but I cannot access C# code from Eiffel very easily - however I
can access C Windows API functions easily.

This is why I was hoping to use PostThreadMessage() as EnableWindow() is
doing nothing when called from my thread function.  In Eiffel I do have
access to the handles (HWND) of the controls I am using.

Do you have any ideas on how I might overcome this?

Thanks again and regards
Chris Saunders

> OK.
>
[quoted text clipped - 16 lines]
>
> www.ivrforbeginners.com
David Lowndes - 26 Jan 2007 10:55 GMT
>In my application I am launching a thread procudure and am then attempting
>to change the enabled state of some controls on my main window (not a
>dialog).  I know that on windows the state of controls is not supposed to be
>altered by a separate thread.

Chris,

From your thread, post a user defined message (use PostMessage not
PostThreadMessage) to your main window and in your main window handle
that message and call EnableWindow.

Dave
Chris Saunders - 26 Jan 2007 12:48 GMT
Thanks Dave

This will be complicated to do from Eiffel but I think I know how to
accomplish this.  I've been up all night (its 7:45 AM here) and I think I
need to try and get some sleep.  After I have tried this I'll reply with my
results.  I may have further questions.

Regards
Chris Saunders

> >In my application I am launching a thread procudure and am then
> >attempting
[quoted text clipped - 10 lines]
>
> Dave
Chris Saunders - 26 Jan 2007 23:12 GMT
My thanks again to David Lowndes.

I tried what you suggested and it succeeded - I very much appreciate your
help.

Regards
Chris Saunders

> Thanks Dave
>
[quoted text clipped - 20 lines]
>>
>> Dave

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.