欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費電子書(shū)等14項超值服

開(kāi)通VIP
windows下控制臺托盤(pán)接口
頭文件
#ifndef WIN_CONSOLE_TRAY
#define WIN_CONSOLE_TRAY
#include <iostream>
#include <string>
//windows下控制臺托盤(pán)接口

#ifdef WIN32
#include <Windows.h>

#define TRAY_MSG_CLOSE    0x01

//消息回調,目前只回調了關(guān)閉消息
typedef void (*fTrayCallBack)(int nMsgType);

/* 功能:?jiǎn)?dòng)托盤(pán)
   參數: hwnd        程序窗口
        hicon        托盤(pán)圖標
     fCallBack    消息回調
  szServerName 托盤(pán)提示文本
返回值:成功返回0,失敗返回-1*/
long StartTray(HWND hwnd,HICON hIcon,fTrayCallBack fCallBack,std::string szServerName);

//停止托盤(pán)
long StopTray();

#endif
#endif //WIN_CONSOLE_TRAY
.cpp文件
#include "stdafx.h"
#include "WinConsoleTray.h"
#include "EC_GeneralError.h"
#include <commctrl.h>
#include <atltypes.h>
#include<cstring>
using namespace std;
#define SWM_SHOW WM_APP + 1 
#define SWM_HIDE WM_APP + 2
#define SWM_EXIT WM_APP + 3 
#define WM_NOTIFYICON (WM_USER+100)
#ifdef WIN32
fTrayCallBack m_fCallBack=NULL;
HANDLE m_hThread=NULL;
HWND m_hTrayWnd=NULL;
HWND m_hMainWnd=NULL;
NOTIFYICONDATA m_struNotifyIconData;
HICON m_hIcon=NULL;
std::string m_szServerName;
void ShowContextMenu(HWND hWnd);
LRESULT CALLBACK TrayWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
DWORD WINAPI TrayRun( LPVOID lpParam )
{
 //創(chuàng )建托盤(pán)窗口
 HWND hTrayWnd = ::CreateWindowA( "#32770", "1234", WS_OVERLAPPED, 0, 0, 2, 3, NULL, NULL, GetModuleHandleA(NULL),NULL );
 if(hTrayWnd==NULL)
  return -1;
 m_hTrayWnd=hTrayWnd;
 SetWindowLongA(hTrayWnd, GWL_WNDPROC, (LONG)TrayWndProc);
 ShowWindow( hTrayWnd, SW_HIDE );
 UpdateWindow(hTrayWnd);
 //設置托盤(pán)通知
 NOTIFYICONDATA struNotifyData;
 struNotifyData.cbSize=sizeof(NOTIFYICONDATA);
 struNotifyData.hIcon=m_hIcon;
 struNotifyData.hWnd=hTrayWnd;
 strcpy_s(struNotifyData.szTip, m_szServerName.c_str());
 struNotifyData.uCallbackMessage=WM_NOTIFYICON;
 struNotifyData.uFlags=NIF_MESSAGE|NIF_ICON|NIF_TIP;
 struNotifyData.uID=104;
 Shell_NotifyIcon(NIM_ADD,&struNotifyData);
 //氣泡顯示
 struNotifyData.cbSize=sizeof(NOTIFYICONDATA);
 struNotifyData.uFlags = NIF_INFO;
 struNotifyData.uTimeout = 1000;
 struNotifyData.dwInfoFlags = NIIF_INFO;
 strcpy_s(struNotifyData.szTip, m_szServerName.c_str());
 memset(struNotifyData.szInfo, 0, sizeof(struNotifyData.szInfo));
 memset(struNotifyData.szInfoTitle, 0, sizeof(struNotifyData.szInfoTitle));
 Shell_NotifyIcon(NIM_MODIFY, &struNotifyData);
 m_struNotifyIconData=struNotifyData;
 while(true)
 {
  MSG Msg;
  ZeroMemory(&Msg, sizeof(MSG));
  ::GetMessage(&Msg, hTrayWnd, 0, 0);
  ::TranslateMessage(&Msg);
  ::DispatchMessage(&Msg);
 }
 return VMS_SUCCESS;
}
LRESULT CALLBACK TrayWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
 BOOL isProcessFlag=0;
 switch(uMsg)
 {
 case WM_NOTIFYICON:
  {
   switch(lParam)
   {
   case WM_RBUTTONUP:
    {
     //顯示菜單
     ShowContextMenu(hWnd);
     isProcessFlag=TRUE;
    }
    break;
   case WM_LBUTTONUP:
    {
     if(IsWindowVisible(m_hMainWnd))
      ShowWindow(m_hMainWnd,SW_HIDE);
     else
     {
      ShowWindow(m_hMainWnd,SW_SHOWNORMAL);
      SetFocus(m_hMainWnd);
     }
     isProcessFlag=TRUE;
    }
    break;
   default:
    break;
   }
  }
  break;
 case WM_COMMAND:
  {
   switch(LOWORD(wParam))
   {
   case SWM_SHOW:
    {
     ShowWindow(m_hMainWnd,SW_SHOWNORMAL);
     SetFocus(m_hMainWnd);
    }
    break;
   case SWM_HIDE:
    ShowWindow(m_hMainWnd,SW_HIDE);
    break;
   case SWM_EXIT:
    {
     if(m_fCallBack!=NULL)
      m_fCallBack(TRAY_MSG_CLOSE);
    }
    break;
   default:
    break;
   }
   break;
  }
 default:
  break;
 }
 if(isProcessFlag)
  return VMS_SUCCESS;
 else
  return DefWindowProc(hWnd,uMsg,wParam,lParam);
}
void ShowContextMenu(HWND hWnd)
{
 POINT pt;
 HMENU hMenu = CreatePopupMenu();
 GetCursorPos(&pt);
 if(hMenu)
 {
  if( IsWindowVisible(m_hMainWnd))
   InsertMenu(hMenu, -1, MF_BYPOSITION, SWM_HIDE, "隱藏");
  else
   InsertMenu(hMenu, -1, MF_BYPOSITION, SWM_SHOW, "顯示");
  InsertMenu(hMenu, -1, MF_BYPOSITION, SWM_EXIT, "關(guān)閉");
  SetForegroundWindow(hWnd);
  TrackPopupMenu(hMenu, TPM_BOTTOMALIGN,pt.x, pt.y, 0, hWnd, NULL );
  DestroyMenu(hMenu);
 }
}

