Добро пожаловать в форум, Guest  >>   Войти | Регистрация | Поиск | Правила | В избранное | Подписаться
Все форумы / WinForms, .Net Framework Новый топик    Ответить
 Подскажите либу для всплывающих сообщений на N сек.  [new]
Petro123
Member

Откуда: Загрузочный сектор Москвы (AutoPOI.ru)
Сообщений: 29704
типа Alertify
https://apex.oracle.com/pls/apex/f?p=64237:30:0:::::
1 окт 17, 22:52    [20834993]     Ответить | Цитировать Сообщить модератору
 Re: Подскажите либу для всплывающих сообщений на N сек.  [new]
Roman Mejtes
Member

Откуда: г. Пермь
Сообщений: 2259
https://msdn.microsoft.com/ru-ru/library/windows/desktop/ee330740(v=vs.85).aspx

в WPF, не знаю как на счет WF, есть вся сопутствующая инфраструктура классов, думаю ей можно воспользоваться и в WF.
2 окт 17, 10:07    [20835497]     Ответить | Цитировать Сообщить модератору
 Re: Подскажите либу для всплывающих сообщений на N сек.  [new]
Petro123
Member

Откуда: Загрузочный сектор Москвы (AutoPOI.ru)
Сообщений: 29704
Roman Mejtes
https://msdn.microsoft.com/ru-ru/library/windows/desktop/ee330740(v=vs.85).aspx

в WPF, не знаю как на счет WF, есть вся сопутствующая инфраструктура классов, думаю ей можно воспользоваться и в WF.

Как то из коробки у меня не пошла эта фича. Вроде расширение надо через инсталлятор ставить.
И по дизайну сомнения что фразу: "Отправлено на сервер..." в сис трее будет красиво.
Но на крайняк спасибо.
2 окт 17, 10:18    [20835540]     Ответить | Цитировать Сообщить модератору
 Re: Подскажите либу для всплывающих сообщений на N сек.  [new]
Petro123
Member

Откуда: Загрузочный сектор Москвы (AutoPOI.ru)
Сообщений: 29704
Roman Mejtes,
Не видит windows.Forms.NotifyIcon
SDK какое то ставить?
2 окт 17, 11:28    [20835769]     Ответить | Цитировать Сообщить модератору
 Re: Подскажите либу для всплывающих сообщений на N сек.  [new]
Petro123
Member

Откуда: Загрузочный сектор Москвы (AutoPOI.ru)
Сообщений: 29704
Ups....
теперь видит, но в сисТрее ничего нет.
var icon = new NotifyIcon ();
icon.ShowBalloonTip (5000, "44444", "66666", ToolTipIcon.Info);
2 окт 17, 11:41    [20835820]     Ответить | Цитировать Сообщить модератору
 Re: Подскажите либу для всплывающих сообщений на N сек.  [new]
Cat2
Member

Откуда: Petroskoi, Karjala
Сообщений: 141253
Petro123,

Вы описание класса до конца дочитайте, а потом начинайте вопросы задавать
2 окт 17, 12:39    [20836027]     Ответить | Цитировать Сообщить модератору
 Re: Подскажите либу для всплывающих сообщений на N сек.  [new]
Petro123
Member

Откуда: Загрузочный сектор Москвы (AutoPOI.ru)
Сообщений: 29704
Cat2
Petro123,
Вы описание класса до конца дочитайте, а потом начинайте вопросы задавать

Ок
Это называется Быстрый старт.
Ушёл читать.
2 окт 17, 13:13    [20836151]     Ответить | Цитировать Сообщить модератору
 Re: Подскажите либу для всплывающих сообщений на N сек.  [new]
Дмитрий77
Member

Откуда:
Сообщений: 4011
Petro123
Как то из коробки у меня не пошла эта фича. ... windows.Forms.NotifyIcon.

Не надо из коробки.
В "коробке "NOTIFYICON_VERSION_3
А вот это никак не учтено:
Public Const NOTIFYICON_VERSION_4 = &H4 'Use Windows Vista behavior

Надо

Вам же дали правильную ссылку выше.
Вот здесь все:
Shell_NotifyIcon function
NOTIFYICONDATA structure

+
Imports System.Runtime.InteropServices

Module m_TrayIcon

  'Shell Structures
  '--------------------------------------------------------------------------------
  'NOTIFICATION ICON VERSIONS (used in uVersion)
  '--------------------------------------------------------------------------------
  Public Const NOTIFYICON_VERSION_0 = &H0 'Use Windows 95 behavior
  Public Const NOTIFYICON_VERSION = &H3 'Use Windows 2000 behavior
  Public Const NOTIFYICON_VERSION_3 = NOTIFYICON_VERSION 'Alias of NOTIFYICON_VERSION
  Public Const NOTIFYICON_VERSION_4 = &H4 'Use Windows Vista behavior
  '--------------------------------------------------------------------------------
  Public Const NOTIFYICONDATA_V1_SIZE = 88  'pre-5.0 structure size (32bit,ANSI)
  Public Const NOTIFYICONDATA_V2_SIZE = 488 'pre-6.0 structure size (32bit,ANSI)
  Public Const NOTIFYICONDATA_V3_SIZE = 504 '6.0+ structure size (32bit,ANSI)

  'uFlags - Flags that either indicate which of the other members of the structure contain valid data
  'or provide additional information to the tooltip as to how it should display.
  Public Const NIF_MESSAGE = &H1
  Public Const NIF_ICON = &H2
  Public Const NIF_TIP = &H4
  Public Const NIF_INFO = &H10
  Public Const NIF_SHOWTIP = &H80

  'dwInfoFlags - Flags that can be set to modify the behavior and appearance of a balloon
  Public Const NIIF_NONE = &H0
  Public Const NIIF_INFO = &H1
  Public Const NIIF_WARNING = &H2
  Public Const NIIF_ERROR = &H3
  Public Const NIIF_USER = &H4
  Public Const NIIF_NOSOUND = &H10
  Public Const NIIF_LARGE_ICON = &H20

  'Required by Shell_NotifyIcon API call
  <StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
  Public Structure NOTIFYICONDATA
    Dim cbSize As Integer
    Dim hWnd As IntPtr
    Dim uID As Integer
    Dim uFlags As Integer
    Dim uCallbackMessage As Integer
    Dim hIcon As IntPtr
    <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=128)> Dim szTip As String
    Dim dwState As Integer
    Dim dwStateMask As Integer
    <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=256)> Dim szInfo As String
    Dim uTimeoutAndVersion As Integer
    <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=64)> Dim szInfoTitle As String
    Dim dwInfoFlags As Integer
    Dim guidItem As Guid
    Dim hBalloonIcon As IntPtr
  End Structure

  'Shell Functions

  'dwMessage A value that specifies the action to be taken by Shell_NotifyIcon API call:
  Public Const NIM_ADD = &H0
  Public Const NIM_MODIFY = &H1
  Public Const NIM_DELETE = &H2
  Public Const NIM_SETVERSION = &H4

  Public Declare Unicode Function Shell_NotifyIcon Lib "shell32" _
   Alias "Shell_NotifyIconW" _
   (ByVal dwMessage As Integer, ByRef pnid As NOTIFYICONDATA) As Boolean

  Private Const WM_USER = &H400

  Public Const NIN_BALLOONSHOW = (WM_USER + &H2) 'Sent when the balloon is shown (balloons are queued).
  Public Const NIN_BALLOONHIDE = (WM_USER + &H3) 'Sent when the balloon disappears.This message is not sent if the balloon is dismissed because of a timeout or if the user clicks the mouse.
  Public Const NIN_BALLOONTIMEOUT = (WM_USER + &H4) 'Sent when the balloon is dismissed because of a timeout.
  Public Const NIN_BALLOONUSERCLICK = (WM_USER + &H5) 'Sent when the balloon is dismissed because the user clicked the mouse.

  'Windows Vista Shell
  'Sent when the user hovers the cursor over an icon to indicate that the richer pop-up UI
  'should be used in place of a standard textual tooltip.
  Public Const NIN_POPUPOPEN = (WM_USER + &H6)
  'Sent when a cursor no longer hovers over an icon to indicate that the rich pop-up UI should be closed.
  Public Const NIN_POPUPCLOSE = (WM_USER + &H7)

  Public Const WM_MySysTrayNotify = WM_USER + &H1

  ''Contains information that the system needs to process taskbar status area messages
  'Public Type NOTIFYICONDATA
  ' 'The size of this structure, in bytes.
  ' cbSize As Long
  '
  ' 'A handle to the window that receives notification messages associated with an icon
  ' 'in the taskbar status area. The Shell uses hWnd together with uID to identify which
  ' 'icon to operate on when Shell_NotifyIcon is invoked. If guidItem is specified, hWnd
  ' 'is not required.
  ' hwnd As Long
  '
  ' 'The application-defined identifier of the taskbar icon. The Shell uses either hWnd
  ' 'plus uID or guidItem to identify which icon to operate on when Shell_NotifyIcon is
  ' 'invoked. You can have multiple icons associated with a single hWnd by assigning each
  ' 'a different uID. If guidItem is specified, uID is ignored.
  ' uID As Long
  '
  ' 'Flags that either indicate which of the other members contain valid data or
  ' 'provide additional information to the ToolTip as to how it should display.
  ' 'If you set the NIF_INFO flag, the standard ToolTip is replaced by a balloon ToolTip.
  ' 'NIF_MESSAGE  The uCallbackMessage member is valid.
  ' 'NIF_ICON     The hIcon member is valid.
  ' 'NIF_TIP      The szTip member is valid.
  ' 'NIF_STATE    The dwState and dwStateMask members are valid. (Windows 2000 and later)
  ' 'NIF_INFO     The szInfo, uTimeout, szInfoTitle, and dwInfoFlags members are valid. (Windows 2000 and later)
  ' 'NIF_GUID     Reserved. (Windows XP and later)
  ' 'NIF_REALTIME If the ToolTip cannot be displayed immediately, discard it. (Windows Vista and later)
  ' 'NIF_SHOWTIP  Use the standard ToolTip (Windows Vista and later)
  ' uFlags As Long
  '
  ' 'An application-defined message identifier. The system uses this identifier to send
  ' 'notifications to the window identified in hWnd. These notifications are sent when
  ' 'a mouse event occurs in the bounding rectangle of the icon, or when the icon is
  ' 'selected or activated with the keyboard.
  ' '
  ' 'When the uVersion member is either 0 or NOTIFYICON_VERSION, the wParam parameter of
  ' 'the message contains the identifier of the taskbar icon in which the event occurred.
  ' 'This identifier can be 32-bits in length. The lParam parameter holds the mouse or
  ' 'keyboard message associated with the event. For example, when the pointer moves over
  ' 'a taskbar icon, lParam is set to WM_MOUSEMOVE.
  ' '
  ' 'When the uVersion member is NOTIFYICON_VERSION_4, applications continue to receive
  ' 'notification events in the form of application-defined messages through the
  ' 'uCallbackMessage member, but the interpretation of the lParam and wParam parameters
  ' 'of that message is changed as follows:
  ' '
  ' 'LOWORD(lParam) contains notification events, such as NIN_BALLOONSHOW, NIN_POPUPOPEN,
  ' 'or WM_CONTEXTMENU.
  ' '
  ' 'HIWORD(lParam) contains the icon ID. Icon IDs are restricted to a length of 16 bits.
  ' '
  ' 'GET_X_LPARAM(wParam) returns the X anchor coordinate for notification events
  ' 'NIN_POPUPOPEN, NIN_SELECT, NIN_KEYSELECT, and all mouse messages between WM_MOUSEFIRST
  ' 'and WM_MOUSELAST. If any of those messages are generated by the keyboard, wParam is
  ' 'set to the upper-left corner of the target icon. For all other messages, wParam is
  ' 'undefined.
  ' '
  ' 'GET_Y_LPARAM(wParam) returns the Y anchor coordinate for notification events and
  ' 'messages as defined for the X anchor.
  ' uCallbackMessage As Long
  '
  ' 'A handle to the icon to be added, modified, or deleted. To avoid icon distortion,
  ' 'be aware that notification area icons have different levels of support under
  ' 'different versions of Microsoft Windows. Windows 95, Windows 98, and Microsoft
  ' 'Windows NT 4.0 support icons of up to 4 bits per pixel (BPP). Windows Millennium
  ' 'Edition (Windows Me) and Windows 2000 support icons of a color depth up to the
  ' 'current display mode. Windows XP supports icons of up to 32 BPP.
  ' '
  ' 'If only a 16x16 pixel icon is provided, it is scaled to a larger size in a system
  ' 'set to a high dots per inch (dpi). This can lead to an unattractive result. It is
  ' 'recommended that you provide both a 16x16 pixel icon and a larger icon in your
  ' 'resource file. Use LoadIconMetric to ensure that the correct icon is loaded and
  ' 'scaled appropriately.
  ' hIcon As Long
  '
  ' 'A null-terminated string that specifies the text for a standard ToolTip.
  ' 'It can have a maximum of 64 characters, including the terminating null character.
  ' 'For Windows 2000 (Shell32.dll version 5.0) and later, szTip can have a maximum of
  ' '128 characters, including the terminating null character.
  ' szTip As String * 128
  '
  ' 'The state of the icon. There are two flags that can be set independently: NIS_HIDDEN and NIS_SHAREDICON
  ' 'Windows 2000 (Shell32.dll version 5.0) and later.
  ' dwState As Long
  '
  ' 'A value that specifies which bits of the dwState member are retrieved or modified.
  ' 'The possible values are the same as those for dwState. For example, setting this
  ' 'member to NIS_HIDDEN causes only the item's hidden state to be retrieved while the
  ' 'icon sharing bit is ignored regardless of its value.
  ' 'Windows 2000 (Shell32.dll version 5.0) and later.
  ' dwStateMask As Long
  '
  ' 'A null-terminated string that specifies the text for a balloon ToolTip. It can have
  ' 'a maximum of 256 characters, including the terminating null character. To remove
  ' 'the ToolTip, set the NIF_INFO flag in uFlags and set szInfo to an empty string.
  ' 'Windows 2000 (Shell32.dll version 5.0) and later.
  ' szInfo As String * 256
  '
  ' 'uTimeout
  ' 'This member is deprecated as of Windows Vista.
  ' 'Notification display times are now based on system settings.
  ' '
  ' 'Union with uVersion. The timeout value, in milliseconds, for a balloon ToolTip.
  ' 'The system enforces minimum and maximum timeout values. Values specified in uTimeout
  ' 'that are too large are set to the maximum value. Values that are too small default
  ' 'to the minimum value. The system minimum and maximum timeout values are currently
  ' 'set at 10 seconds and 30 seconds, respectively.
  ' '
  ' 'uVersion
  ' 'Windows 2000 (Shell32.dll version 5.0) and later. Union with uTimeout. Specifies
  ' 'whether the Shell notify icon interface should use Windows 95 or Windows 2000
  ' 'behavior. For more information on the differences in these two behaviors, see
  ' 'Shell_NotifyIcon. This member is only employed when using Shell_NotifyIcon to send
  ' 'a NIM_SETVERSION message.
  ' '
  ' '0 = Use the Windows 95 behavior. Use this value for applications designed for Windows versions prior to Windows 2000.
  ' 'NOTIFYICON_VERSION = Use the Windows 2000 behavior. Use this value for applications designed for Windows 2000 and later.
  ' 'NOTIFYICON_VERSION_4 = Use the Windows Vista behavior. Use this value for applications designed for Windows Vista and later.
  ' uTimeoutAndVersion As Long
  '
  ' 'A null-terminated string that specifies a title for a balloon ToolTip. This title
  ' 'appears in a bold type above the text. It can have a maximum of 64 characters.
  ' 'Windows 2000 (Shell32.dll version 5.0) and later.
  ' szInfoTitle As String * 64
  '
  ' 'Flags that can be set to add an icon to a balloon ToolTip. It is placed to the left
  ' 'of the title. If the szInfoTitle member is zero-length, the icon is not shown.
  ' 'Windows 2000 (Shell32.dll version 5.0) and later.
  ' dwInfoFlags As Long
  '
  ' 'Windows 7 and later: A registered GUID that identifies the icon. This value
  ' 'overrides uID and is the recommended method of identifying the icon.
  ' 'Windows XP through Windows Vista: Reserved.
  ' 'Windows XP (Shell32.dll version 6.0) and later.
  ' guidItem As GUID
  '
  ' 'The handle of a customized balloon icon provided by the application that should be
  ' 'used independently of the tray icon. If this member is non-NULL and the NIIF_USER
  ' 'flag is set in the dwInfoFlags member, this icon is used as the balloon icon. If
  ' 'this member is NULL, the legacy behavior is carried out.
  ' 'Windows Vista (Shell32.dll version 6.0.6) and later.
  ' 'hBalloonIcon As Long
  '
  'End Type

End Module


     Dim nid As New NOTIFYICONDATA
    With nid
     .cbSize = IIf(sys_WinVista, Marshal.SizeOf(nid), Marshal.SizeOf(nid) - IntPtr.Size) 'NOTIFYICONDATA_V3_SIZE для XP
      .uTimeoutAndVersion = NOTIFYICON_VERSION_4
...

    Shell_NotifyIcon(NIM_SETVERSION, nid) 'на XP вернет false и работаем как NOTIFYICON_VERSION_3

Ну и т.д., просто намекнул чего делать, будет желание разберетесь.

Только имейте еще ввиду:
Petro123
на N сек

msdn
•A timeout for the notification. This setting is ignored in Windows Vista and later systems in favor of a system-wide accessibility timeout setting.

(причем это не зависит от версии структуры)

Но Ballon кажется можно убить через N секунд, не помню так сходу.
2 окт 17, 13:36    [20836245]     Ответить | Цитировать Сообщить модератору
Все форумы / WinForms, .Net Framework Ответить