Source code of Windows XP (NT5)
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.

449 lines
8.8 KiB

  1. #include "precomp.h"
  2. #include <shellapi.h>
  3. #include "clCnfLnk.hpp"
  4. #include "resource.h"
  5. #if 0
  6. typedef struct _clps
  7. {
  8. PROPSHEETPAGE psp;
  9. PCConfLink pconflink;
  10. char rgchIconFile[MAX_PATH_LEN];
  11. }
  12. CLPS;
  13. DECLARE_STANDARD_TYPES(CLPS);
  14. UINT CALLBACK CLPSCallback(HWND hwnd, UINT uMsg,
  15. LPPROPSHEETPAGE ppsp)
  16. {
  17. UINT uResult = TRUE;
  18. PCLPS pclps = (PCLPS)ppsp;
  19. // uMsg may be any value.
  20. ASSERT(! hwnd ||
  21. IS_VALID_HANDLE(hwnd, WND));
  22. ASSERT(IS_VALID_STRUCT_PTR((PCCLPS)ppsp, CCLPS));
  23. switch (uMsg)
  24. {
  25. case PSPCB_CREATE:
  26. TRACE_OUT(("CLPSCallback(): Received PSPCB_CREATE."));
  27. break;
  28. case PSPCB_RELEASE:
  29. TRACE_OUT(("CLPSCallback(): Received PSPCB_RELEASE."));
  30. pclps->pconflink->Release();
  31. break;
  32. default:
  33. TRACE_OUT(("CLPSCallback(): Unhandled message %u.",
  34. uMsg));
  35. break;
  36. }
  37. return(uResult);
  38. }
  39. void SetCLPSFileNameAndIcon(HWND hdlg)
  40. {
  41. HRESULT hr;
  42. PCConfLink pconflink;
  43. char rgchFile[MAX_PATH_LEN];
  44. ASSERT(IS_VALID_HANDLE(hdlg, WND));
  45. pconflink = ((PCLPS)GetWindowLong(hdlg, DWL_USER))->pconflink;
  46. ASSERT(IS_VALID_STRUCT_PTR(pconflink, CCConfLink));
  47. hr = pconflink->GetCurFile(rgchFile, sizeof(rgchFile));
  48. if (hr == S_OK)
  49. {
  50. SHFILEINFO shfi;
  51. DWORD dwResult;
  52. dwResult = SHGetFileInfo( rgchFile, 0, &shfi, sizeof(shfi),
  53. (SHGFI_DISPLAYNAME | SHGFI_ICON));
  54. if (dwResult)
  55. {
  56. PSTR pszFileName;
  57. pszFileName = (PSTR)ExtractFileName(shfi.szDisplayName);
  58. EVAL(SetDlgItemText(hdlg, IDC_NAME, pszFileName));
  59. TRACE_OUT(("SetCLPSFileNameAndIcon(): Set property sheet file name to \"%s\".",
  60. pszFileName));
  61. ASSERT(IS_VALID_HANDLE(shfi.hIcon, ICON));
  62. HICON hIconOld = (HICON) SendDlgItemMessage(hdlg,
  63. IDC_FILEICON,
  64. STM_SETICON,
  65. (WPARAM) shfi.hIcon,
  66. 0);
  67. if (NULL != hIconOld)
  68. {
  69. DestroyIcon(hIconOld);
  70. }
  71. }
  72. else
  73. {
  74. hr = E_FAIL;
  75. TRACE_OUT( ("SetCLPSFileNameAndIcon(): SHGetFileInfo() failed, returning %lu.",
  76. dwResult));
  77. }
  78. }
  79. else
  80. {
  81. TRACE_OUT(("SetCLPSFileNameAndIcon(): GetCurFile() failed, returning %s.",
  82. GetHRESULTString(hr)));
  83. }
  84. if (hr != S_OK)
  85. {
  86. EVAL(SetDlgItemText(hdlg, IDC_NAME, EMPTY_STRING));
  87. }
  88. return;
  89. }
  90. void SetCLPSName(HWND hdlg)
  91. {
  92. PCConfLink pconflink;
  93. HRESULT hr;
  94. PSTR pszName;
  95. ASSERT(IS_VALID_HANDLE(hdlg, WND));
  96. pconflink = ((PCLPS)GetWindowLong(hdlg, DWL_USER))->pconflink;
  97. ASSERT(IS_VALID_STRUCT_PTR(pconflink, CCConfLink));
  98. hr = pconflink->GetName(&pszName);
  99. if (hr == S_OK)
  100. {
  101. EVAL(SetDlgItemText(hdlg, IDC_CONFNAME, pszName));
  102. TRACE_OUT(("SetCLPSURL(): Set property sheet Name to \"%s\".",
  103. pszName));
  104. PIMalloc pMalloc = NULL;
  105. if (SUCCEEDED(SHGetMalloc(&pMalloc)))
  106. {
  107. pMalloc->Free(pszName);
  108. pMalloc->Release();
  109. pMalloc = NULL;
  110. pszName = NULL;
  111. }
  112. }
  113. else
  114. {
  115. EVAL(SetDlgItemText(hdlg, IDC_CONFNAME, EMPTY_STRING));
  116. }
  117. return;
  118. }
  119. void SetCLPSAddress(HWND hdlg)
  120. {
  121. PCConfLink pconflink;
  122. HRESULT hr;
  123. PSTR pszAddress;
  124. ASSERT(IS_VALID_HANDLE(hdlg, WND));
  125. pconflink = ((PCLPS)GetWindowLong(hdlg, DWL_USER))->pconflink;
  126. ASSERT(IS_VALID_STRUCT_PTR(pconflink, CCConfLink));
  127. hr = pconflink->GetAddress(&pszAddress);
  128. if (hr == S_OK)
  129. {
  130. EVAL(SetDlgItemText(hdlg, IDC_CONFADDR, pszAddress));
  131. TRACE_OUT(("SetCLPSURL(): Set property sheet Address to \"%s\".",
  132. pszAddress));
  133. PIMalloc pMalloc = NULL;
  134. if (SUCCEEDED(SHGetMalloc(&pMalloc)))
  135. {
  136. pMalloc->Free(pszAddress);
  137. pMalloc->Release();
  138. pMalloc = NULL;
  139. pszAddress = NULL;
  140. }
  141. }
  142. else
  143. {
  144. EVAL(SetDlgItemText(hdlg, IDC_CONFADDR, EMPTY_STRING));
  145. }
  146. return;
  147. }
  148. BOOL CLPS_InitDialog(HWND hdlg, WPARAM wparam, LPARAM lparam)
  149. {
  150. PCConfLink pconflink;
  151. // wparam may be any value.
  152. ASSERT(IS_VALID_HANDLE(hdlg, WND));
  153. ASSERT(IS_VALID_STRUCT_PTR((PCCLPS)lparam, CCLPS));
  154. SetWindowLong(hdlg, DWL_USER, lparam);
  155. pconflink = ((PCLPS)lparam)->pconflink;
  156. ASSERT(IS_VALID_STRUCT_PTR(pconflink, CCConfLink));
  157. // Initialize control contents.
  158. SetCLPSFileNameAndIcon(hdlg);
  159. SetCLPSName(hdlg);
  160. SetCLPSAddress(hdlg);
  161. return(TRUE);
  162. }
  163. BOOL CLPS_Destroy(HWND hdlg, WPARAM wparam, LPARAM lparam)
  164. {
  165. PCConfLink pconflink;
  166. // wparam may be any value.
  167. // lparam may be any value.
  168. ASSERT(IS_VALID_HANDLE(hdlg, WND));
  169. pconflink = ((PCLPS)GetWindowLong(hdlg, DWL_USER))->pconflink;
  170. ASSERT(IS_VALID_STRUCT_PTR(pconflink, CConfLink));
  171. SetWindowLong(hdlg, DWL_USER, NULL);
  172. return(TRUE);
  173. }
  174. BOOL CALLBACK CLPS_DlgProc(HWND hdlg, UINT uMsg, WPARAM wparam,
  175. LPARAM lparam)
  176. {
  177. BOOL bMsgHandled = FALSE;
  178. // uMsg may be any value.
  179. // wparam may be any value.
  180. // lparam may be any value.
  181. ASSERT(IS_VALID_HANDLE(hdlg, WND));
  182. switch (uMsg)
  183. {
  184. case WM_INITDIALOG:
  185. bMsgHandled = CLPS_InitDialog(hdlg, wparam, lparam);
  186. break;
  187. case WM_DESTROY:
  188. bMsgHandled = CLPS_Destroy(hdlg, wparam, lparam);
  189. break;
  190. #if 0
  191. case WM_COMMAND:
  192. bMsgHandled = CLPS_Command(hdlg, wparam, lparam);
  193. break;
  194. case WM_NOTIFY:
  195. bMsgHandled = CLPS_Notify(hdlg, wparam, lparam);
  196. break;
  197. #endif // 0
  198. #ifdef CLPSHELP
  199. case WM_HELP:
  200. WinHelp((HWND)(((LPHELPINFO)lparam)->hItemHandle),
  201. ISPS_GetHelpFileFromControl((HWND)(((LPHELPINFO)lparam)->hItemHandle)),
  202. HELP_WM_HELP, (DWORD)(PVOID)s_rgdwHelpIDs);
  203. bMsgHandled = TRUE;
  204. break;
  205. case WM_CONTEXTMENU:
  206. {
  207. POINT pt;
  208. LPARAM_TO_POINT(lparam, pt);
  209. EVAL(ScreenToClient(hdlg, &pt));
  210. WinHelp((HWND)wparam,
  211. ISPS_GetHelpFileFromControl(ChildWindowFromPoint(hdlg, pt)),
  212. HELP_CONTEXTMENU, (DWORD)(PVOID)s_rgdwHelpIDs);
  213. bMsgHandled = TRUE;
  214. break;
  215. }
  216. #endif // CLSPSHELP
  217. default:
  218. break;
  219. }
  220. return(bMsgHandled);
  221. }
  222. HRESULT AddCLPS( PCConfLink pconflink,
  223. LPFNADDPROPSHEETPAGE pfnAddPage, LPARAM lparam)
  224. {
  225. HRESULT hr;
  226. CLPS clps;
  227. HPROPSHEETPAGE hpsp;
  228. // lparam may be any value.
  229. ASSERT(IS_VALID_STRUCT_PTR(pconflink, CConfLink));
  230. ASSERT(IS_VALID_CODE_PTR(pfnAddPage, LPFNADDPROPSHEETPAGE));
  231. ZeroMemory(&clps, sizeof(clps));
  232. clps.psp.dwSize = sizeof(clps);
  233. clps.psp.dwFlags = (PSP_DEFAULT | PSP_USECALLBACK);
  234. clps.psp.hInstance = g_hInst;
  235. clps.psp.pszTemplate = MAKEINTRESOURCE(IDD_CONFLINKPROP);
  236. clps.psp.pfnDlgProc = (DLGPROC) &CLPS_DlgProc;
  237. clps.psp.pfnCallback = &CLPSCallback;
  238. clps.pconflink = pconflink;
  239. ASSERT(IS_VALID_STRUCT_PTR(&clps, CCLPS));
  240. hpsp = CreatePropertySheetPage(&(clps.psp));
  241. if (hpsp)
  242. {
  243. if ((*pfnAddPage)(hpsp, lparam))
  244. {
  245. pconflink->AddRef();
  246. hr = S_OK;
  247. TRACE_OUT(("AddCLPS(): Added Conference Link property sheet."));
  248. }
  249. else
  250. {
  251. DestroyPropertySheetPage(hpsp);
  252. hr = E_FAIL;
  253. WARNING_OUT(("AddCLPS(): Callback to add property sheet failed."));
  254. }
  255. }
  256. else
  257. {
  258. hr = E_OUTOFMEMORY;
  259. }
  260. return(hr);
  261. }
  262. #endif // 0
  263. HRESULT STDMETHODCALLTYPE CConfLink::Initialize(LPCITEMIDLIST pcidlFolder,
  264. LPDATAOBJECT pido,
  265. HKEY hkeyProgID)
  266. {
  267. HRESULT hr;
  268. FORMATETC fmtetc = { CF_HDROP, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
  269. STGMEDIUM stgmed;
  270. DebugEntry(CConfLink::Initialize);
  271. ASSERT(IS_VALID_STRUCT_PTR(this, CConfLink));
  272. ASSERT( !pcidlFolder ||
  273. IS_VALID_STRUCT_PTR(pcidlFolder, const ITEMIDLIST));
  274. ASSERT(IS_VALID_INTERFACE_PTR(pido, IDataObject));
  275. ASSERT(IS_VALID_HANDLE(hkeyProgID, KEY));
  276. hr = pido->GetData(&fmtetc, &stgmed);
  277. if (hr == S_OK)
  278. {
  279. UINT ucbPathLen;
  280. PSTR pszFile;
  281. // (+ 1) for null terminator.
  282. ucbPathLen = DragQueryFile((HDROP)(stgmed.hGlobal), 0, NULL, 0) + 1;
  283. ASSERT(ucbPathLen > 0);
  284. pszFile = new(char[ucbPathLen]);
  285. if (pszFile)
  286. {
  287. EVAL(DragQueryFile((HDROP)(stgmed.hGlobal), 0, pszFile, ucbPathLen) == ucbPathLen - 1);
  288. ASSERT(IS_VALID_STRING_PTR(pszFile, STR));
  289. ASSERT((UINT)lstrlen(pszFile) == ucbPathLen - 1);
  290. hr = LoadFromFile(pszFile, TRUE);
  291. delete pszFile;
  292. pszFile = NULL;
  293. }
  294. else
  295. {
  296. hr = E_OUTOFMEMORY;
  297. }
  298. EVAL(MyReleaseStgMedium(&stgmed) == S_OK);
  299. }
  300. ASSERT(IS_VALID_STRUCT_PTR(this, CConfLink));
  301. DebugExitHRESULT(CConfLink::Initialize, hr);
  302. return(hr);
  303. }
  304. #if 0
  305. HRESULT STDMETHODCALLTYPE CConfLink::AddPages( LPFNADDPROPSHEETPAGE pfnAddPage,
  306. LPARAM lparam)
  307. {
  308. HRESULT hr;
  309. DebugEntry(CConfLink::AddPages);
  310. // lparam may be any value.
  311. ASSERT(IS_VALID_STRUCT_PTR(this, CConfLink));
  312. ASSERT(IS_VALID_CODE_PTR(pfnAddPage, LPFNADDPROPSHEETPAGE));
  313. hr = AddCLPS(this, pfnAddPage, lparam);
  314. ASSERT(IS_VALID_STRUCT_PTR(this, CConfLink));
  315. DebugExitHRESULT(CConfLink::AddPages, hr);
  316. return(hr);
  317. }
  318. HRESULT STDMETHODCALLTYPE CConfLink::ReplacePage( UINT uPageID,
  319. LPFNADDPROPSHEETPAGE pfnReplaceWith,
  320. LPARAM lparam)
  321. {
  322. HRESULT hr;
  323. DebugEntry(CConfLink::ReplacePage);
  324. // lparam may be any value.
  325. // uPageID may be any value.
  326. ASSERT(IS_VALID_STRUCT_PTR(this, CConfLink));
  327. ASSERT(IS_VALID_CODE_PTR(pfnReplaceWith, LPFNADDPROPSHEETPAGE));
  328. hr = E_NOTIMPL;
  329. ASSERT(IS_VALID_STRUCT_PTR(this, CConfLink));
  330. DebugExitHRESULT(CConfLink::ReplacePage, hr);
  331. return(hr);
  332. }
  333. #endif // 0