pæra Skrevet 11. februar 2004 Del Skrevet 11. februar 2004 Er det noen som vet hvordan en kan få et program til å kjøre skjult i bakgrunnen, med bare et ikon på oppgavelinjen sammen med klokken. I så fall hva er koden i C? Lenke til kommentar https://www.diskusjon.no/topic/206063-ikon-p%C3%A5-oppgavelinjen/
pæra Skrevet 11. februar 2004 Forfatter Del Skrevet 11. februar 2004 Fant det ut selv.... Lenke til kommentar https://www.diskusjon.no/topic/206063-ikon-p%C3%A5-oppgavelinjen/#findComment-1757926
HellCat Skrevet 11. februar 2004 Del Skrevet 11. februar 2004 Så flink du e!! Lenke til kommentar https://www.diskusjon.no/topic/206063-ikon-p%C3%A5-oppgavelinjen/#findComment-1758398
Zethyr Skrevet 11. februar 2004 Del Skrevet 11. februar 2004 kan jeg spørre hvordan?? gjerne en c++ kode også... Lenke til kommentar https://www.diskusjon.no/topic/206063-ikon-p%C3%A5-oppgavelinjen/#findComment-1759708
kjetil7 Skrevet 11. februar 2004 Del Skrevet 11. februar 2004 kan jeg spørre hvordan??gjerne en c++ kode også... Du bruker Shell_NotifyIcon funksjonen. Her er et lite eksempel jeg har hatt liggende: // ShellNotifyIcon Example by Kjetil Haga <[email protected]> // #include <windows.h> #include <tchar.h> // Globals HINSTANCE g_instance; // Constants const TCHAR* APPLICATION_NAME = _T("ShellNotifyIcon Example"); const TCHAR* MAIN_WINDOWCLASS = _T("SHELLNOTIFYICONEXAMPLE"); // User defined messages #define WM_SHELLNOTIFY WM_USER + 101 // Prototypes ATOM MyRegisterClass(HINSTANCE instance_); BOOL InitInstance(HINSTANCE instance_, int cmdShow_); LRESULT CALLBACK WndProc(HWND wnd_, UINT message_, WPARAM wParam_, LPARAM lParam_); // Entry point int APIENTRY _tWinMain(HINSTANCE instance_, HINSTANCE prevInstance_, LPTSTR cmdLine_, int cmdShow_) { MSG msg; HACCEL accelTable; // register window class MyRegisterClass(instance_); // init application if(!InitInstance (instance_, cmdShow_)) { return FALSE; } // load accelerators accelTable = LoadAccelerators(instance_, MAIN_WINDOWCLASS); // main message loop while (GetMessage(&msg, NULL, 0, 0)) { if (!TranslateAccelerator(msg.hwnd, accelTable, &msg)) { TranslateMessage(&msg); DispatchMessage(&msg); } } return (int) msg.wParam; } //! Saves instance handle and creates main window BOOL InitInstance(HINSTANCE instance_, int cmdShow_) { HWND hWnd; g_instance = instance_; hWnd = CreateWindow(MAIN_WINDOWCLASS, APPLICATION_NAME, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, instance_, NULL); if (!hWnd) { return FALSE; } ShowWindow(hWnd, cmdShow_); UpdateWindow(hWnd); return TRUE; } //! Registers the window class. ATOM MyRegisterClass(HINSTANCE instance_) { WNDCLASSEX wcex; wcex.cbSize = sizeof(WNDCLASSEX); wcex.style = CS_HREDRAW | CS_VREDRAW; wcex.lpfnWndProc = (WNDPROC)WndProc; wcex.cbClsExtra = 0; wcex.cbWndExtra = 0; wcex.hInstance = instance_; wcex.hIcon = 0; wcex.hCursor = LoadCursor(NULL, IDC_ARROW); wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wcex.lpszMenuName = NULL; wcex.lpszClassName = MAIN_WINDOWCLASS; wcex.hIconSm = 0; return RegisterClassEx(&wcex); } //! Processes messages for the main window. LRESULT CALLBACK WndProc(HWND wnd_, UINT message_, WPARAM wParam_, LPARAM lParam_) { const static UINT SHELLICON_ID = 1; PAINTSTRUCT ps; HDC hdc; switch (message_) { case WM_SYSCOMMAND: if(SC_MINIMIZE == wParam_) { NOTIFYICONDATA tnid; memset(&tnid, 0, sizeof(tnid) ); tnid.cbSize = sizeof(tnid); tnid.hWnd = wnd_; tnid.uID = SHELLICON_ID; tnid.uFlags = NIF_MESSAGE | NIF_ICON; tnid.uCallbackMessage = WM_SHELLNOTIFY; tnid.hIcon = LoadIcon(NULL, IDI_EXCLAMATION); if(Shell_NotifyIcon(NIM_ADD, &tnid) == TRUE) { ShowWindow(wnd_, SW_HIDE); } break; } return DefWindowProc(wnd_, message_, wParam_, lParam_); case WM_SHELLNOTIFY: if(SHELLICON_ID == wParam_) { if (WM_LBUTTONDBLCLK == lParam_) { NOTIFYICONDATA tnid; memset(&tnid, 0, sizeof(tnid) ); tnid.cbSize = sizeof(tnid); tnid.hWnd = wnd_; tnid.uID = SHELLICON_ID; Shell_NotifyIcon(NIM_DELETE, &tnid); ShowWindow(wnd_, SW_RESTORE); } } break; case WM_PAINT: hdc = BeginPaint(wnd_, &ps); EndPaint(wnd_, &ps); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(wnd_, message_, wParam_, lParam_); } return 0; } Lenke til kommentar https://www.diskusjon.no/topic/206063-ikon-p%C3%A5-oppgavelinjen/#findComment-1760278
Anbefalte innlegg
Opprett en konto eller logg inn for å kommentere
Du må være et medlem for å kunne skrive en kommentar
Opprett konto
Det er enkelt å melde seg inn for å starte en ny konto!
Start en kontoLogg inn
Har du allerede en konto? Logg inn her.
Logg inn nå