void TestSysTrayCommand() { HWND hwnd=FindWindow("Shell_TrayWnd",""); if(hwnd==NULL) { std::cout<<"Cannot find the Shell_TrayWnd !\n"; } else { std::cout<<"Shell_TrayWnd finded!\n"; HWND hwnd2=FindWindowEx(hwnd,NULL,"TrayNotifyWnd",""); if(hwnd2==NULL) { std::cout<<"Cannot find the TrayNotifyWnd !\n"; } else { std::cout<<"TrayNotifyWnd finded!\n"; HWND hwnd3=FindWindowEx(hwnd2,NULL,"SysPager",""); if(hwnd3==NULL) { std::cout<<"Cannot find the SysPager !\n"; } else { std::cout<<"SysPager finded!\n"; HWND hwnd4=FindWindowEx(hwnd3,NULL,"ToolbarWindow32",NULL); if(hwnd4==NULL) { std::cout<<"Cannot find the ToolbarWindow32 !\n"; } else { LRESULT numberButtons=SendMessage(hwnd4,TB_BUTTONCOUNT,0,0); std::cout<<"ToolbarWindow32 finded!\n"; std::cout<<"Shell_TrayWnd/TrayNotifyWnd/SysPager/ToolbarWindow32>\n"; std::cout<<"+-Number of buttons:"<<numberButtons<<"\n"; for(int i=0;i<numberButtons;i++) { std::cout<<" +-Button_"<<i<<"\n"; //std::cout<<" +-text:""<<str<<""\n"; } HWND tooltip=(HWND)SendMessage(hwnd4,TB_GETTOOLTIPS,0,0); if(tooltip==NULL) { std::cout<<"TB_GETTOOLTIPS failed: no tooltip associated\n"; } else { LRESULT toolNumber=SendMessage(tooltip,TTM_GETTOOLCOUNT,0,0); std::cout<<"+-tooltip:\n"; std::cout<<" +-tool number:"<<toolNumber<<"\n"; for(int i=0;i<toolNumber;i++) { TOOLINFO ti; ti.cbSize=sizeof(TOOLINFO); if(!SendMessage(tooltip,TTM_ENUMTOOLS,i,(LPARAM)(LPTOOLINFO)&ti)) { std::cout<<"TTM_ENUMTOOLS failed for i="<<i<<"\n"; } else { std::cout<<" +-tool_"<<i<<":\n"; std::cout<<" +-ID:"<<ti.uId<<"\n"; std::cout<<" +-rect:{"<<ti.rect.left<<","<<ti.rect.top<<","<<ti.rect.right <<","<<ti.rect.bottom<<"}\n"; std::cout<<" +-text:"<<ti.lpszText<<"\n"; } } } } } } } std::cin.get(); }
SendMessage(tooltip,TTM_ENUMTOOLS,i,(LPARAM)(LPTOOLINFO)&ti);
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question