09. april 2001 - 17:04Der er
3 kommentarer og 2 løsninger
minimeret app. i taskbarens statusområde
Hvordan laver man en applikation der kører minimeret, med en lille ikon i taskbarens statusområde a.la. lydstyrke, skærmopløsning og winamp. Det skal være sådan at når men trykker på ikonet (kommer System Menuen frem?) kan man maksimere vinduet.
// Catch the Minimize event before the application procedure TForm1.WndProc(var Message: TMessage); var p : TPoint; begin case Message.Msg of WM_SYSCOMMAND: case Message.WParam and $FFF0 of SC_MINIMIZE: begin // Hide the Mainform Hide; // Bail out here, so the Application dont starts to show the form Exit; end; SC_RESTORE: ; end; WM_USER + 1: case Message.lParam of WM_RBUTTONDOWN: begin GetCursorPos(p); PopupMenu1.Popup(p.x, p.y); end; WM_LBUTTONDOWN: begin Show; end; end; end; inherited ; end;
procedure TForm1.FormCreate(Sender: TObject); begin //Now set up the IconNotifyData structure so that it receives//the window messages sent to the application and displays //the application\'s tips with IconNotifyData do begin hIcon := Application.Icon.Handle; uCallbackMessage := WM_USER + 1; cbSize := sizeof(IconNotifyData); Wnd := Handle; uID := 100; uFlags := NIF_MESSAGE + NIF_ICON + NIF_TIP; end;
//Add the Icon to the system tray and use the //the structure and its values Shell_NotifyIcon(NIM_ADD, @IconNotifyData);
// Hide MainForm at startup. //(Remove if application is to be shown at startup) Application.ShowMainForm := False;
// Toolwindows dont have a TaskIcon. //(Remove if TaskIcon is to be show when form is visible) SetWindowLong(Application.Handle, GWL_EXSTYLE, WS_EX_TOOLWINDOW); end;
// Shows the form when user click on TrayIcon procedure TForm1.Showform1Click(Sender: TObject); begin // Show the Mainform. Show; // Put the form in top of all others. SetForegroundWindow(Self.handle); end;
procedure TForm1.FormDestroy(Sender: TObject); begin Shell_NotifyIcon(NIM_DELETE, @IconNotifyData); end;
Jeg har givet pointene præcis i det omfang de hjalp mig. Tak.
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.