Make form deactivate itself?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Andrew Morton

    #1

    Make form deactivate itself?

    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(B yVal sender As System.Object, ByVal e As
    System.EventArg s) Handles Button1.Click
    Form.ActiveForm .SendToBack()
    Form.ActiveForm .Deactivate() ' no such method :-(
    ' process CD

    Only a few hundred more CDs to do...

    Andrew


  • C-Services Holland b.v.

    #2
    Re: Make form deactivate itself?

    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(B yVal sender As System.Object, ByVal e As
    System.EventArg s) 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=fa lse


    --
    Rinze van Huizen
    C-Services Holland b.v

    Comment

    • Andrew Morton

      #3
      Re: Make form deactivate itself?

      C-Services Holland b.v. wrote:
      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(B yVal sender As System.Object, ByVal e As
      >System.EventAr gs) Handles Button1.Click
      > Form.ActiveForm .SendToBack()
      > Form.ActiveForm .Deactivate() ' no such method :-(
      > ' process CD
      >>
      >Only a few hundred more CDs to do...
      >
      form.enabled=fa lse
      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


      Comment

      • C-Services Holland b.v.

        #4
        Re: Make form deactivate itself?

        Andrew Morton schreef:
        >form.enabled=f alse
        >
        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.

        --
        Rinze van Huizen
        C-Services Holland b.v

        Comment

        • Andrew Morton

          #5
          Re: Make form deactivate itself?

          C-Services Holland b.v. wrote:
          Andrew Morton schreef:
          C-Services Holland b.v. wrote:
          >>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 :-(
          >
          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/windowsamp...dowsample.html (22KB)

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

          Andrew


          Comment

          • Andrew Morton

            #6
            Re: Make form deactivate itself?

            Andrew Morton wrote:
            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


            Comment

            Working...