The MASM Forum

General => The Campus => Topic started by: bluedevil on September 25, 2022, 04:42:04 PM

Title: x64 Tray Icon Example shows transparent icon and does nothing
Post by: bluedevil on September 25, 2022, 04:42:04 PM
Hello

If I understand right, somehow
1. WM_SHELLNOTIFY is not getting triggered

    .elseif uMsg==WM_SHELLNOTIFY
        .if wParam==IDI_TRAY
            .if lParam==WM_RBUTTONDOWN
                invoke GetCursorPos, addr pt
                invoke SetForegroundWindow, hWnd
                invoke TrackPopupMenu, hPopupMenu, TPM_RIGHTALIGN, pt.x, pt.y, NULL, hWnd, NULL
                invoke PostMessage, hWnd, WM_NULL, 0, 0
               
            .elseif lParam==WM_LBUTTONDBLCLK
                invoke SendMessage, hWnd, WM_COMMAND, IDM_RESTORE, 0
            .endif
        .endif

2. When minimized no icon is showing

    .elseif uMsg==WM_SIZE
        .if wParam==SIZE_MINIMIZED
            mov note.cbSize, sizeof NOTIFYICONDATA
            mov rax, hWnd
            mov note.hwnd, rax
            mov note.uID, IDI_TRAY
            mov note.uCallbackMessage, WM_SHELLNOTIFY
           
            invoke LoadIcon, NULL, IDI_WINLOGO
            mov note.hIcon, rax
           
            invoke lstrcpy, addr note.szTip, addr AppName
           
            invoke ShowWindow, hWnd, SW_HIDE
            invoke Shell_NotifyIcon, NIM_ADD, addr note
        .endif


I removed the "[Solved]" in the title as this forum is not a help desk. Our members help out where they can if time allows.
Title: Re: x64 Tray Icon Example shows transparent icon and does nothing
Post by: bluedevil on September 25, 2022, 04:44:16 PM
BTW

@Mikl__ your example works very fine but I can not get how you did it. For example you didn't fill the NOTIFYICONDATA under SIZE_MINIMIZED but you did it in data section?
Title: Re: x64 Tray Icon Example shows transparent icon and does nothing
Post by: bluedevil on September 26, 2022, 02:21:35 PM
Esen (Hello)!

I woke up early in this Monday morning and fixed it. @Mikl__ I finally understand what you have done in data section  :greenclp: So if I didn't misunderstand in x64 we need to add flags:

mov note.uFlags, NIF_ICON or NIF_MESSAGE or NIF_TIP

It is working now

But one more thing: I have to add -Zp8 parameter to make this app work! M$ Docs (https://learn.microsoft.com/en-us/cpp/assembler/masm/ml-and-ml64-command-line-reference?view=msvc-170) says:
Quote
/Zp⟦alignment⟧    Packs structures on the specified byte boundary. The alignment can be 1, 2, or 4.

I think my NOTIFYICONDATA structure is not perfect!

NOTIFYICONDATAA STRUCT
    cbSize              DWORD   ?
    hwnd                HWND    ?
    uID                 DWORD   ?
    uFlags              DWORD   ?
    uCallbackMessage    DWORD   ?
    hIcon               HICON   ?
    szTip               BYTE    64 dup (?)
    ;                    BYTE    128 dup (?)
    dwState             DWORD   ?
    dwStateMask         DWORD   ?
    szInfo              BYTE    256 dup(?)
    union DUMMYUNIONNAME
        uTimeout        DWORD   ?
        uVersion        DWORD   ?
    ends
    szInfoTitle         BYTE    64 dup(?)
    dwInfoFlags         DWORD   ?
    guidItem            GUID    <>
    hBalloonIcon        HICON   ?
NOTIFYICONDATAA ENDS

NOTIFYICONDATAW STRUCT
    cbSize              DWORD   ?
    hwnd                HWND    ?
    uID                 DWORD   ?
    uFlags              DWORD   ?
    uCallbackMessage    DWORD   ?
    hIcon               HICON   ?
    szTip               WORD    64 dup (?)
    ;                    WORD    128 dup (?)
    dwState             DWORD   ?
    dwStateMask         DWORD   ?
    szInfo              WORD    256 dup(?)
    union DUMMYUNIONNAME
        uTimeout        DWORD   ?
        uVersion        DWORD   ?
    ends
    szInfoTitle         WORD    64 dup(?)
    dwInfoFlags         DWORD   ?
    guidItem            GUID    <>
    hBalloonIcon        HICON   ?
NOTIFYICONDATAW ENDS

IFDEF __UNICODE__
    NOTIFYICONDATA  equ  <NOTIFYICONDATAW>
ELSE
    NOTIFYICONDATA  equ  <NOTIFYICONDATAA>
ENDIF
Title: x64 Tray Icon Example shows transparent icon and does nothing
Post by: TimoVJL on September 26, 2022, 06:23:48 PM
also this might help with x64
NOTIFYICONDATAA STRUCT 8
structure offsets and sizesNOTIFYICONDATA   528 210h bytes
cbSize           +0h 4h
hWnd             +8h 8h
uID              +10h 4h
uFlags           +14h 4h
uCallbackMessage +18h 4h
hIcon            +20h 8h
szTip            +28h 80h
dwState          +A8h 4h
dwStateMask      +ACh 4h
szInfo           +B0h 100h
uTimeout         +1B0h 4h
uVersion         +1B0h 4h
dwInfoFlags      +1F4h 4h
guidItem         +1F8h 10h
hBalloonIcon     +208h 8h
NOTIFYICONDATA   210h bytes
Title: Re: x64 Tray Icon Example shows transparent icon and does nothing
Post by: hutch-- on September 26, 2022, 06:35:46 PM
Would you guys give up on using the [Resolved] tag in the subject line. This forum is NOT A HELP DESK.
Title: Re: x64 Tray Icon Example shows transparent icon and does nothing
Post by: bluedevil on September 26, 2022, 06:58:01 PM
Quote from: TimoVJL on September 26, 2022, 06:23:48 PM
also this might help with x64
NOTIFYICONDATAA STRUCT 8

This helped directly, thank you

Quote from: hutch-- on September 26, 2022, 06:35:46 PM
Would you guys give up on using the [Resolved] tag in the subject line. This forum is NOT A HELP DESK.

OK hutch-- I got the message  :thumbsup:
Title: Re: x64 Tray Icon Example shows transparent icon and does nothing
Post by: zedd151 on September 26, 2022, 10:36:30 PM
@bluedevil
Good to see that you're improving your troubleshooting skills, we'll sort of. At least you are trying.  :thumbsup: