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.

190 lines
4.8 KiB

  1. /* File: D:\wacker\ext\fspage.c (Created: 01-Mar-1994)
  2. *
  3. * Copyright 1994 by Hilgraeve Inc. -- Monroe, MI
  4. * All rights reserved
  5. *
  6. * $Revision: 2 $
  7. * $Date: 2/05/99 3:20p $
  8. */
  9. #define _INC_OLE // WIN32, get ole2 from windows.h
  10. #define CONST_VTABLE
  11. #include <windows.h>
  12. #pragma hdrstop
  13. #include <windowsx.h>
  14. //#include <shell2.h>
  15. #include <shlobj.h>
  16. #include <tdll\stdtyp.h>
  17. #include <tdll\globals.h>
  18. #include <tdll\tdll.h>
  19. #include <term\res.h>
  20. #include <tdll\assert.h>
  21. #include <tdll\mc.h>
  22. #include "pageext.hh"
  23. #include <tdll\session.h>
  24. #include <tdll\sf.h>
  25. #include <tdll\property.h>
  26. #include <cncttapi\cncttapi.h>
  27. //
  28. // Function prototype
  29. //
  30. UINT CALLBACK FSPage_ReleasePage(HWND hwnd, UINT uMsg, LPPROPSHEETPAGE psp);
  31. //---------------------------------------------------------------------------
  32. //
  33. // FSPage_AddPages
  34. //
  35. // This function is called from CSamplePageExt::AddPages(). It add a page
  36. // if the data object contains file system objects.
  37. //
  38. //---------------------------------------------------------------------------
  39. void FSPage_AddPages(LPDATAOBJECT pdtobj,
  40. LPFNADDPROPSHEETPAGE lpfnAddPage, LPARAM lParam)
  41. {
  42. //
  43. // Call IDataObject::GetData asking for a CF_HDROP (i.e., HDROP).
  44. //
  45. FORMATETC fmte = {
  46. CF_HDROP,
  47. (DVTARGETDEVICE FAR *)NULL,
  48. //DVASPECT_SHORTNAME,
  49. DVASPECT_CONTENT,
  50. -1,
  51. TYMED_HGLOBAL};
  52. STGMEDIUM medium;
  53. HRESULT hres = pdtobj->lpVtbl->GetData(pdtobj, &fmte, &medium);
  54. if (SUCCEEDED(hres))
  55. {
  56. //
  57. // We need to make a copy of hdrop, because we can't hang on
  58. // to this medium.
  59. //
  60. UINT cbDrop = (UINT)GlobalSize(medium.hGlobal);
  61. HDROP hdrop = GlobalAlloc(GPTR, cbDrop);
  62. HSESSION hSession;
  63. hSession = CreateSessionHandle(NULL);
  64. if ((hdrop != NULL) && (hSession != NULL))
  65. {
  66. PROPSHEETPAGE psp;
  67. HPROPSHEETPAGE hpage;
  68. char szFile[MAX_PATH];
  69. if (cbDrop)
  70. MemCopy((LPSTR)hdrop, GlobalLock(medium.hGlobal), cbDrop);
  71. GlobalUnlock(medium.hGlobal);
  72. /*
  73. * We need to get a session handle that we can pass along to
  74. * the property sheet dialogs. This may take a little bit of
  75. * work because the routines to create a session handle usually
  76. * expect that there will be a session window. Not in this case.
  77. */
  78. DragQueryFile(hdrop, 0, szFile, sizeof(szFile));
  79. InitializeSessionHandle(hSession, NULL, NULL);
  80. sfOpenSessionFile(sessQuerySysFileHdl(hSession), szFile);
  81. sessLoadSessionStuff(hSession);
  82. //
  83. // Create a property sheet page object from a dialog box.
  84. //
  85. // We store the hdrop (a copy of medium.hGlobal) in lParam,
  86. // because it is the only instance data we need.
  87. //
  88. // If the page needs more instance data, you can append
  89. // arbitrary size of data at the end of this structure,
  90. // and pass it to the CreatePropSheetPage. In such a case,
  91. // the size of entire data structure (including page specific
  92. // data) must be stored in the dwSize field.
  93. //
  94. psp.dwSize = sizeof(psp); // no extra data.
  95. psp.dwFlags = PSP_USEREFPARENT | PSP_USECALLBACK;
  96. psp.hInstance = glblQueryDllHinst();
  97. psp.pszTemplate = MAKEINTRESOURCE(IDD_TAB_PHONENUMBER);
  98. psp.pfnDlgProc = NewPhoneDlg;
  99. psp.pcRefParent = &g_cRefThisDll;
  100. psp.pfnCallback = FSPage_ReleasePage;
  101. psp.lParam = (LPARAM)hSession;
  102. hpage = CreatePropertySheetPage(&psp);
  103. if (hpage)
  104. {
  105. if (!lpfnAddPage(hpage, lParam))
  106. DestroyPropertySheetPage(hpage);
  107. }
  108. // Do the terminal page now
  109. psp.dwSize = sizeof(psp); // no extra data.
  110. psp.dwFlags = PSP_USEREFPARENT;
  111. psp.hInstance = glblQueryDllHinst();
  112. psp.pszTemplate = MAKEINTRESOURCE(IDD_TAB_TERMINAL);
  113. psp.pfnDlgProc = TerminalTabDlg;
  114. psp.pcRefParent = &g_cRefThisDll;
  115. psp.pfnCallback = 0;
  116. psp.lParam = (LPARAM)hSession;
  117. hpage = CreatePropertySheetPage(&psp);
  118. if (hpage)
  119. {
  120. if (!lpfnAddPage(hpage, lParam))
  121. DestroyPropertySheetPage(hpage);
  122. }
  123. /* Make sure we free this up here */
  124. GlobalFree(hdrop);
  125. }
  126. //
  127. // HACK: We are supposed to call ReleaseStgMedium. This is a temporary
  128. // hack until OLE 2.01 for Chicago is released.
  129. //
  130. if (medium.pUnkForRelease)
  131. {
  132. medium.pUnkForRelease->lpVtbl->Release(medium.pUnkForRelease);
  133. }
  134. else
  135. {
  136. GlobalFree(medium.hGlobal);
  137. }
  138. }
  139. }
  140. //
  141. //
  142. //
  143. UINT CALLBACK FSPage_ReleasePage(HWND hwnd, UINT uMsg, LPPROPSHEETPAGE psp)
  144. {
  145. HSESSION hSession;
  146. SF_HANDLE hsf;
  147. switch (uMsg)
  148. {
  149. case PSPCB_RELEASE:
  150. hSession = (HSESSION)psp->lParam;
  151. hsf = sessQuerySysFileHdl(hSession);
  152. sessSaveSessionStuff(hSession);
  153. sfFlushSessionFile(hsf);
  154. DestroySessionHandle(hSession);
  155. hSession = NULL;
  156. break;
  157. }
  158. return TRUE;
  159. }