Archived

This topic is now archived and is closed to further replies.

Tonic151

Win console, Minimize to System Tray

Recommended Posts

Hi,, i do a lot of programming in normal console mode.. and i'm looking for some working examples of how to minimize my program to teh system tray.. i've done a bunch of search's but all i come up with is needing windows message handling.. and MFC stuff.. would anyone have anything that specificly works for a console app.. i'd be mucho apprecieated!!' I'm programming in a mix of c/c++ using DevC++ g++ 2.59.3 compiler... [edited by - Tonic151 on August 31, 2003 6:57:33 PM]

Share this post


Link to post
Share on other sites
quote:
Original post by C-Junkie
No, for a console app.

For a windows app, it involves hiding your windows and creating an icon in the tray with something like ShellNotifyIcon or something


dam theres no hack or anything of the sort to acomplish this?? anyone else ever try to get this working?

Share this post


Link to post
Share on other sites
quote:
Original post by DukeAtreides076
I think if you have XP or 2k you can get a HANDLE to the console window...and then you can hide it.


i''ve looked into it. but it needs a windows message handler to get the systemtray icon clicks.. any god way about writting one seperate from winmain since i use main()...

Share this post


Link to post
Share on other sites
Here''s some code for getting the handle to the console window on W9x. YMMV



////////////////////////////////////////////////////////////////////////

// G E T C O N S O L E H A N D L E 9 X ------------------------------

HWND __stdcall GetConsoleWindow9X(void)
{

HWND hConWnd = NULL;
WIN32_FIND_DATA fd;
HANDLE ff;

static TCHAR szTempTitle[] = TEXT("MyWin9xConsole");
static TCHAR szTempString[MAX_PATH];

if( GetConsoleTitle(szTempString, sizeof(szTempString)/sizeof(TCHAR) ) > 0 )
{
SetConsoleTitle(szTempTitle);
hConWnd = FindWindow(TEXT("tty"), szTempTitle);
SetConsoleTitle(szTempString);
}

// fallback method - could be written differently

if ( !hConWnd )
{
ZeroMemory(&szTempTitle, sizeof(szTempTitle) );
if ( GetModuleFileName(NULL, szTempString, MAX_PATH) > 0 )
{
ff = FindFirstFile(szTempString, &fd);
if ( ff != INVALID_HANDLE_VALUE )
{
ZeroMemory(&szTempString, sizeof(szTempString) );
for ( int i = 0; fd.cFileName[i] != ''.''; i++ )
{
szTempString[i] = fd.cFileName[i];
}
hConWnd = FindWindow(TEXT("tty"), szTempString);
}
FindClose(ff);
}
}
return( hConWnd );
}

Share this post


Link to post
Share on other sites