long RefreshTrayArea()
{
 HWND  hStatus=::FindWindow("Shell_TrayWnd",NULL);  //得到任務(wù)欄句柄
 if(hStatus==NULL) 
  return -1; 
 HWND hNotify=FindWindowEx(hStatus,NULL,"TrayNotifyWnd",NULL); //右下角區域
 if(hNotify==NULL) 
  return -1; 
 HWND hNotify1=FindWindowEx(hNotify,NULL,"SysPager",NULL);
 if(hNotify==NULL) 
  return -1; 
 HWND hNotify1_0=FindWindowEx(hNotify1,NULL,"ToolBarWindow32",NULL);//右下角區域(不包括時(shí)間)
 if(hNotify1_0==NULL)  
  return -1; 
 DWORD  pid = 0; 
 GetWindowThreadProcessId(hNotify1_0,&pid); 
 if(pid==NULL) 
  return -1;  
 HANDLE  hProcess=OpenProcess(PROCESS_QUERY_INFORMATION|PROCESS_ALL_ACCESS,true,pid); 
 if  (hProcess==NULL) 
  return -1; 
 ::SendMessage(hNotify1_0,WM_PAINT ,NULL,NULL);
 RECT rect;
 ::GetWindowRect(hNotify1_0,&rect);
 ::InvalidateRect(hNotify1_0,&rect,false);
 int  iNum=::SendMessage(hNotify1_0,TB_BUTTONCOUNT ,NULL,NULL);  //獲取任務(wù)欄上圖標個(gè)數
 unsigned long n = 0; 
 TBBUTTON  *pButton = new TBBUTTON; 
 wchar_t  name[256] = {0};   
 TBBUTTON  BButton;
 unsigned   long    whd,proid;
 for(int i=0; i<iNum; i++) 
 { 
  ::SendMessage(hNotify1_0,TB_GETBUTTON,i,(LPARAM)(&BButton)); 
  ReadProcessMemory(hProcess,&BButton,pButton,sizeof(TBBUTTON),&n);  
  if  (pButton->iString != 0xffffffff) 
   ReadProcessMemory(hProcess,(void *)pButton->iString,name,255,&n);    
  whd=0;  
  ReadProcessMemory(hProcess,(void   *)pButton->dwData,&whd,4,&n);  
  proid=NULL;  
  GetWindowThreadProcessId((HWND)whd,&proid);  
  if(proid==NULL)
   ::SendMessage(hNotify1_0,TB_DELETEBUTTON,i,0);
 }
 delete pButton;
 return 0;
};
long StartTray(HWND hwnd,HICON hIcon,fTrayCallBack fCallBack,std::string szServerName)
{
 //RefreshTrayArea();
 //設置標題欄圖標           
 SendMessage(hwnd, WM_SETICON, ICON_BIG, (LPARAM)hIcon);
 SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)hIcon);
 m_fCallBack=fCallBack;
 m_hIcon=hIcon;
 m_hMainWnd=hwnd;
 m_szServerName=szServerName;
 DWORD dwThreadid;
 m_hThread = CreateThread(NULL,0,TrayRun,NULL,0,&dwThreadid); 
 return VMS_SUCCESS;
}
long StopTray()
{
 Shell_NotifyIcon(NIM_DELETE, &m_struNotifyIconData);
 CloseHandle(m_hThread);
 return 0;
}
#endif
 
調用程序demo:
 HICON hIcon;
 hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
 StartTray(m_hWnd,hIcon,CallBackFunc,_T("Tray Call Back"));
退出時(shí):
void CallBackFunc(int nMsgType)
{
 switch (nMsgType)
 {
 case TRAY_MSG_CLOSE:
  StopTray();
  ::SendMessage(::FindWindow(NULL,"handler"),WM_CLOSE,NULL,NULL);
                                                                                                               窗口的名為handler
break;
 default:
  break;
 }
}
本站僅提供存儲服務(wù),所有內容均由用戶(hù)發(fā)布,如發(fā)現有害或侵權內容,請點(diǎn)擊舉報。
打開(kāi)APP,閱讀全文并永久保存 查看更多類(lèi)似文章
猜你喜歡
類(lèi)似文章
VC指定窗口模擬按鍵或鼠標事件
[轉]MFC子線(xiàn)程更改圖像數據后更新主窗口圖像顯示方法
VC編程小技巧之框架窗口及其他
VC窗體設計集錦
像qq一樣變換圖標
Windows應用程序基礎知識 - 筆記 - 吳錦華 - CSDN學(xué)生大本營(yíng) - Powe...
更多類(lèi)似文章 >>
生活服務(wù)
分享 收藏 導長(cháng)圖 關(guān)注 下載文章
綁定賬號成功
后續可登錄賬號暢享VIP特權!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服

欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久