Конференция "KOL" » Проблема с TrayIcon.
 
  • AndreyRus © (11.10.13 22:03) [0]
    var
     TrayIcon: PTrayIcon;

    function CreateNumIcon(T: Byte; PowerOn: LongBool): HIcon;
    begin
     //
    end;

    procedure OnTrayIconMouse(DummySelf: Pointer; Sender: PObj; Message: Word);
    begin
     //
    end;

    procedure TForm1.KOLForm1FormCreate(Sender: PObj);
    begin
     Randomize;
     TrayIcon:= NewTrayIcon(Applet, CreateNumIcon(Random(100), true));
     TrayIcon.OnMouse:= TOnTrayIconMouse(MakeMethod(nil, @OnTrayIconMouse));
     TrayIcon.Tooltip:= 'Test';
     // Applet.ProcessMessages;
     TrayIcon.AutoRecreate:= True;
     // Applet.ProcessMessages;
    end;

    procedure TForm1.Timer1Timer(Sender: PObj);
    begin
     DestroyIcon(TrayIcon.Icon);
     TrayIcon.Icon:= CreateNumIcon(Random(100), true);
    end;

    end.

    > Вышеобозначенный код вызывает ошибку при отрисовки иконки в области системных уведомлений, если программа запускается из шедулера. Ошибка заключается в потери контроля над модификацией иконки в трее по таймеру после выхода из сеанса Windows и последующего возврата обратно. Протестировано в Win7 со всеми обновлениями.
  • AndreyRus © (11.10.13 22:06) [1]
    // Applet.ProcessMessages; - Значительно уменьшает уменьшает вероятность этой ошибки, но тем ни менее, с вероятностью 30% (на моем компьютере) она проявляться.
  • AndreyRus © (11.10.13 22:10) [2]
    Комментирование строки
    > TrayIcon.AutoRecreate:= True;
    решает эту проблему.
  • AndreyRus © (25.11.13 14:45) [3]
    Заметил, что если провести над иконкой мышкой, то иконка начинает нормально обновляться.
  • Vladimir Kladov © (25.11.13 20:00) [4]
    У меня тоже часики под семеркой иногда замирают. Возможно, система решает, что надо перейти в режим экономии и перестает обрабатывать запросы от слишком назойливых приложений. Вот, кстати, из MSDN нового:
    начало ссылки>>>>> http://msdn.microsoft.com/en-us/library/windows/desktop/ee330740(v=vs.85).aspx <<<<<конец ссылки

    Check the User Status

    The system uses the SHQueryUserNotificationState function is used to check whether the user is in quiet time, away from the computer, or in an uninterruptable state such as Presentation mode. Whether the system displays your notification depends on this state.

    Note  If your application is using a custom notification method that does not use Shell_NotifyIcon, IUserNotification, or IUserNotification2, it should always explicitly call SHQueryUserNotificationState to determine whether it should display notification UI at that time.

    Notifications sent when the user is away are queued for display, but because you cannot know when the user will return or whether the notification will still be valid at that time, you might consider resending the notification later.

    Notifications sent during quiet time are discarded unshown. Design guidelines ask that all notifications be ignorable. They should not require immediate user action. Therefore, no notification is so important that it should override quiet time.

    ----------------
    возможно, причина замирания анимации как раз в том, что мы игнорим это требование - анализировать отсутствие юзера у экрана и пытаемся обновляться, когда система залочена, например.
 
Конференция "KOL" » Проблема с TrayIcon.
Есть новые Нет новых   [118463   +19][b:0][p:0]