Console Program to Tray??????
-
Sorry i no nuderstand any world in Deutch...
-
That was a bot which moved your thread into an other forum...
-
Darez schrieb:
hmm, can You gave some examples??
i can give you an example if you pay me 20 €. :schland:
-
Maybe something like that... i haven't tested it yet....
#include <iostream> #include <windows.h> #include <tchar.h> #include "resource.h" bool AddTrayIcon(UINT, ::HICON, LPTSTR); int _tmain(int argc, _TCHAR* argv[]) { if (argc < 2) { if (!AddTrayIcon(11, ::LoadIcon(0, MAKEINTRESOURCE(IDI_ICON1)), _T("Test"))) return -1; ::ShowWindow(::GetConsoleWindow(), SW_HIDE); } else if(lstrcmp(argv[1], _T("-b"))) { std::cout << _T("Herzlich Willkommen!") << std::endl; } return 0; } bool AddTrayIcon(UINT nID, ::HICON hIcon, LPTSTR lpszTip) { if (!hIcon || !lpszTip) return false; ::NOTIFYICONDATA tnid; tnid.cbSize = sizeof(NOTIFYICONDATA); tnid.hWnd = ::GetConsoleWindow(); tnid.uID = nID; tnid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP; tnid.uCallbackMessage = 0; tnid.hIcon = hIcon; lstrcpy(tnid.szTip, lpszTip); return (::Shell_NotifyIcon(NIM_ADD, &tnid) ? true : false); }
-
Hmmm no problem, thanks for help, i thought that Board it for Helping people, no money...Thanks
many thanks Devil:D
but....Compiling... main.cpp e:\project\main.cpp(620) : error C2039: 'GetConsoleWindow' : is not a member of '`global namespace'' e:\project\main.cpp(620) : error C3861: 'GetConsoleWindow': identifier not found Build log was saved at "file://e:\project\Debug\BuildLog.htm" Test - 2 error(s), 0 warning(s) ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
-
sry ... hatte was vergessen... guck mal unter remarks bei folgendem link:
Referenzen:
GetConsoleWindow
-
Hmmm, I have got added kernel32.lib to project... and wnidows headers...
-
To compile an application that uses this function, define _WIN32_WINNT as 0x0500 or later. For more information, see Using the Windows Headers.
-
right... you should add the following:
#ifndef _WIN32_WINNT #define _WIN32_WINNT 0x0500 #endif #include <iostream> #include <windows.h> #include <tchar.h> #include "resource.h" bool AddTrayIcon(UINT, ::HICON, LPTSTR); int _tmain(int argc, _TCHAR* argv[]) { if (argc < 2) { if (!AddTrayIcon(11, ::LoadIcon(0, MAKEINTRESOURCE(IDI_ICON1)), _T("Test"))) return -1; ::ShowWindow(::GetConsoleWindow(), SW_HIDE); } else if(lstrcmp(argv[1], _T("-b"))) { std::cout << _T("Herzlich Willkommen!") << std::endl; } return 0; } bool AddTrayIcon(UINT nID, ::HICON hIcon, LPTSTR lpszTip) { if (!hIcon || !lpszTip) return false; ::NOTIFYICONDATA tnid; tnid.cbSize = sizeof(NOTIFYICONDATA); tnid.hWnd = ::GetConsoleWindow(); tnid.uID = nID; tnid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP; tnid.uCallbackMessage = 0; tnid.hIcon = hIcon; lstrcpy(tnid.szTip, lpszTip); return (::Shell_NotifyIcon(NIM_ADD, &tnid) ? true : false); }
-
Yes i add it and define alles
main.obj : error LNK2019: unresolved external symbol __imp__Shell_NotifyIconA@8 referenced in function "bool __cdecl AddTrayIcon(unsigned int,struct HICON__ *,char *)" (?AddTrayIcon@@YA_NIPAUHICON__@@PAD@Z) libcpmtd.lib(xdebug.obj) : error LNK2019: unresolved external symbol __malloc_dbg referenced in function "void * __cdecl operator new(unsigned int,struct std::_DebugHeapTag_t const &,char *,int)" (??2@YAPAXIABU_DebugHeapTag_t@std@@PADH@Z) libcpmtd.lib(xdebug.obj) : error LNK2019: unresolved external symbol __free_dbg referenced in function "void __cdecl operator delete(void *,struct std::_DebugHeapTag_t const &,char *,int)" (??3@YAXPAXABU_DebugHeapTag_t@std@@PADH@Z)
i am learniing vc++
i was doing all the time on Linux and G++...
-
Linux and G++
But it is not possible to use the WinAPI Functions on a Linux machin...
Maybe you should use a windows machin and take a look at Microsoft Visual C++ 2005 Express Edition... then you only have to look into the MSDN Library ... there you will see that you have fergotten to link a special library
-
I mean that earlier i was working all the time on Linux...
now i am working and learning VC++ Expres 2005, and that program and that thread is about VC++, and i don't know what is that bug above.
-
@Darez:
I don't know how to get the console window minimized to a tray-icon, but you can try to simulate a pressed [ALT] + [TAB] key (this idea isn't pretty good if there are a lot of other windows open...). I saw example code for this (it was example code for fullscreen-mode, but it should be easy to replace the [ENTER]) in the web, but I forgot the link - sorry!
-
proggaholic
Hör auf so nen Mist zu erzählen... was soll das denn für nen unschöner Müll werden?Darez
I have just now tested my code and it functionated... You have fergotten to link a library...References:
Shell_NofifyIcon
-
Import library shell32.lib
-
Richtig.... was meinst de was in dem vom mir angehengten Link steht
-
Great, Is it possibale that You can upload somewhere You sln?? - poject form vc++??
I can check what is wrong...
darezik@gmail.com - e mail
Thasnk mr Devil for all really thanks
-
Yep it is works
but, when i close CMD window, TEST progra is shoutdown...-no minimaising to tray closing.. when i try to press on icon tray it no maximalize... nth do...
-
That function is to add icon to tray... it isn't to minimalise console program to Tray...:(
-
Hide the window with ShowWindow.