Results 1 to 10 of 10

Thread: Activate Window

  1. #1

    Thread Starter
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Resolved Activate Window

    I have a form that isn't sizeable, as a background to my app. If the user alt-tabs to a different app, my program is no longer shown in the taskbar, and can only be continued by using the task manager to Switch To.

    I am thinking that I should be able to have the user restart the app to continue, but am having trouble making it so. Right now, if the previous instance of the app is true, I end starting it up again.

    What do I have to do to "switch to" the previous instance? I know it can't be too difficult, but have tried a few different ways, including my find window app to send the wm_activate message to it. That seems kind of overkill.

    Can't I use ME when I restart it to start a previous instance?


    Thanks.
    Last edited by dglienna; Jun 13th, 2005 at 01:32 PM.

  2. #2
    Frenzied Member sciguyryan's Avatar
    Join Date
    Sep 2003
    Location
    Wales
    Posts
    1,763

    Re: Activate Window

    Quote Originally Posted by dglienna
    I have a form that isn't sizeable, as a background to my app. If the user alt-tabs to a different app, my program is no longer shown in the taskbar, and can only be continued by using the task manager to Switch To.

    I am thinking that I should be able to have the user restart the app to continue, but am having trouble making it so. Right now, if the previous instance of the app is true, I end starting it up again.

    What do I have to do to "switch to" the previous instance? I know it can't be too difficult, but have tried a few different ways, including my find window app to send the wm_activate message to it. That seems kind of overkill.

    Can't I use ME when I restart it to start a previous instance?


    Thanks.
    Whay about using FindWindow to get its handel and then using that as the parameter for the SetForegroundWindow to set focus to it?

    Cheers,

    RyanJ
    My Blog.

    Ryan Jones.

  3. #3
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Activate Window

    Is this Form set as the StartUp object? Is it only used as a background, so you always have other forms loaded?

  4. #4

    Thread Starter
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Activate Window

    When I call frmBackgroun as the startup object from Sub Main, it will automatically show frmMain to start the app, so I want to get the previous instance of the program.

    Right now, if i use frmBackground.show, by calling the app again, everything works, except that a new instance of the app starts and the form is shown.

    There are many forms that could be activated when the app is hidden, and I want to always go back to frmBackground.

    SetForeground Window might work, but I'm not sure

  5. #5
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Activate Window

    I might have misunderstood your question but I just don't understand why your Main form isn't available from the taskbar. Maybe you don't want it to be but if you from the background form would call it up like this it would.
    VB Code:
    1. Private Sub Form_Load()
    2.     'frmBackground
    3.     frmMain.Show vbModeless, Me
    4. End Sub

  6. #6
    Frenzied Member sciguyryan's Avatar
    Join Date
    Sep 2003
    Location
    Wales
    Posts
    1,763

    Re: Activate Window

    Quote Originally Posted by dglienna
    When I call frmBackgroun as the startup object from Sub Main, it will automatically show frmMain to start the app, so I want to get the previous instance of the program.

    Right now, if i use frmBackground.show, by calling the app again, everything works, except that a new instance of the app starts and the form is shown.

    There are many forms that could be activated when the app is hidden, and I want to always go back to frmBackground.

    SetForeground Window might work, but I'm not sure

    But by using FindWindow you could use the unique title of that form and set focus to it that way it should always set focus on the one you need

    Cheers,

    RyanJ
    My Blog.

    Ryan Jones.

  7. #7

    Thread Starter
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Activate Window

    Thanks Joacim. I looked at it again, and I had ShowinTaskbar set to False

    I thought that I had checked that. I think this is resolved.

  8. #8
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Activate Window

    It almost sounds like your trying to create your own MDI type app. Maybe, depending on what your actually doing,
    you would be better off using an MDI form.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  9. #9
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Activate Window

    Quote Originally Posted by RobDog888
    It almost sounds like your trying to create your own MDI type app. Maybe, depending on what your actually doing,
    you would be better off using an MDI form.
    I was thinking that it might be more like the old style installers that often had a gradient background. Anyway, thanks for the unexpected reps dg

  10. #10

    Thread Starter
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Activate Window

    Just a full screen app to mimick the old DOS program. Now, they can do other things without losing their work, and I don't have to worry about multiple instances running. This is a point of sale app with 23 forms, and wouldn't work as an MDI app. I thought of it, though. It's menu driven.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width