Exemple #1
0
LRESULT CMainDlg::OnTrayNotification(WPARAM wParam, LPARAM lParam)
{
	if(wParam == IDR_MAINFRAME && 
		(lParam == WM_LBUTTONDOWN || lParam == WM_RBUTTONDOWN))
		SetTrayIcon();

	if(wParam == IDR_MAINFRAME 
		&& lParam == WM_RBUTTONUP
		&& theApp.m_dwSubWindowCount > 0)
		lParam = WM_LBUTTONDOWN;

	if(wParam == IDR_MAINFRAME && lParam == WM_LBUTTONDOWN)
	{
		if(m_MessageIndex != 0)
		{
			int tmpIndex = m_MessageIndex;
			m_MessageIndex = 0;
			AfxMessageBox(m_OnLine.GetInternet()->m_sMessage[tmpIndex], MB_ICONINFORMATION);
			m_OnLine.GetInternet()->m_sMessage[tmpIndex][0] = 0;
			SetTrayIcon();
			return 0;
		}

		lParam = WM_LBUTTONDBLCLK;
	}

    return m_TrayIcon.OnTrayNotification(wParam, lParam);
}
Exemple #2
0
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	int wmId, wmEvent;
	PAINTSTRUCT ps;
	HDC hdc;
	TCHAR szHello[MAX_LOADSTRING];
	LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING);

	switch (message)
	{
        case WM_ICON_NOTIFY:
            return TrayIcon.OnTrayNotification(wParam, lParam);

		case WM_COMMAND:
			wmId    = LOWORD(wParam);
			wmEvent = HIWORD(wParam);
			// Parse the menu selections:
			switch (wmId)
			{
				case IDM_ABOUT:
				   DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
				   break;
				case IDM_EXIT:
				   DestroyWindow(hWnd);
				   break;
				default:
				   return DefWindowProc(hWnd, message, wParam, lParam);
			}
			break;
		case WM_PAINT:
			hdc = BeginPaint(hWnd, &ps);
			// TODO: Add any drawing code here...
			RECT rt;
			GetClientRect(hWnd, &rt);
			DrawText(hdc, szHello, strlen(szHello), &rt, DT_VCENTER | DT_CENTER | DT_SINGLELINE |DT_WORDBREAK);
			EndPaint(hWnd, &ps);
			break;

		case WM_DESTROY:
			PostQuitMessage(0);
			break;
		default:
			return DefWindowProc(hWnd, message, wParam, lParam);
   }
   return 0;
}
Exemple #3
0
LRESULT CMainFrame::OnTrayNotification(WPARAM wParam, LPARAM lParam)
{
	if(wParam == IDR_MAINFRAME && lParam == WM_LBUTTONDOWN)
	{
		if(m_MessageIndex != 0)
		{
			int tmpIndex = m_MessageIndex;
			m_MessageIndex = 0;
			AfxMessageBox(theApp.m_sMessage[tmpIndex], MB_ICONINFORMATION);
			return 0;
		}

		lParam = WM_LBUTTONDBLCLK;
	}

    return m_TrayIcon.OnTrayNotification(wParam, lParam);
}
// This is the global (static) callback function for all TrayIcon windows
LRESULT PASCAL CSystemTray::WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    // The option here is to maintain a list of all TrayIcon windows,
    // and iterate through them. If you do this, remove these 3 lines.
    CSystemTray* pTrayIcon = m_pThis;
    if (pTrayIcon->GetSafeHwnd() != hWnd)
        return ::DefWindowProc(hWnd, message, wParam, lParam);

    // If maintaining a list of TrayIcon windows, then the following...
    // pTrayIcon = GetFirstTrayIcon()
    // while (pTrayIcon != NULL)
    // {
    //    if (pTrayIcon->GetSafeHwnd() != hWnd) continue;

          // Taskbar has been recreated - all TrayIcons must process this.
          if (message == CSystemTray::m_nTaskbarCreatedMsg)
              return pTrayIcon->OnTaskbarCreated(wParam, lParam);

          // Animation timer
          if (message == WM_TIMER && wParam == pTrayIcon->GetTimerID())
              return pTrayIcon->OnTimer(wParam);

          // Settings changed
          if (message == WM_SETTINGCHANGE && wParam == pTrayIcon->GetTimerID())
              return pTrayIcon->OnSettingChange(wParam, (LPCTSTR) lParam);

          // Is the message from the icon for this TrayIcon?
          if (message == pTrayIcon->GetCallbackMessage())
              return pTrayIcon->OnTrayNotification(wParam, lParam);

    //    pTrayIcon = GetNextTrayIcon();
    // }

    // Message has not been processed, so default.
    return ::DefWindowProc(hWnd, message, wParam, lParam);
}