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.

171 lines
5.0 KiB

  1. // ShellExtensions.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "Ext.h"
  5. #include "Extaw.h"
  6. #include "shextdlg.h"
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12. /////////////////////////////////////////////////////////////////////////////
  13. // ShellExtensions dialog
  14. ShellExtensions::ShellExtensions()
  15. : CAppWizStepDlg(ShellExtensions::IDD)
  16. {
  17. //{{AFX_DATA_INIT(ShellExtensions)
  18. m_bContextMenu = FALSE;
  19. m_bContextMenu2 = FALSE;
  20. m_bContextMenu3 = FALSE;
  21. m_bCopyHook = FALSE;
  22. m_bDataObject = FALSE;
  23. m_bDragAndDrop = FALSE;
  24. m_bDropTarget = FALSE;
  25. m_bIcon = FALSE;
  26. m_bInfoTip = FALSE;
  27. m_bPropertySheet = FALSE;
  28. //}}AFX_DATA_INIT
  29. }
  30. void ShellExtensions::DoDataExchange(CDataExchange* pDX)
  31. {
  32. CDialog::DoDataExchange(pDX);
  33. //{{AFX_DATA_MAP(ShellExtensions)
  34. DDX_Control(pDX, IDC_DND, m_btnDragAndDrop);
  35. DDX_Control(pDX, IDC_CONTEXTMENU3, m_btnContextMenu3);
  36. // DDX_Control(pDX, IDC_CONTEXTMENU2, m_btnContextMenu2);
  37. DDX_Check(pDX, IDC_CONTEXTMENU, m_bContextMenu);
  38. // DDX_Check(pDX, IDC_CONTEXTMENU2, m_bContextMenu2);
  39. DDX_Check(pDX, IDC_CONTEXTMENU3, m_bContextMenu3);
  40. DDX_Check(pDX, IDC_COPYHOOK, m_bCopyHook);
  41. DDX_Check(pDX, IDC_DATAOBJECT, m_bDataObject);
  42. DDX_Check(pDX, IDC_DND, m_bDragAndDrop);
  43. DDX_Check(pDX, IDC_DROPTARGET, m_bDropTarget);
  44. DDX_Check(pDX, IDC_ICONHANDLER, m_bIcon);
  45. DDX_Check(pDX, IDC_INFOTIP, m_bInfoTip);
  46. DDX_Check(pDX, IDC_PROPERTYSHEET, m_bPropertySheet);
  47. //}}AFX_DATA_MAP
  48. }
  49. BEGIN_MESSAGE_MAP(ShellExtensions, CAppWizStepDlg)
  50. //{{AFX_MSG_MAP(ShellExtensions)
  51. ON_BN_CLICKED(IDC_CONTEXTMENU, OnContextmenu)
  52. //}}AFX_MSG_MAP
  53. END_MESSAGE_MAP()
  54. /////////////////////////////////////////////////////////////////////////////
  55. // ShellExtensions message handlers
  56. BOOL ShellExtensions::OnDismiss()
  57. {
  58. UpdateData(TRUE);
  59. GUID guidTemp;
  60. WCHAR wszGUID[50];
  61. BOOL bSomethingSelected = FALSE;
  62. if (m_bContextMenu)
  63. {
  64. Extensionsaw.m_Dictionary[TEXT("IContextMenu")] = TEXT("1");
  65. if (m_bContextMenu3)
  66. Extensionsaw.m_Dictionary[TEXT("IContextMenu3")] = TEXT("1");
  67. else
  68. Extensionsaw.m_Dictionary.RemoveKey(TEXT("IContextMenu3"));
  69. if (m_bDragAndDrop)
  70. Extensionsaw.m_Dictionary[TEXT("DragAndDrop")] = TEXT("1");
  71. else
  72. Extensionsaw.m_Dictionary.RemoveKey(TEXT("DragAndDrop"));
  73. if (SUCCEEDED(CoCreateGuid(&guidTemp)))
  74. {
  75. StringFromGUID2(guidTemp, wszGUID, ARRAYSIZE(wszGUID));
  76. Extensionsaw.m_Dictionary[TEXT("ContextMenuGUID")] = StripCurly(wszGUID);
  77. }
  78. bSomethingSelected = TRUE;
  79. }
  80. else
  81. {
  82. Extensionsaw.m_Dictionary.RemoveKey(TEXT("IContextMenu"));
  83. Extensionsaw.m_Dictionary.RemoveKey(TEXT("IContextMenu3"));
  84. Extensionsaw.m_Dictionary.RemoveKey(TEXT("DragAndDrop"));
  85. Extensionsaw.m_Dictionary.RemoveKey(TEXT("ContextMenuGUID"));
  86. }
  87. if (m_bIcon)
  88. {
  89. Extensionsaw.m_Dictionary[TEXT("Icon")] = TEXT("1");
  90. if (SUCCEEDED(CoCreateGuid(&guidTemp)))
  91. {
  92. StringFromGUID2(guidTemp, wszGUID, ARRAYSIZE(wszGUID));
  93. Extensionsaw.m_Dictionary[TEXT("IconGUID")] = StripCurly(wszGUID);
  94. }
  95. bSomethingSelected = TRUE;
  96. }
  97. else
  98. {
  99. Extensionsaw.m_Dictionary.RemoveKey(TEXT("Icon"));
  100. Extensionsaw.m_Dictionary.RemoveKey(TEXT("IconGUID"));
  101. }
  102. if (m_bPropertySheet)
  103. {
  104. Extensionsaw.m_Dictionary[TEXT("PropertySheet")] = TEXT("1");
  105. if (SUCCEEDED(CoCreateGuid(&guidTemp)))
  106. {
  107. StringFromGUID2(guidTemp, wszGUID, ARRAYSIZE(wszGUID));
  108. Extensionsaw.m_Dictionary[TEXT("PropertySheetGUID")] = StripCurly(wszGUID);
  109. }
  110. bSomethingSelected = TRUE;
  111. }
  112. else
  113. {
  114. Extensionsaw.m_Dictionary.RemoveKey(TEXT("PropertySheet"));
  115. Extensionsaw.m_Dictionary.RemoveKey(TEXT("PropertySheetGUID"));
  116. }
  117. if (m_bInfoTip)
  118. {
  119. Extensionsaw.m_Dictionary[TEXT("InfoTip")] = TEXT("1");
  120. if (SUCCEEDED(CoCreateGuid(&guidTemp)))
  121. {
  122. StringFromGUID2(guidTemp, wszGUID, ARRAYSIZE(wszGUID));
  123. Extensionsaw.m_Dictionary[TEXT("InfoTipGUID")] = StripCurly(wszGUID);
  124. }
  125. bSomethingSelected = TRUE;
  126. }
  127. else
  128. {
  129. Extensionsaw.m_Dictionary.RemoveKey(TEXT("InfoTip"));
  130. Extensionsaw.m_Dictionary.RemoveKey(TEXT("InfoTipGUID"));
  131. }
  132. #if 0
  133. Extensionsaw.m_Dictionary[TEXT("CopyHook")] = m_bCopyHook? TEXT("TRUE") : TEXT("FALSE");
  134. Extensionsaw.m_Dictionary[TEXT("DataObject")] = m_bDataObject? TEXT("TRUE") : TEXT("FALSE");
  135. Extensionsaw.m_Dictionary[TEXT("DropTarget")] = m_bDropTarget? TEXT("TRUE") : TEXT("FALSE");
  136. Extensionsaw.m_Dictionary[TEXT("InfoTip")] = m_bInfoTip? TEXT("TRUE") : TEXT("FALSE");
  137. #endif
  138. return bSomethingSelected;
  139. ;
  140. }
  141. void ShellExtensions::OnContextmenu()
  142. {
  143. UpdateData(TRUE);
  144. m_btnContextMenu2.EnableWindow(m_bContextMenu);
  145. m_btnContextMenu3.EnableWindow(m_bContextMenu);
  146. m_btnDragAndDrop.EnableWindow(m_bContextMenu);
  147. }