473,383 Members | 1,803 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Enabling/disabling a control

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
Jan 26 '07 #1
5 1403
"Chris Saunders" <ev**@mountaincable.netwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
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

Jan 26 '07 #2
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.
>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

Jan 26 '07 #3
>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
Jan 26 '07 #4
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

"David Lowndes" <Da****@example.invalidwrote in message
news:rc********************************@4ax.com...
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

Jan 26 '07 #5
My thanks again to David Lowndes.

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

Regards
Chris Saunders

"Chris Saunders" <ev**@mountaincable.netwrote in message
news:Ou**************@TK2MSFTNGP03.phx.gbl...
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

"David Lowndes" <Da****@example.invalidwrote in message
news:rc********************************@4ax.com...
>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


Jan 26 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: HumptyDumpty | last post by:
Does anyone know if there is a problem with re-enabling the Screen Saver after it has been disabled programmatically. I am using the SystemParametersInfo function within User32.dll, and have...
2
by: mitzie | last post by:
Is it possible to enable and disable check box of active record using a continuous form? The problem with what I have done is if user entered multiple records, then clicked 1st option box, all...
7
by: Vignesh | last post by:
I have tab control which has some TabPages. I want to enable or disable the tabpages based on some condition. It is possible to that. Thanks in advance.
0
Ali Rizwan
by: Ali Rizwan | last post by:
Hi, How can i control my devices using vb6. Like disabling mouse keyboard speakers etc. Thanx
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.