设为首页 加入收藏

TOP

1.3.3 小试牛刀--编程实现写邮件超级链接(5)
2013-10-07 15:52:51 来源: 作者: 【 】 浏览:81
Tags:1.3.3 小试牛刀 编程 实现 邮件 超级 链接

1.3.3  小试牛刀--编程(www.cppentry.com)实现写邮件超级链接(5)

⑩ 定义函数SetDefaultCursor(),用于设定默认的鼠标形状,具体代码如下:

  1. void CHyperLink::SetDefaultCursor()  
  2. {  
  3. if (m_hLinkCursor == NULL)         // No cursor handle - load our own  
  4. {  
  5. // Get the windows directory  
  6. CString strWndDir;  
  7. GetWindowsDirectory(strWndDir.GetBuffer(MAX_PATH), MAX_PATH);  
  8. strWndDir.ReleaseBuffer();  
  9.  
  10. strWndDir += _T("\\winhlp32.exe");  
  11. // This retrieves cursor #106 from winhlp32.exe,   
  12. // which is a hand pointer  
  13. HMODULE hModule = LoadLibrary(strWndDir);  
  14. if (hModule) {  
  15. HCURSOR hHandCursor = ::LoadCursor(hModule, MAKEINTRESOURCE(106));  
  16. if (hHandCursor)  
  17. m_hLinkCursor = CopyCursor(hHandCursor);  
  18. }  
  19. FreeLibrary(hModule);  
  20. }  
  21. }  

定义函数GetRegKey(),用于获得注册表信息,具体代码如下:
  1. LONG CHyperLink::GetRegKey(HKEY key, LPCTSTR subkey, LPTSTR retdata)  
  2. {  
  3. HKEY hkey;  
  4. LONG retval = RegOpenKeyEx(key, subkey, 0, KEY_QUERY_VALUE, &hkey);  
  5. if (retval == ERROR_SUCCESS) {  
  6. long datasize = MAX_PATH;  
  7. TCHAR data[MAX_PATH];  
  8. RegQueryValue(hkey, NULL, data, &datasize);  
  9. lstrcpy(retdata, data);  
  10. RegCloseKey(hkey);  
  11. }  
  12. return retval;  
  13. }  

定义函数ReportError(),用于输出打印错误,具体代码如下:

  1. void CHyperLink::ReportError(int nError)  
  2. {  
  3. CString str;  
  4. switch (nError) {  
  5. case 0:   
  6. str = "The operating system is out\nof memory or resources.";   
  7. break;  
  8. case SE_ERR_PNF:   
  9. str = "The specified path was not found.";   
  10. break;  
  11. case SE_ERR_FNF:       
  12. str = "The specified file was not found.";   
  13. break;  
  14. case ERROR_BAD_FORMAT:    
  15. str = "The .EXE file is invalid\n(non-Win32 .EXE " 
  16. + CString("") + "or error in .EXE image).";   
  17. break;  
  18. case SE_ERR_ACCESSDENIED:   
  19. str="The operating system denied\naccess to the specified file.";   
  20. break;  
  21. case SE_ERR_ASSOCINCOMPLETE:    
  22. str = "The filename association is\nincomplete or invalid.";   
  23. break;  
  24. case SE_ERR_DDEBUSY:   
  25. str = "The DDE transaction could not\nbe completed because " 
  26. + CString("")+"other DDE transactions\nwere being processed.";   
  27. break;  
  28. case SE_ERR_DDEFAIL:   
  29. str = "The DDE transaction failed.";   
  30. break;  
  31. case SE_ERR_DDETIMEOUT:   
  32. str = "The DDE transaction could not\nbe completed because " 
  33. + CString("") + "the request timed out.";   
  34. break;  
  35. case SE_ERR_DLLNOTFOUND:   
  36. str = "The specified dynamic-link library was not found.";   
  37. break;  
  38. case SE_ERR_NOASSOC:   
  39. str = "There is no application associated\nwith the " 
  40. + CString("") + "given filename extension.";   
  41. break;  
  42. case SE_ERR_OOM:   
  43. str = "There was not enough memory to complete the operation.";   
  44. break;  
  45. case SE_ERR_SHARE:   
  46. str = "A sharing violation occurred. ";  
  47. default:   
  48. str.Format("Unknown Error (%d) occurred.", nError);   
  49. break;  
  50. }  
  51.  
  52. str = "Unable to open hyperlink:\n\n" + str;  
  53. AfxMessageBox(str, MB_ICONEXCLAMATION | MB_OK);  
  54. }  

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇1.3.3 小试牛刀--编程实现写邮件.. 下一篇1.3.3 小试牛刀--编程实现写邮件..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·C++中智能指针的性能 (2025-12-25 03:49:29)
·如何用智能指针实现c (2025-12-25 03:49:27)
·如何在 C 语言中管理 (2025-12-25 03:20:14)
·C语言和内存管理有什 (2025-12-25 03:20:11)
·为什么C语言从不被淘 (2025-12-25 03:20:08)