G
Guest
I am trying to create a application with no UI that I can run as a background application.
The catch is that the application adds an icon to the taskbar and I need to be able to get a icon click event when the user clicks the icon. Someone pointed out that with out a form there is no Windows Message Pump and I woudl not get any events. So I need that pump and I can't see any other way to have a message pump than creating my own. So I gave it a shot:
public void MessagePump()
{
do
{
MSG msg = new MSG();
if ( PeekMessage( ref msg, 0, 0, 0, (int)PeekMessageOption.PM_REMOVE ) )
{
TranslateMessage( ref msg );
DispatchMessage( ref msg );
}
Thread.Sleep( 200 );
}while( true );
}
Unfortunately I am getting no events when I click on the icon at all. Does anyone have any ideas as to what I could be missing?
Note, I can get the event fine if I use a form, so it is not that the code is not getting the event at all, it's that my pump is not working.
Thanks
The catch is that the application adds an icon to the taskbar and I need to be able to get a icon click event when the user clicks the icon. Someone pointed out that with out a form there is no Windows Message Pump and I woudl not get any events. So I need that pump and I can't see any other way to have a message pump than creating my own. So I gave it a shot:
public void MessagePump()
{
do
{
MSG msg = new MSG();
if ( PeekMessage( ref msg, 0, 0, 0, (int)PeekMessageOption.PM_REMOVE ) )
{
TranslateMessage( ref msg );
DispatchMessage( ref msg );
}
Thread.Sleep( 200 );
}while( true );
}
Unfortunately I am getting no events when I click on the icon at all. Does anyone have any ideas as to what I could be missing?
Note, I can get the event fine if I use a form, so it is not that the code is not getting the event at all, it's that my pump is not working.
Thanks