扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
图一、实现图形超链接功能的程序界面图 |
BOOL AddTool( CWnd* pWnd,LPCTSTR lpszText, LPCRECT lpRectTool,UINT nIDTOOL ); |
//在文件头定义的全局变量 CToolTipCtrl m_ToolTip;//工具提示对象 char string[50];//用来存放提示文字 CRect rect;//用来存放工具提示所对应的窗口的尺寸 #define IDC_CONST 12345//定义的工具提示标志号,注意不要和系统冲突 void CTestView::OnMouseMove(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default wsprintf(string,"%d,%d",point.x,point.y); GetClientRect(&recty); m_ToolTip.AddTool(this,string,&rect,IDC_CONST); m_ToolTip.Activate(TRUE); CView::OnMouseMove(nFlags, point); } LRESULT CTestView::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) { // TODO: Add your specialized code here and/or call the base class switch(message) {case WM_LBUTTONDOWN: case WM_RBUTTONDOWN: case WM_MBUTTONDOWN: case WM_LBUTTONUP: case WM_MBUTTONUP: case WM_RBUTTONUP: case WM_MOUSEMOVE: {MSG msg; msg.hwnd=m_hWnd; msg.message=message; msg.wParam=wParam; msg.lParam=lParam; m_ToolTip.RelayEvent(&msg); } } return CView::WindowProc(message, wParam, lParam); } |
void UpdateTipText( LPCTSTR lpszText, CWnd* pWnd, UINT nIDTool = 0 ); |
void CMapHyperLink::SetDefaultCursor() { if (m_hLinkCursor == NULL) // No cursor handle - load our own { // Get the windows directory CString strWndDir; GetWindowsDirectory(strWndDir.GetBuffer(MAX_PATH), MAX_PATH); strWndDir.ReleaseBuffer(); strWndDir += _T("\\winhlp32.exe"); // This retrieves cursor #106 from winhlp32.exe, which is a hand pointer HMODULE hModule = LoadLibrary(strWndDir); if (hModule) { HCURSOR hHandCursor = ::LoadCursor(hModule, MAKEINTRESOURCE(106)); if (hHandCursor) m_hLinkCursor = CopyCursor(hHandCursor); } FreeLibrary(hModule); } } |
HINSTANCE ShellExecute( HWND hwnd, //窗口句柄 LPCTSTR lpOperation, //操作类型 LPCTSTR lpFile, //文件指针 LPCTSTR lpParameters, //文件可带的参数 LPCTSTR lpDirectory, //缺省目录 INT nShowCmd //显示方式 ); |
ShellExecute(this->m_hWnd,"open","calc.exe","","", SW_SHOW ); 或 ShellExecute(this->m_hWnd,"open","notepad.exe", "c:\\MyLog.log","",SW_SHOW ); |
ShellExecute(this->m_hWnd,"open", "c:\\abc.txt","","",SW_SHOW ); |
ShellExecute(this->m_hWnd,"open", " http://www.google.com","","",/ SW_SHOW ); |
ShellExecute(this->m_hWnd,"open","mailto:nishinapp@yahoo.com","","", W_SHOW ); |
ShellExecute(this->m_hWnd,"print", "c:\\abc.txt","","", SW_HIDE); |
ShellExecute(m_hWnd,"find","d:\\nish", NULL,NULL,SW_SHOW); |
SHELLEXECUTEINFO ShExecInfo = {0}; ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO); ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS; ShExecInfo.hwnd = NULL; ShExecInfo.lpVerb = NULL; ShExecInfo.lpFile = "c:\\MyProgram.exe"; ShExecInfo.lpParameters = ""; ShExecInfo.lpDirectory = NULL; ShExecInfo.nShow = SW_SHOW; ShExecInfo.hInstApp = NULL; ShellExecuteEx(&ShExecInfo); WaitForSingleObject(ShExecInfo.hProcess,INFINITE); 或: PROCESS_INFORMATION ProcessInfo; STARTUPINFO StartupInfo; //This is an [in] parameter ZeroMemory(&StartupInfo, sizeof(StartupInfo)); StartupInfo.cb = sizeof StartupInfo ; //Only compulsory field if(CreateProcess("c:\\winnt\\notepad.exe", NULL, NULL,NULL,FALSE,0,NULL, NULL,&StartupInfo,&ProcessInfo)) { WaitForSingleObject(ProcessInfo.hProcess,INFINITE); CloseHandle(ProcessInfo.hThread); CloseHandle(ProcessInfo.hProcess); } else { MessageBox("The process could not be started..."); } |
SHELLEXECUTEINFO ShExecInfo ={0}; ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO); ShExecInfo.fMask = SEE_MASK_INVOKEIDLIST ; ShExecInfo.hwnd = NULL; ShExecInfo.lpVerb = "properties"; ShExecInfo.lpFile = "c:\\"; //can be a file as well ShExecInfo.lpParameters = ""; ShExecInfo.lpDirectory = NULL; ShExecInfo.nShow = SW_SHOW; ShExecInfo.hInstApp = NULL; ShellExecuteEx(&ShExecInfo); |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者