Reay = problem?

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #71061
    Lasse
    Participant

      I think I had the same issue. I have done it this way:

      TMainForm = class(...
        ApplicationEvents: TApplicationEvents;
        TrayIcon: TTrayIcon;
        procedure ApplicationEventsMinimize(Sender: TObject);
        procedure TrayIconClick(Sender: TObject);
        procedure WMWindowStateNormal(var AMessage: TMessage); message WM_WINDOW_STATE_NORMAL;
        ...
      private
        procedure MinimizeToSystemTray;
      end;
      
      procedure TMainForm.ApplicationEventsMinimize(Sender: TObject);
      begin
        MinimizeToSystemTray;
      end;
      
      procedure TMainForm.MinimizeToSystemTray;
      begin
        if OptionsContainer.MinimizeToSystemTray then
        begin
          Hide;
          WindowState := wsMinimized;
          TrayIcon.Visible := True;
          TrayIcon.Animate := True;
        end;
      end;
      
      procedure TMainForm.TrayIconClick(Sender: TObject);
      begin
        TrayIcon.Visible := False;
        Show;
        WindowState := wsNormal;
        Application.BringToFront;
      end;
      
      procedure TMainForm.WMWindowStateNormal(var AMessage: TMessage);
      begin
        TrayIconClick(Self);
      end;
      #71062
      Andreas
      Participant

        Hey, thanks!

        With your code, it works like charme.
        Little bit I changed to fit with my project but you helped me very much.
        Thanks!

      Viewing 2 posts - 1 through 2 (of 2 total)
      • You must be logged in to reply to this topic.