Make form deactivate itself?

  • Thread starter Thread starter Andrew Morton
  • Start date Start date
A

Andrew Morton

Is it possible to make a form deactivate itself without minimizing it?

I have written a small utility which copies selected files from CDs
(hundreds of them). I put a CD in the tray and click a button on the form to
tell it the next CD is ready for it to process. Each CD takes a few minutes
to copy, and the form has a textbox at which I glance to see the progress. I
have the form sending itself to the back, but it would be nice if it would
also relinquish focus to the previously active window.

..NET 1.1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Form.ActiveForm.SendToBack()
Form.ActiveForm.Deactivate() ' no such method :-(
' process CD

Only a few hundred more CDs to do...

Andrew
 
Andrew Morton schreef:
Is it possible to make a form deactivate itself without minimizing it?

I have written a small utility which copies selected files from CDs
(hundreds of them). I put a CD in the tray and click a button on the form to
tell it the next CD is ready for it to process. Each CD takes a few minutes
to copy, and the form has a textbox at which I glance to see the progress. I
have the form sending itself to the back, but it would be nice if it would
also relinquish focus to the previously active window.

.NET 1.1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Form.ActiveForm.SendToBack()
Form.ActiveForm.Deactivate() ' no such method :-(
' process CD

Only a few hundred more CDs to do...

Andrew

form.enabled=false
 
C-Services Holland b.v. said:
Andrew Morton schreef:

form.enabled=false

No, that doesn't work, it just disables the form while leaving it as the
active window and the only way to close it then is through the Task Manager
:-(

Andrew
 
Andrew Morton schreef:
No, that doesn't work, it just disables the form while leaving it as the
active window and the only way to close it then is through the Task Manager
:-(

Andrew

Well, how is the form displayed? If it's by using .showdialog(), then
what you want is not possible because that dialog is then modal.
 
C-Services Holland b.v. said:
Andrew Morton schreef:


Well, how is the form displayed? If it's by using .showdialog(), then
what you want is not possible because that dialog is then modal.

It's a simple Windows application. I couldn't find anything in the Windows
API docs on the MSDN website - although that doesn't mean there isn't
anything. Maybe there's a more relevant newsgroup for me to ask in?

I've done a couple of screen-grabs of what to show what does and what I'd
like to happen:
http://www.in-press.co.uk/windowsample/windowsample.html (22KB)

There's only about 100 CDs left to do now, so there's no need for a solution
any more.

Andrew
 
Andrew said:
It's a simple Windows application. I couldn't find anything in the
Windows API docs on the MSDN website - although that doesn't mean
there isn't anything.

For the benefit of anyone reading this in the future...

As I reach the end of the task, I found the GetWindow function in
user32.dll, with which I could have retrieved the window handle to the next
window in z-order (i.e. the previously activate one) so, with the handle, I
would have been able to activate that window.

Andrew
 
Back
Top