Programm im Hintergrund weiterlaufen lassen
-
Hallo Gemeinde,
Hat vielleicht jemand ne Idee wie ich mein c++ Program im Hintergrund weiterlaufen lassen kann? Also Sprich auch nicht in der Taskleiste zu sehen ist, sondern warscheinlich beim Taskmanager unter Prozesse?
Danke für jede Idee oder Tip
-
Wenn du keine Konsole brauchst einfach ne Windowsanwendung erstellen, bei der du kein Fenster erstellst.
-
Hi,
Ich hab ne Grafische-oberfläche, also geine Konsole. Und wenn ich das Programm schließen will, will ich das es im Hintergrund weiterläuft und vielleicht ein Icon unter angezeigt wird...Gibts dazu wichtige Methoden die ich mir anschauen sollte???
-
dimes schrieb:
Hi,
Ich hab ne Grafische-oberfläche, also geine Konsole. Und wenn ich das Programm schließen will, will ich das es im Hintergrund weiterläuft und vielleicht ein Icon unter angezeigt wird...Gibts dazu wichtige Methoden die ich mir anschauen sollte???
hmm erstens eher kein standard c++ mehr,
zweitens denke ich nen tray icon ( falls du das meinst ) kann man in den meisten apis recht einfach machen, auch wenn ich auf windows nur mit borland c++ ( vcl ) gearbeitet habe und nicht weiss, mit was du deine graphische oberfläche machst.
(also mit welcher lib).
Naja, so oder so musst du dann ggf in dem dafür vorgesehenden Subforum schauen.
Willst du den Prozess denn dann überhaupt noch "in den hintergrund" verschieben,
also wenn du nen tray icon statt des "taskleisteneintrages" hast?
Wenn nicht, hat sichs ja eigentlich schon erledigt, wenn doch, verstehe ich nicht warumund je nach lib kannst du doch eh die action definieren, die ausgeführt wird,
wenn auf auf "close" klickst, bzw du machst dir einfach nen button "in den Hintergrund" ...
-
Du brauchst doch nur das Fenster zu schliessen und das Programm anschliessend nicht beenden...
Für das Icon im Systray (Windows natürlich) schau Dir mal Shell_NotifyIcon (MSDN) an.
-
LordJaxom schrieb:
Du brauchst doch nur das Fenster zu schliessen und das Programm anschliessend nicht beenden...
Mit ShowWindow(hWnd, SW_HIDE);
das ist aber WinAPI
-
Hm, ist die Annahme, dass ich in einem Programm nach dem Schließen des Fensters hWnd (in der Art, dass hWnd kein gültiges Handle mehr darstellt) beliebigen weiteren Code ausführen könnte, so falsch?
-
LordJaxom schrieb:
Hm, ist die Annahme, dass ich in einem Programm nach dem Schließen des Fensters hWnd (in der Art, dass hWnd kein gültiges Handle mehr darstellt) beliebigen weiteren Code ausführen könnte, so falsch?
Theoretisch möglich
-
Dieser Thread wurde von Moderator/in HumeSikkins aus dem Forum C++ in das Forum WinAPI verschoben.
Im Zweifelsfall bitte auch folgende Hinweise beachten:
C/C++ Forum :: FAQ - Sonstiges :: Wohin mit meiner Frage?Dieses Posting wurde automatisch erzeugt.
-
Du kannst machen was Du willst... solange Du nicht Dein Programm beendest. Ist ja eigentlich ganz simpel, oder?
Wie hast Du denn deine Oberfläche erstellt? MFC? Native?
-
Ich möchte gerne auf meine Klasse CTrayIcon verweisen, welche man auf www.webfritzi.de.vu in der WinApi-Ecke unter "Klassen" runterladen kann. Eine Beschreibung ist auch dabei.
-
WebFritzi schrieb:
Ich möchte gerne auf meine Klasse CTrayIcon verweisen, welche man auf www.webfritzi.de.vu in der WinApi-Ecke unter "Klassen" runterladen kann. Eine Beschreibung ist auch dabei.
www.webfritzi.de.vu schrieb:
// ... public: CTrayIcon(HINSTANCE hInstance, HWND hWnd, HICON hIcon, LPTSTR lpszTip); CTrayIcon(HINSTANCE hInstance, HWND hWnd, WORD wIconID, LPTSTR lpszTip); CTrayIcon(HINSTANCE hInstance, WNDPROC WndProc, HICON hIcon, LPTSTR lpszTip); CTrayIcon(HINSTANCE hInstance, WNDPROC WndProc, WORD wIconID, LPTSTR lpszTip); // ...
Was gibt denn die WndProc an ?
BTW: Perfekt, jetzt brauch ich das nit auch noch schreiben
-
Auszug aus CTrayIcon.txt:
CTrayIcon(HINSTANCE hInstance, HWND hWnd, HICON hIcon, LPTSTR lpszTip) CTrayIcon(HINSTANCE hInstance, HWND hWnd, WORD wIconID, LPTSTR lpszTip) ------------------------------------------------------------------------ Constructors. I think, the first parameter should be clear. In the second you specify the window which will receive the Message WM_TRAYMESSAGE (see 2) from the tray icon object. In addition, if a popupmenu is specified (using CTrayIcon::SetPopupMenu), this window will receive all the messages coming from this popup menu. The third parameter is a HICON handle to the icon, you'd like to see in the tray. The last parameter is a pointer to a string that consists of the tooltip text. This text is shown in a small window when you place the mouse cursor over the icon in the tray. The second constructor works as the first except in the third parameter. Here, you can specify a resource ID for your icon. CTrayIcon(HINSTANCE hInstance, WNDPROC WndProc, HICON hIcon, LPTSTR lpszTip) CTrayIcon(HINSTANCE hInstance, WNDPROC WndProc, WORD wIconID, LPTSTR lpszTip) ------------------------------------------------------------------------ Other contructors. As you can see, everything is equal to the first two constructors, except the second parameter. In this parameter you can specify a callback function of type WNDPROC, i.e. LRESULT CALLBACK (HWND, UINT, WPARAM, LPARAM). If you create your trayicon with this constructor, all the messages (WM_TRAYMESSAGE for mouse actions and WM_COMMAND for menu clicks) are sent to the specified callback function.
Man bestaune noch folgende Funktion:
VOID ShowBalloon(LPTSTR szTitle, LPTSTR szInfo, UINT uiTimeout, DWORD dwIcon) --------------------------------------------------------------------------------- With this function you can show a balloon (bubble) with some descripting text in it right above your tray icon. The text which you specify in szTitle will be the header of the text in the bubble and displayed in bold letters. Below, the text in szInfo follows. The parameter uiTimeout is a time value (in milliseconds) specifying the maximal display durance of the bubble. In dwIcon you specify a value which stands for the icon that is displayed in the bubble. You have the following possibilities: NIIF_NONE : No icon NIIF_INFO : A bubble with a question mark NIIF_WARNING : A warning yellow triangle with a "!" in it NIIF_ERROR : A red error icon NIIF_GUID : no idea what this is, sorry NIIF_QUESTION : same as NIIF_INFO NIIF_ICON_MASK : no idea what this is (it is reserved for future use, I think) NIIF_NOSOUND : no sound is played (ONLY Shell Version 6) NIIF_USER : ONLY SP2 - use the tray icon itself