How to do a Task Manager 'Switch To'?

N

N M

Hi all,

I've been scratching my head (to the bone) try to find a way of
switching from one .Net application to another. ie. I click a button
on a controller application and the other one is brought to the front.

I even have a Process object pointing to the application I want to
activate, but I can't seem to find any way of using this.

The purpose of the controller application is to provide a single
interface to launch/terminate/switch to a suite of programs without
having loads of applications in either the task bar or the system
tray.

Herein lies the problem. In order to hide the application when it is
minimised, I have to either sets its ShowInTaskBar property to false
or just hide it. The trouble is, when you do this you lose the handle
as there isn't a window anymore. I tried using the API calls
(ShowWindow or SetForegroundWindow) using the Process.MainWindowHandle
property, but as I mentioned it's set to 0 when the form is hidden.

Does anyone have any ideas how to proceed with this? The only other
way I thought of doing this was to send a message directly to the
hidden application telling it to make itself visible and restore its
window position. Now comes the second problem...how do I do this? I
don't want to get into sockets, etc. as it is all local to the one
machine. Message queues would be another alternative, but I'd prefer
to use something that doesn't have to be installed separately to a
standard framework installation.

There is a fair chance I'm missing something pretty obvious here, but
please...feel free to point it out. :)

Thanks in advance,

Neill.


______________________________________________
WORK: N M @ R C S S o f t w a r e . c o . u k
HOME: n e i l l . i m m o r t a l @ B T I n t e r n e t . c o m
WEB: www.neill.immortal.btinternet.com
 
F

Fergus Cooney

Hi Niall,

In case you're not watching the thread, there's an answer to your previous
post under the topic "Starting and Ending Processes from a program".

Regards,
Fergus
 
L

Lifeng Lu

You can get the idea how to make your app not on the tast bar from MSDN:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/pla
tform/shell/programmersguide/shell_int/shell_int_programming/taskbar.asp

The Shell creates a button on the taskbar whenever an application creates a
window that isn't owned. To ensure that the window button is placed on the
taskbar, create an unowned window with the WS_EX_APPWINDOW extended style.
To prevent the window button from being placed on the taskbar, create the
unowned window with the WS_EX_TOOLWINDOW extended style. As an alternative,
you can create a hidden window and make this hidden window the owner of
your visible window.

If you want to send a message to your application on the same computer, the
easiest way is to send/post a user-defined message to one window of your
application, and your application could handle this message and do what it
need to do.

Hope it will resolve your problem

Thanks
Lifeng
Microsoft VB team.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top