Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

107 lines
3.5 KiB

  1. #include <precomp.h>
  2. #include "resource.h"
  3. #include "wzccore.h"
  4. #include "wzcatl.h"
  5. #include "quickcfg.h"
  6. CWZCQuickCfg *pDlgCfg = NULL;
  7. //--------------------------------------------------------
  8. // "CanShowBalloon" hook into the WZC part of the UI pipe
  9. // This call is supposed to return either S_OK and a pszBalloonText
  10. // to be filled into the popping balloon, or S_FALSE if no balloon
  11. // is to be popped up
  12. HRESULT
  13. WZCDlgCanShowBalloon (
  14. IN const GUID * pGUIDConn,
  15. IN OUT BSTR * pszBalloonText,
  16. IN OUT BSTR * pszCookie)
  17. {
  18. HRESULT hr = S_FALSE;
  19. if (pszCookie != NULL && pszBalloonText != NULL)
  20. {
  21. PWZCDLG_DATA pDlgData = reinterpret_cast<PWZCDLG_DATA>(*pszCookie);
  22. if (pDlgData->dwCode == WZCDLG_FAILED)
  23. {
  24. WCHAR wszBuffer[MAX_PATH];
  25. SysFreeString(*pszBalloonText);
  26. LoadString(_Module.GetResourceInstance(),
  27. IDS_WZCDLG_FAILED,
  28. wszBuffer,
  29. MAX_PATH);
  30. *pszBalloonText = SysAllocString(wszBuffer);
  31. hr = pDlgData->lParam == 0 ? S_FALSE : S_OK;
  32. }
  33. }
  34. return hr;
  35. }
  36. //--------------------------------------------------------
  37. // "OnBalloonClick" hook into the WZC part of the UI pipe.
  38. // This call is supposed to be called whenever the user clicks
  39. // on a balloon previously displayed by WZC
  40. HRESULT
  41. WZCDlgOnBalloonClick (
  42. IN const GUID * pGUIDConn,
  43. IN const LPWSTR wszConnectionName,
  44. IN const BSTR szCookie)
  45. {
  46. HRESULT hr = S_OK;
  47. PWZCDLG_DATA pDlgData = reinterpret_cast<PWZCDLG_DATA>(szCookie);
  48. LRESULT lRetCode;
  49. CWZCQuickCfg *pLocalDlgCfg;
  50. if (pDlgCfg == NULL)
  51. {
  52. pDlgCfg = new CWZCQuickCfg(pGUIDConn);
  53. if (pDlgCfg != NULL)
  54. {
  55. pDlgCfg->m_wszTitle = wszConnectionName;
  56. lRetCode = pDlgCfg->DoModal(NULL);
  57. if (lRetCode == IDC_WZCQCFG_ADVANCED)
  58. {
  59. TCHAR szConnProps[4*(GUID_NCH+3)+1];
  60. LPTSTR pszConnGuid;
  61. _tcscpy(szConnProps, CONN_PROPERTIES_DLG);
  62. _tcscat(szConnProps, _T("::"));
  63. pszConnGuid = szConnProps + _tcslen(szConnProps);
  64. StringFromGUID2(*pGUIDConn, pszConnGuid, GUID_NCH);
  65. // According to MSDN, ShellExecute succeeds if the return value is >32!
  66. if (ShellExecute(
  67. NULL,
  68. COMM_WLAN_PROPS_VERB,
  69. szConnProps,
  70. NULL,
  71. NULL,
  72. SW_SHOWNORMAL) > (HINSTANCE)UlongToHandle(32))
  73. {
  74. }
  75. }
  76. pLocalDlgCfg = pDlgCfg;
  77. pDlgCfg = NULL;
  78. delete pLocalDlgCfg;
  79. }
  80. }
  81. else
  82. {
  83. // there could be a window when we've seen the pDlgCfg as not being NULL, but
  84. // while we're trying to get the window on top the user dismisses the dialog.
  85. // However, the fact we're in this code is a result of the user clicking on the
  86. // balloon - how fast can the user be in order to move the mouse to the dialog
  87. // and dismiss it while we're processing the click?
  88. pDlgCfg->SetWindowPos(HWND_TOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
  89. pDlgCfg->SetWindowPos(HWND_NOTOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
  90. }
  91. return hr;
  92. }