|
-
Jun 27th, 2011, 03:10 AM
#1
Thread Starter
New Member
AppActivate problem in Windows 7
I am testing an application developed using VB6 on a computer with Windows 7. That application uses AppActivate in order to activate MS Excel so the user can select a cell and then go back to my application. The problem is with Windows 7, because AppActivate keeps Excel flashing in the task bar and the expected behavior was that the Excel main window became the top window with the focus on it. The same code works as expected with Windows XP.
Does anybody know if there is a workaround for Windows 7?
Thank you in advance for your help.
-
Jun 27th, 2011, 07:00 AM
#2
Re: AppActivate problem in Windows 7
You may need to use SetForegroundWindow api:
Sample 1
Sample 2
-
Jun 27th, 2011, 09:59 AM
#3
Thread Starter
New Member
Re: AppActivate problem in Windows 7
 Originally Posted by RhinoBull
Thank you for your suggestions.. but no luck , both approaches work well on XP but neither of them on W7.
Sample1 - ForceForegroundWindow on W7 simply does nothing
Sample2 - What I get after executing RestoreWindow is a flashing window in the task bar, exactly the same behavior than AppActivate
-
Jun 28th, 2011, 12:23 PM
#4
Re: AppActivate problem in Windows 7
This one:
http://vb.mvps.org/samples/ForceFore/
Works for me on Windows7 Profession 32-bit - it is by the same author in the first link (PDF), but maybe he updated it on his website? I didn't compare the code.
If it doesn't work for you - what version of Windows 7 are you using?
-
Jun 30th, 2011, 03:22 AM
#5
Thread Starter
New Member
Re: AppActivate problem in Windows 7
 Originally Posted by jpbro
This one:
http://vb.mvps.org/samples/ForceFore/
Works for me on Windows7 Profession 32-bit - it is by the same author in the first link (PDF), but maybe he updated it on his website? I didn't compare the code.
If it doesn't work for you - what version of Windows 7 are you using?
Yes, that sample application works for me too.
Then the problem may be my app, because I copied the same code and the result is the flashing window in the task bar.
This extrange behaviour happens with W7 64-bit.
I'll review my code for 64-bit.
-
Jun 30th, 2011, 11:45 AM
#6
Re: AppActivate problem in Windows 7
Question: Why do you need to select a cell in the first place? Depending upon your needs, you could acess the cell's value using Excel Automation and end up with something like...
Text.Text = oCell.Value 'etc where oCell is instanciated with code.
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Jun 30th, 2011, 12:12 PM
#7
Thread Starter
New Member
Re: AppActivate problem in Windows 7
 Originally Posted by RobDog888
Question: Why do you need to select a cell in the first place? Depending upon your needs, you could acess the cell's value using Excel Automation and end up with something like...
Text.Text = oCell.Value 'etc where oCell is instanciated with code.
Because first the user selects an element data in my app, then my app activates Excel and the user picks a cell where he wants to copy the data. The "selection changed" event causes the data being copied, and my app is activated again, allowing the user to select another data, and so on.
-
Jun 30th, 2011, 02:22 PM
#8
Re: AppActivate problem in Windows 7
Ok then perhaps it might be easier to do it all in VBA so you can use an Excel UserForm? Then there wont be any back and forth focus issues but this depends upon your source app.
If you are just doing SetForegroundWindow you may need to check first if your window is minimized (IsIconic) first. If it is then restore the window and THEN set it with SetForegroundWindow.
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Jul 1st, 2011, 01:31 AM
#9
Thread Starter
New Member
Re: AppActivate problem in Windows 7
Thanks for the info RobDog888
I am trying several approaches, focused in W7 64-bit
If I find a sucessfull solution I'll tell you in this thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|