Call external gps app from VB.NET in CF 3.5 and return back to VB.NET app
I am writing an application in VB.NET that allows the user to call Garmin Mobile XT to get directions.
I have a form that stays open for Garmin and after exiting Garmin allows the user to return.
Sometimes, however, this form is automatically hidden by the WM OS.
Any ideas on how I can get the form to stay in place - or can I put a check on my app launch to check if the app is running and the form is hidden and return the form to the top?
I tried setting the TopMost form, but that means the GPS application cannot be seen as my form is the very top one above the GPS application.
I tried to catch the closure handler for the form, but that doesn't work - I would guess because WM OS just hides the form and doesn't actually close it.
I tried catch on the Deactivate handler form to prevent loss of focus, but that does the same as the TopMost property and I can't see the GPS app.
Any ideas on where I can go from here as I don't really have a clue!
Thanks Adam
I believe that this should be done, as in "normal" VB / VBA, through the OS API. Get the winAPI help file :-).
Now I suggest your app to repeat all windows, find your GPS app using:
HWND FindWindow (
LPCTSTR lpClassName, // pointer to class name LPCTSTR lpWindowName // pointer to window name );
and then you can either change your Z-order (put it above or below some other specific wind):
BOOL SetWindowPos (
HWND hWnd, // handle of window HWND hWndInsertAfter, // placement-order handle int X, // horizontal position int Y, // vertical position int cx, // width int cy, // height UINT uFlags // window-positioning flags );
or just ask it to restore (which should automatically bring it to the highest Z-order) using:
BOOL SetWindowPlacement (
HWND hWnd, // handle of window CONST WINDOWPLACEMENT *lpwndpl // address of structure with position
);
source to share