void TaskBarIcon::doBallonMsg()
{
	gcWString msg;

	std::sort(m_vNextUpdateList.begin(), m_vNextUpdateList.end(), sortItems);

	for (size_t x=0; x<m_vNextUpdateList.size(); x++)
	{
		if (!m_vNextUpdateList[x])
			continue;

		msg += gcWString(L" - {0}\n", m_vNextUpdateList[x]->getName());
	}

	if (msg.size() > 0)
	{
		swapUpdateList();
		m_iLastBallon = BALLON_GAMEUPDATE;
		ShowBalloon(Managers::GetString(L"#TB_TITLE"), msg.c_str());
	}
}
Beispiel #2
0
void CToolTips::ShowBalloon(int nIdWnd, UINT nIdText, UINT nIDTitle, UINT icon /* = 0 */)
{
    ShowBalloon(((CDialog*)m_pParentWnd)->GetDlgItem(nIdWnd), nIdText, nIDTitle, icon);
}
Beispiel #3
0
int event_cb(char *word[], void *userdata)
{
	int iEvent = (int)userdata;

	if(iEvent > 10 && iEvent != 21)
		return HEXCHAT_EAT_NONE;

	/***************************************************************************************/
	/***** if the window is minimized or if we're allowed to show alerts when its not	 **/
	/***** and if the option to show the specified alert is true and if we're even		**/
	/***** allowed to show alerts at all then we show them (a bit confusing but it works) **/
	/***************************************************************************************/
	if(((g_iIsActive == 0) || !(g_dwPrefs & (1<<PREF_OSBWM))) && (g_dwPrefs & (1<<PREF_AMAE)) && (g_dwPrefs & (1<<iEvent)))
	{	
		/*********************************/
		/*********** Our Buffers *********/
		/*********************************/
		char			szInfo[512];
		char			szName[64];
		DWORD			dwInfoFlags;
		int iTime		= g_iTime*1000;
		char *szTemp	= NULL;

		if(g_dwPrefs & (1<<PREF_KAOI))
		{
			iTime = 0;
		}

		switch(iEvent)
		{
		case CHAN_HILIGHT:
			_snprintf(szInfo, 512, "%s:\r\n%s", word[1], word[2]);
			_snprintf(szName, 64, "Highlight: %s", hexchat_get_info (ph, "channel"));
			dwInfoFlags = NIIF_INFO;
			break;
		case CHAN_MESSAGE:
			_snprintf(szInfo, 512, "%s:\r\n%s", word[1], word[2]);
			_snprintf(szName, 64, "Channel Message: %s", hexchat_get_info (ph, "channel"));
			dwInfoFlags = NIIF_INFO;
			break;
		case CHAN_TOPIC_CHANGE:
			_snprintf(szInfo, 512, "%s has changed the topic to %s", word[1], word[2]);
			_snprintf(szName, 64, "Topic Change: %s", word[3]);
			dwInfoFlags = NIIF_INFO;
			break;
		case CHAN_INVITE:
			_snprintf(szInfo, 512, "%s has invited you into %s", word[1], word[2]);
			_snprintf(szName, 64, "Invite");
			dwInfoFlags = NIIF_INFO;
			break;
		case CHAN_KICKED:
			_snprintf(szInfo, 512, "Kicked from %s by %s:\r\n%s", word[2], word[3], word[4]);
			_snprintf(szName, 64, "Kick");
			dwInfoFlags = NIIF_WARNING;
			break;
		case CHAN_BANNED:
			_snprintf(szInfo, 512, "Cannot join %s You are banned.", word[1]);
			_snprintf(szName, 64, "Banned");
			dwInfoFlags = NIIF_WARNING;
			break;
		case CTCP_GENERIC:
			_snprintf(szInfo, 512, "%s:\r\nCTCP %s", word[2], word[1]);
			_snprintf(szName, 64, "CTCP");
			dwInfoFlags = NIIF_INFO;
			break;
		case PMSG_RECEIVE:
			_snprintf(szInfo, 512, "%s:\r\n%s", word[1], word[2]);
			_snprintf(szName, 64, "Private Message");
			dwInfoFlags = NIIF_INFO;
			break;
		case SERV_DISCONNECT:
			_snprintf(szInfo, 512, "Disconnected\r\nError: %s", word[1]);
			_snprintf(szName, 64, "Disconnect");
			dwInfoFlags = NIIF_ERROR;
			break;
		case SERV_KILLED:
			_snprintf(szInfo, 512, "Killed(%s(%s))", word[1], word[2]);
			_snprintf(szName, 64, "Server Admin has killed you");
			dwInfoFlags = NIIF_ERROR;
			break;
		case SERV_NOTICE:
			_snprintf(szInfo, 512, "Notice:\r\n%s: %s", word[1], word[2]);
			_snprintf(szName, 64, "Notice");
			dwInfoFlags = NIIF_INFO;
			break;
		case 11:
			_snprintf(szInfo, 512, ":\r\n%s: %s", word[1], word[2]);
			_snprintf(szName, 64, "Notice");
			dwInfoFlags = NIIF_INFO;
			break;
		}

		/**************************************************************************************/
		/***** Use windows instead of balloons, and if its a window should we keep it open ****/
		/***** indefinitely?															   ****/
		/**************************************************************************************/
		szTemp = hexchat_strip_color(szInfo);

		if(g_dwPrefs & (1<<PREF_UWIOB))
		{
			sdSystemAlert((HINSTANCE)g_hInstance, IDD_ALERT, szTemp, szName, iTime);
		}
		else
		{
			ShowBalloon(g_hXchatWnd, 1, szTemp, szName, iTime, dwInfoFlags);
		}

		free(szTemp);
	}

	if(g_dwPrefs & (1<<PREF_BLINK) && (g_dwPrefs & (1<<iEvent)))
	{
		BlinkIcon(g_hXchatWnd, 1, g_hIcons[0], g_hIcons[(iEvent+1)], 700, 5);
	}

	/***********************************/
	/***** pass the events to HexChat **/
	/***********************************/
	return HEXCHAT_EAT_NONE;
}
Beispiel #4
0
LRESULT CALLBACK MainWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	static UINT s_uTaskBarCreated = 0;

	switch(uMsg)
	{
	case WM_CREATE:
		{
			g_hwndMain = hwnd;
			// Register task bar (re)creation in order to reload systray icons after explorer crashes
			s_uTaskBarCreated = RegisterWindowMessage(REGISTER_MESSAGE);

			// Set Icons
			SendMessage(hwnd, WM_SETICON, ICON_BIG, 
				(LONG)(LONG_PTR)LoadImage(g_hInst, MAKEINTRESOURCE(IDI_MAIN_ICON), IMAGE_ICON, 
				GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON), LR_DEFAULTCOLOR));

			SendMessage(hwnd, WM_SETICON, ICON_SMALL, 
				(LONG)(LONG_PTR)LoadImage(g_hInst, MAKEINTRESOURCE(IDI_MAIN_ICON), IMAGE_ICON, 
				GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR));

			ShowWindow(hwnd, SW_HIDE);

			// Clear the list
			g_IconTray.clear();

			installHookKeyboard();

			// Open the configuration
			if (openConfig() == FALSE)
			{
				uninstallHookKeyboard();
				clearMenuSkin();

				MessageBox(g_hwndMain, L"Configuration file not found or invalid", ERR_MSGBOX_TITLE, NULL);

				PostQuitMessage(0);
				return 0;
			}

			// Retreive the version of Windows (in order to know if it is a win200 or superior)
			windowsVersion = GetWindowsVersion();

			// Initialisation of variables for menus
			InitMenuVars();

			// Add the system tray icons (depends of the configuration)
			ShowTrayIcons();

			// Show loading error messages
			if (g_loadingmessage != NULL) {
				ShowBalloon(ERR_MSGBOX_TITLE, g_loadingmessage, 0, NIIF_ERROR);
				free(g_loadingmessage);
				g_loadingmessage = NULL;
			}

			// Launch application in "autorun" mode
			fireEvent(PROG_EVENT_START);

			FlushMemory();
		}
		break;

	case WM_HOTKEY:
		if( (wParam >= IDH_HOTKEY_MENU) && (wParam <= (IDH_HOTKEY_MENU + g_portal->hotkeys.size()) ) )
		{
			// Detect application item or menu item in order to open a menu or launch the application
			PortalProg* l_sp = g_portal->hotkeys[ wParam - IDH_HOTKEY_MENU ];

			while( l_sp )
			{
				if( l_sp->progs.size() > 0 )
				{
					ShowTrayMenu(l_sp, PORTAL_MENU_HOTKEY);
				}
				else
				{
					l_sp->run(false);
					// Some commands could call quitPortal. In this case g_portal is set to NULL.
					if(g_portal == NULL)
						return 0;
				}
				l_sp = l_sp->nextSameHotkey;
			}
		}
		FlushMemory();
		break;

	case WM_DESTROY:
		{
			quitPortal();
		}
		break;

	case WM_MYTRAYMSG:
		if ((wParam >= IDI_MAIN_ICON) && g_portal && (wParam <= (IDI_MAIN_ICON + g_portal->menus.size())))
		{
			// Find the clicked systray
			int pos = (int)wParam - IDI_MAIN_ICON;
			if( ((UINT)lParam == WM_RBUTTONUP) || ((UINT)lParam == WM_LBUTTONUP) || ((UINT)lParam == WM_MOUSEMOVE) )
			{
				// Left click : minimalist menu
				// Right click : Complete menu (with About/Reload/Quit)
				// Auto Open : Complete menu (like right click) with a automatic dismiss
				int param = PORTAL_MENU_SYSTRAY;
				if((UINT)lParam == WM_RBUTTONUP)
				{
					param = PORTAL_MENU_SYSTRAY_CMD;
				}
				
				if( ((UINT)lParam == WM_MOUSEMOVE) )
				{
					if( (g_portal->menus[pos] != NULL) && (g_portal->menus[pos]->options & PROG_OPTION_AUTOOPEN) )
					{
						param = PORTAL_MENU_SYSTRAY_AUTO;
					}
					else
					{
						return 0;
					}
				}

				// Detect if the icon is for a menu or a application
				if( (g_portal->menus[pos] != NULL) && ( g_portal->menus[pos]->progs.size() > 0 ) )
				{
					ShowTrayMenu(g_portal->menus[pos], param);
					g_currentMenu = pos;
				}
				else if( (g_portal->menus[pos] != NULL) && (g_portal->menus[pos]->progExe != NULL ))
				{
					if((UINT)lParam == WM_LBUTTONUP)
					{
						g_portal->menus[pos]->run(true);
						g_currentMenu = pos;
					}
					else
					{
						ShowTrayMenu(g_portal->menus[pos], param);
						g_currentMenu = pos;
					}
				}
				else
				{
					ShowTrayMenu(NULL, param);
					g_currentMenu = 0;
				}
				FlushMemory();
			}
			else if( (UINT)lParam == NIN_BALLOONUSERCLICK )
			{
				if(g_aboutbaloon)
					checkGuiproVersion();
				FlushMemory();
				return 0;
			}
		}
		break;

	case WM_INITMENUPOPUP :
		OnInitMenuPopup(hwnd, wParam, lParam);
		break;

	case WM_UNINITMENUPOPUP:
		OnUninitMenuPopup(hwnd, wParam, lParam);
		break;

	case WM_MEASUREITEM :
		OnMeasureItem(hwnd, wParam, lParam);
		break;

	case WM_DRAWITEM :
		OnDrawItem(hwnd, wParam, lParam);
		break;

	case WM_MENUCHAR:
		return OnMenuCharItem(hwnd, wParam, lParam);

	case WM_COMMAND:
		// Retreive a menu command
		if( wParam == IDM_EXIT )
		{
			quitPortal();
		}
		else if( wParam == IDM_RELOAD )
		{
			reloadPortalConfig();
		}
		else if( wParam == IDM_ABOUT )
		{
			ShowAbout(g_currentMenu);
			FlushMemory();
		}
		else if( ((UINT)wParam >= (PORTAL_HK_ID)) && ( (UINT)wParam <= (UINT)(PORTAL_HK_ID + menuGetNbElem()) )  )
		{
			PortalProg* l_sp = menuGetElem( (int)(wParam - 1 - PORTAL_HK_ID) );
			l_sp->run(true);
			FlushMemory();
		}
		else if( ((UINT)wParam >= (PORTAL_FILE_ID)) && ( (UINT)wParam < (UINT)(PORTAL_FILE_ID + menuGetNbFiles()) ) )
		{
			PortalProg* l_sp = menuGetFile( (int)(wParam - PORTAL_FILE_ID) );
			l_sp->run(true);
			FlushMemory();

			for(PortalProgVector::iterator i = g_portal_files.begin(); i != g_portal_files.end(); i++)
			{
				delete (*i);
			}
			g_portal_files.clear();
		}
		break;

	default:
		if( uMsg == s_uTaskBarCreated )
		{
			// Traskbar (re)creation, we have to reset systray icons
			ReloadTrayIcons();
			FlushMemory();
		}
		else
		{
			return(DefWindowProc(hwnd, uMsg, wParam, lParam));
		}
		break;
	}
	return 0;
}
Beispiel #5
0
//
// creates a new balloon window
// Parameters:
//    strTitle    |  Title of balloon
//    strContent  |  Content of balloon
//    ptAnchor    |  point tail of balloon will be "anchor"ed to
//    unOptions   |  One or more of:
//                :     unCLOSE_ON_LBUTTON_UP   |  closes window on WM_LBUTTON_UP
//                :     unCLOSE_ON_MBUTTON_UP   |  closes window on WM_MBUTTON_UP
//                :     unCLOSE_ON_RBUTTON_UP   |  closes window on WM_RBUTTON_UP
//                :     unCLOSE_ON_LBUTTON_DOWN |  closes window on WM_LBUTTON_DOWN
//                :     unCLOSE_ON_MBUTTON_DOWN |  closes window on WM_MBUTTON_DOWN
//                :     unCLOSE_ON_RBUTTON_DOWN |  closes window on WM_RBUTTON_DOWN
//                :     unCLOSE_ON_MOUSE_MOVE   |  closes window when user moves mouse past threshhold
//                :     unCLOSE_ON_KEYPRESS     |  closes window on the next keypress message sent to this thread.    (!!! probably not thread safe !!!)
//                :     unDELETE_THIS_ON_CLOSE  |  deletes object when window is closed.  Used by LaunchBalloon(), use with care
//                :     unSHOW_CLOSE_BUTTON     |  shows close button in upper right
//                :     unSHOW_INNER_SHADOW     |  draw inner shadow in balloon
//                :     unSHOW_TOPMOST          |  place balloon above all other windows
//                :     unDISABLE_FADE          |  disable the fade-in/fade-out effects (overrides system and user settings)
//                :     unDISABLE_FADEIN        |  disable the fade-in effect
//                :     unDISABLE_FADEOUT       |  disable the fade-out effect
//    pParentWnd  |  Parent window.  If NULL will be set to AfxGetMainWnd() and anchor to screen
//    strURL      |  If not empty, when the balloon is clicked ShellExecute() will
//                |  be called, with strURL passed in.
//    unTimeout   |  If not 0, balloon will automatically close after unTimeout milliseconds.
//    hIcon       |  If not NULL, the icon indicated by hIcon will be displayed at top-left of the balloon.
//
// Returns:
//    TRUE if successful, else FALSE
//
BOOL CBalloonHelp::Create(const CString& strTitle, const CString& strContent, 
						  const CPoint& ptAnchor, unsigned int unOptions,
						  CWnd* pParentWnd /*=NULL*/,
						  const CString strURL /*= ""*/,
						  unsigned int unTimeout /*= 0*/,
						  HICON hIcon /*= NULL*/)
{
	m_strContent   = strContent;
	SetAnchorPoint(ptAnchor, pParentWnd);
	m_unOptions    = unOptions;
	m_strURL       = strURL;
	m_unTimeout    = unTimeout;
	
	if ( NULL != hIcon )
		SetIcon(hIcon);
	
	pParentWnd = GetSafeOwner(pParentWnd);
	if (NULL == pParentWnd)
		return FALSE;
	
	// if no fonts set, use defaults
	if ( NULL == m_pContentFont )
	{
		m_pContentFont = new CFont;
		if ( !m_pContentFont->CreateStockObject(DEFAULT_GUI_FONT) )
			return FALSE;
	}
	
	// title font defaults to bold version of content font
	if ( NULL == m_pTitleFont )
	{
		m_pTitleFont = new CFont;
		LOGFONT LogFont;
		m_pContentFont->GetLogFont(&LogFont);
		LogFont.lfWeight = FW_BOLD;
		if ( !m_pTitleFont->CreateFontIndirect(&LogFont) )
			return FALSE;
	}
	
	if ( !GetClassAtom() )  // couldn't register class
		return FALSE;
	
	// check system settings: if fade effects are disabled or unavailable, disable here too
	BOOL bFade = FALSE;
	::SystemParametersInfo(SPI_GETTOOLTIPANIMATION, 0, &bFade, 0);
	if (bFade)
		::SystemParametersInfo(SPI_GETTOOLTIPFADE, 0, &bFade, 0);
	if (!bFade || NULL == m_fnAnimateWindow)
		m_unOptions |= unDISABLE_FADE;
	
	// create invisible at arbitrary position; then position, set region, and finally show
	
	// the idea with WS_EX_TOOLWINDOW is, you can't switch to this using alt+tab
	DWORD dwExStyle = WS_EX_TOOLWINDOW;
	if ( m_unOptions&unSHOW_TOPMOST )      // make topmost, if requested
		dwExStyle |= WS_EX_TOPMOST;
	if ( !CreateEx(dwExStyle, _T("BalloonHelpClass"), strTitle, WS_POPUP, CRect(0,0,10,10), pParentWnd, 0, NULL) )
		return FALSE;
	PositionWindow();
	
	if ( (m_unOptions&unCLOSE_ON_MOUSE_MOVE)
		||(m_unOptions&unCLOSE_ON_LBUTTON_UP)
		||(m_unOptions&unCLOSE_ON_LBUTTON_DOWN)
		||(m_unOptions&unCLOSE_ON_MBUTTON_UP)
		||(m_unOptions&unCLOSE_ON_MBUTTON_DOWN)
		||(m_unOptions&unCLOSE_ON_RBUTTON_UP)
		||(m_unOptions&unCLOSE_ON_RBUTTON_DOWN) )
	{
		::GetCursorPos(&m_ptMouseOrig);
		SetMouseHook();
	}
	
	// these need to take effect even if the window receiving them
	// is not owned by this process.  So, if this process does not
	// already have the mouse captured, capture it!
	if ( (m_unOptions&unCLOSE_ON_LBUTTON_UP)
		||(m_unOptions&unCLOSE_ON_MBUTTON_UP)
		||(m_unOptions&unCLOSE_ON_RBUTTON_UP) )
	{
		// no, i don't particularly need or want to deal with a situation
		// where a balloon is being created and another program has captured
		// the mouse.  If you need it, it shouldn't be too hard, just do it here.
		if ( NULL == GetCapture() )
			SetCapture();
	}
	
	if ( m_unOptions&unCLOSE_ON_KEYPRESS )
		SetKeyboardHook();
	
	ShowBalloon();
	return TRUE;
}