C ++ - Tray Icon does not send two different notifications

0

I'm having an invention with the notifications of the Tray Icon, it turns out that when I press a key the function Siwth () is activated and it shows a message, up there all ok. I put an if inside the ShowMessage to be able to show different messages depending on the value that is sent to the ShowMessage function. But when I execute the function with the second value it shows me the first message and the second one .. I just want to show me the second, probe in many ways and I can not find the form, can not send two different messages?

This is my code

#include "stdafx.h"
#include "TryMode.h"
#include "Controller.h"   
#include "TMemory.h"    
#include <ShellAPI.h>
#include "resource.h"
// ----------------------------------------------------------------------------------------------

TrayMode gTrayMode;
// ----------------------------------------------------------------------------------------------

void TrayMode::Load()
{
    this->TempWindowProc    = NULL;
    this->TempIconProc      = NULL;
    this->InTray            = false;
}
// ----------------------------------------------------------------------------------------------

void TrayMode::SwitchState()
{
    if( IsWindowVisible(pGameWindow) )
    {
        ShowWindow(pGameWindow, SW_HIDE);
        UpdateWindow(pGameWindow);
        this->ShowNotify(true);
        this->ShowMessage(NIIF_INFO,0);
    }
    else
    {
        ShowWindow(pGameWindow, SW_SHOW);
        UpdateWindow(pGameWindow);
        this->ShowNotify(false);
    }
}
// ----------------------------------------------------------------------------------------------

void TrayMode::ShowNotify(bool Mode)
{
    this->InTray = Mode;
    NOTIFYICONDATA Icon     = { 0 };
    // ----
    Icon.cbSize             = sizeof(NOTIFYICONDATA);
    Icon.uID                = TRAYMODE_ICON_ID;
    Icon.uFlags             = NIF_ICON|NIF_MESSAGE|NIF_TIP;
    Icon.hIcon              = (HICON)LoadImage(gController.Instance, MAKEINTRESOURCE(IDI_MAIN_ICON), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR);
    this->TempIconProc      = Icon.hIcon;
    Icon.hWnd               = pGameWindow;
    Icon.uCallbackMessage   = TRAYMODE_ICON_MESSAGE;
    // ----

    // ----
    if( Mode )
    {
        Shell_NotifyIcon(NIM_ADD, &Icon);
    }
    else
    {
        Shell_NotifyIcon(NIM_DELETE, &Icon);
    }
    // ----
    DeleteObject(Icon.hIcon);
}
// ----------------------------------------------------------------------------------------------

void TrayMode::ShowMessage(DWORD Type,int Message)
{
    NOTIFYICONDATA Icon     = { 0 };
    // ----
    Icon.cbSize             = sizeof(NOTIFYICONDATA);
    Icon.uID                = TRAYMODE_ICON_ID;
    Icon.hWnd               = pGameWindow;
    Icon.uFlags             = NIF_ICON | NIF_MESSAGE | NIF_INFO;
    Icon.hIcon              = this->TempIconProc;
    Icon.uCallbackMessage   = TRAYMODE_ICON_MESSAGE;
    Icon.dwInfoFlags        = Type;
    Icon.uTimeout           = 5000;
    // ----
    if(Message == 0){
    strcpy(Icon.szInfo,"Primer mensaje" );
    }
    else if(Message == 1){
    strcpy(Icon.szInfo, "Segundo mensaje" );
    }
    strcpy(Icon.szInfoTitle, "Titulo");
    // ----
    Shell_NotifyIcon(NIM_MODIFY, &Icon);
}
// ----------------------------------------------------------------------------------------------
    
asked by Ignacio Copparoni 22.10.2018 в 14:44
source

0 answers