Windows 7, VB6, Launcher App and Pinning to the Taskbar - vb6

We have an application that has a "launcher" app that sits there with a pretty UI while the main app loads in the background. Both of these apps are written in VB6 (sigh).
In Windows 7, if user's pin the launcher program, we get two different icons on the taskbar (one for the main app, and then the pinned icon for the launcher program). This looks very odd.
I've tried using the following function: http://msdn.microsoft.com/en-us/library/dd378422%28VS.85%29.aspx to no avail so far.
I gave both the same name (Company.Product), as advised in the documentation, and before any UI pops up. If I pin the launcher app while it is running, this works fine. If I pin the executable for the launcher, I get two icons.
Any ideas on how to fix it such that I can users could just pin the launcher exe and all is good?

Why have two separate executables (particularly when they are written in the same language). Why not merge the launcher in with the "main application" and do some threading to have the main app actually start while the launcher is displaying a title screen, etc. There are number of tutorials for creating launchers.

Make it so your main app doesn't show up in the taskbar and make it so when launcher is clicked in the taskbar it will send a message to the main window to appear if it is minimized. This can be achieved with Windows API.
Use FindWindowEx to get a handle for the main window then send a WM_SYSCOMMAND message with SC_RESTORE.

Related

Setting foreground window with Windows scheduled task

I build a fullscreen GUI application for Windows (using LabVIEW but the language should not matter much) that should start with Windows.
I want it to be fullscreen (hiding the Windows taskbar), so I set the window bounds to the screen's resolution.
When I manually launch the exe from explorer, the window hides correctly the taskbar.
But when I launch it from a scheduled task at Windows logon, it is behind the taskbar, until I click on the application. Same thing when I run the scheduled task manuallay in the task scheduler.
I tried the Win32 API function SetForegroundWindow but without success. Maybe the conditions are not met but I do not understand why, there is no other visible window.
How could I force the fullscreen of the app when it auto-starts?
If this is impossible from the application itself, an external solution to the application's code might be ok (e.g. some script running with the scheduled task), but I don't see one either.
Hey so I was having the same trouble when I scheduled a full screen application to run at login. the way I got around this was by creating a mouse click macro and scheduling it at user login with the app (had to set a 10 second delay to allow for the app to load).
It's a bit dodgy but it got it done for me

Disabling Windows 10 Game Bar for specific application

In some conditions the Windows 10's game bar opens up with my application (made with Delphi, VCL). Thats not a game and i don't directly use DirectX or OpenGL, but it opens up.
To be specific, when i reduce to tray my app and a popup is opened the Game Bar appears.
I found a numbers of sites with tutorial for totally disable the Windows 10 game bar (like this) but i want to disable for my application only, i don't think users will be happy to have a windows feature silently disabled by my app
Is this possible? I cannot find any documentation about it
You can disable it following this solution :
Press Win+G, click the Gear icon (Settings) and uncheck "Remember this is a game" (https://superuser.com/questions/1086248/windows-10-xbox-dvr-app-thinks-chrome-is-a-game).
Note that if the name of the application is Main.exe, this checkbox is not visible.
If the name of the app is main.exe or anything else, it is visible.
It seems it is stored in the registry : HKEY_CURRENT_USER\System\GameConfigStore\ in the Children and Parents directories.
You can try to find your app using the ExeParentDirectory key.
https://www.reddit.com/r/ffxiv/comments/3fbu0x/win_10_game_bardvr_anyone_having_issues/
I don't know if it applies to an executable where Windows decides it is a game (like Main.exe)

Metro to desktop to metro.. API?

On Windows 8 they've replaced the Start Menu with a Start Screen using Metro GUI.
Desktop applications can be run from this screen, but when they exit the user is left at the desktop.
Is there a Windows setting that will return to the Start Screen automatically when the application is closed, if it was launched from Metro?
Or is there an API available so that the application itself can detect whether it was launched from Metro and then switch back to it as it is shutting down?
(I want something automatic or programmatic. "Press the Windows key" is not an acceptable solution.)
Window 8 metro GUI is working like Start menu so I will change my application's setup program to put some command line options for desktop menu shortcut and pick it up from Param array.
When closing I would try sending Windows button combination (Ctrl+Esc) to windows. Actual code to do that depends on the language used to develop your app. If developed in .Net following class can be helpful
System.Windows.Forms.SendKey.Send
http://msdn.microsoft.com/en-us/library/system.windows.forms.sendkeys.send.aspx
following library may also be useful
http://inputsimulator.codeplex.com/

Start external exe within own process

I have a VB6 executable we use as a Starter executable for our real program.
The problem is that windows 7 shows a new icon in the taskbar for the new process, instead of the one i clicked on to start my program (of course, because the starter exe has already ended, and the new exe seems to be a new program).
Currently I use the Shell object to start the other exe. Is there a better way to do it from vb6, maybe by using a native C function with declare that does start an exe in the current process, without spawning a new process?
EDIT:
Thanks to atzz for the great information about Application Model IDs. I now have a shortcut to my app starter with a well defined id, and my app also sets the ID when started, and is now accesssible beautifully from the right icon in the toolbar. However, two problems persist:
The app is a Java App started with Exe4J, and I don't have any chance to set the AppID before Exe4J shows the splash screen, so while showing the splash screen there is a second icon in the taskbar.
If I don't manually drag my starter app icon from the Desktop to the toolbar, but instead use my apps icon and set it to be "sticky", the real app is sticked, and not the launcher.
Both problems would be beautifully solved if my launcher would start the app from within its own process. I heard something of using exec() instead of fork() for linux programs to achive this... is there something similar for windows?
I believe there is a way to accomplish what you need via Windows 7 taskbar API, though I never did it myself and thus don't remember clearly enough what I've read on the subject. Look around the Application ID concept.
Some links:
Developing for the Windows 7 Taskbar – Application ID
Inside Windows 7 - Introducing The Taskbar APIs
If the problem is the icon, why not give both programs the same icon (and the same App.Title). Then the user won't be able to tell the difference between the two taskbar entries. Presumably they aren't both visible at the same time.
Alternatively set your starter app not to appear in the taskbar (Form property ShowInTaskbar = False in the design view)

Vista Window Focus Problem

I have an application that manages patient demographic information. Along with this data a user can scan a picture of a patient and assign that picture to a patient. When the user clicks the scan button a separate application is opened as a dialog in order to scan the image. When running this on XP everything worked fine. The imaging application loaded up fine and gained focus. On Vista however occasionally the imaging application will not gain focus and will popup behind the main application. When running full screen or through 2008 Application Server you cannot see the application, you only get a locked screen and it appears nothing has happened. Is there any way to change the window focus management on Vista to work the way XP did? I'm looking for a way to solve this without making changes to the actual application if possible.
I think you will have to make changes to your application to allow the imaging application to take the focus. I'm going to assume that your application launches the imaging application through ShellExecute or CreateProcess. If so, you can get the process handle of the launched process either through SHELLEXECUTEINFO.hProcess (for ShellExecute) or PROCESS_INFORMATION.hProcess (for CreateProcess). Immediately after launching the imaging application call the AllowSetForegroundWindow API:
AllowSetForegroundWindow(GetProcessId(hProcess));
This will allow the imaging application to place its main window/dialog in the foreground when it's starting up.
You could try the following steps:
1. Right Click on the exe
2. Select Properties
3. Select the Compatibility Tab
4. Check the Run this program in campatibility mode for:
5. Select Windows XP (Service Pack 2)
You could iterate through all top level HWNDs and identify the scanning application via its window class, then send an appropriate message to raise the window.
I don't believe this is Vista vs XP related. I think that simply this imaging app takes longer to start on Vista.
Since Windows 2000, the window manager has prevented background applications stealing the foreground. When an application is launched, it has a window of opportunity to create and show a window that will take the foreground. If it takes too long, the window manager thinks that the current window should keep the foreground, and inhibits the other app taking the foreground when it does finally launch.
I can't think of any specific way to avoid this... other than using FindWindow to search for the other apps window after launching the app. When you eventually find it, call SetForegroundWindow on it to bring it to the foreground.

Resources