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.

1238 lines
42 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1999 - 1999
  6. //
  7. // File: DsplComp.cpp
  8. //
  9. //--------------------------------------------------------------------------
  10. #include "stdafx.h"
  11. #include "displ2.h"
  12. #include "DsplMgr2.h"
  13. // local proto
  14. HRESULT ApplyOption (int nCommandID);
  15. extern HINSTANCE g_hinst; // in displ2.cpp
  16. HSCOPEITEM g_root_scope_item = 0;
  17. CComponent::CComponent()
  18. {
  19. m_pResultData = NULL;
  20. m_pHeaderCtrl = NULL;
  21. m_pComponentData = NULL; // the guy who created me
  22. m_IsTaskPad = 0; // TODO: should get this from the persisted data
  23. m_pConsole = NULL;
  24. m_TaskPadCount = 0;
  25. m_toggle = FALSE;
  26. m_toggleEntry = FALSE;
  27. }
  28. CComponent::~CComponent()
  29. {
  30. _ASSERT (m_pResultData == NULL);
  31. _ASSERT (m_pHeaderCtrl == NULL);
  32. }
  33. HRESULT CComponent::Initialize (LPCONSOLE lpConsole)
  34. {
  35. _ASSERT(lpConsole != NULL);
  36. _ASSERT (m_pResultData == NULL); // should be called only once...
  37. _ASSERT (m_pHeaderCtrl == NULL); // should be called only once...
  38. m_pConsole = lpConsole; // hang onto this
  39. HRESULT hresult = lpConsole->QueryInterface(IID_IResultData, (VOID**)&m_pResultData);
  40. _ASSERT (m_pResultData != NULL);
  41. hresult = lpConsole->QueryInterface(IID_IHeaderCtrl, (VOID**)&m_pHeaderCtrl);
  42. _ASSERT (m_pHeaderCtrl != NULL);
  43. if (m_pHeaderCtrl) // Give the console the header control interface pointer
  44. lpConsole->SetHeader(m_pHeaderCtrl);
  45. #ifdef TODO_ADD_THIS_LATER
  46. hr = lpConsole->QueryResultImageList(&m_pImageResult);
  47. _ASSERT(hr == S_OK);
  48. hr = lpConsole->QueryConsoleVerb(&m_pConsoleVerb);
  49. _ASSERT(hr == S_OK);
  50. // Load the bitmaps from the dll for the results pane
  51. m_hbmp16x16 = LoadBitmap(g_hinst, MAKEINTRESOURCE(IDB_RESULT_16x16));
  52. _ASSERT(m_hbmp16x16);
  53. m_hbmp32x32 = LoadBitmap(g_hinst, MAKEINTRESOURCE(IDB_RESULT_32x32));
  54. _ASSERT(m_hbmp32x32);
  55. #endif
  56. return hresult;
  57. }
  58. HRESULT CComponent::Destroy (long cookie)
  59. {
  60. if (m_pResultData)
  61. {
  62. m_pResultData->Release ();
  63. m_pResultData = NULL;
  64. }
  65. if (m_pHeaderCtrl)
  66. {
  67. m_pHeaderCtrl->Release ();
  68. m_pHeaderCtrl = NULL;
  69. }
  70. // hmmm... I wonder if I have to release my IConsole pointer? it doesn't look like it....
  71. return S_OK;
  72. }
  73. HRESULT CComponent::Notify (LPDATAOBJECT lpDataObject, MMC_NOTIFY_TYPE event, long arg, long param)
  74. {
  75. switch (event)
  76. {
  77. case MMCN_SHOW: return OnShow (lpDataObject, arg, param);
  78. case MMCN_ADD_IMAGES: return OnAddImages (lpDataObject, arg, param);
  79. case MMCN_DBLCLICK: return OnDblClick (lpDataObject, arg, param);
  80. case MMCN_SELECT: // return OnSelect (lpDataObject, arg, param);
  81. break;
  82. case MMCN_REFRESH: // return OnRefresh (lpDataObject, arg, param);
  83. case MMCN_VIEW_CHANGE:
  84. case MMCN_CLICK:
  85. case MMCN_BTN_CLICK:
  86. case MMCN_ACTIVATE:
  87. case MMCN_MINIMIZED:
  88. break;
  89. case MMCN_LISTPAD: return OnListPad (lpDataObject, arg, param);
  90. case MMCN_RESTORE_VIEW: return OnRestoreView (lpDataObject, arg, param);
  91. default:
  92. return E_UNEXPECTED;
  93. }
  94. return S_OK;
  95. }
  96. HRESULT CComponent::GetResultViewType (long cookie, LPOLESTR* ppViewType, long* pViewOptions)
  97. {
  98. *ppViewType = NULL;
  99. *pViewOptions = MMC_VIEW_OPTIONS_NONE;
  100. // only allow taskpad when root is selected
  101. if (cookie != 0)
  102. m_IsTaskPad = 0;
  103. // special case for taskpads only
  104. if (m_IsTaskPad != 0)
  105. {
  106. USES_CONVERSION;
  107. TCHAR szBuffer[MAX_PATH*2]; // a little extra
  108. lstrcpy (szBuffer, _T("res://"));
  109. TCHAR * temp = szBuffer + lstrlen(szBuffer);
  110. switch (m_IsTaskPad)
  111. {
  112. case IDM_CUSTOMPAD:
  113. // get "res://"-type string for custom taskpad
  114. ::GetModuleFileName (g_hinst, temp, MAX_PATH);
  115. lstrcat (szBuffer, _T("/default.htm"));
  116. break;
  117. case IDM_TASKPAD:
  118. // get "res://"-type string for custom taskpad
  119. ::GetModuleFileName (NULL, temp, MAX_PATH);
  120. lstrcat (szBuffer, _T("/default.htm"));
  121. break;
  122. case IDM_TASKPAD_WALLPAPER_OPTIONS:
  123. // get "res://"-type string for custom taskpad
  124. ::GetModuleFileName (NULL, temp, MAX_PATH);
  125. lstrcat (szBuffer, _T("/default.htm#wallpaper_options"));
  126. break;
  127. case IDM_TASKPAD_LISTVIEW:
  128. // get "res://"-type string for custom taskpad
  129. // ::GetModuleFileName (g_hinst, temp, MAX_PATH);
  130. // lstrcat (szBuffer, _T("/listview.htm"));
  131. ::GetModuleFileName (NULL, temp, MAX_PATH);
  132. lstrcat (szBuffer, _T("/horizontal.htm"));
  133. break;
  134. case IDM_DEFAULT_LISTVIEW:
  135. // get "res://"-type string for custom taskpad
  136. ::GetModuleFileName (NULL, temp, MAX_PATH);
  137. lstrcat (szBuffer, _T("/listpad.htm"));
  138. break;
  139. default:
  140. _ASSERT (0);
  141. return S_FALSE;
  142. }
  143. // return URL
  144. *ppViewType = CoTaskDupString (T2OLE(szBuffer));
  145. if (!*ppViewType)
  146. return E_OUTOFMEMORY; // or S_FALSE ???
  147. return S_OK;
  148. }
  149. return S_FALSE; // false for default
  150. }
  151. HRESULT CComponent::QueryDataObject (long cookie, DATA_OBJECT_TYPES type, LPDATAOBJECT* ppDataObject)
  152. {
  153. _ASSERT (ppDataObject != NULL);
  154. CDataObject *pdo = new CDataObject (cookie, type);
  155. *ppDataObject = pdo;
  156. if (!pdo)
  157. return E_OUTOFMEMORY;
  158. return S_OK;
  159. }
  160. HRESULT CComponent::GetDisplayInfo (RESULTDATAITEM* prdi)
  161. {
  162. _ASSERT(prdi != NULL);
  163. if (prdi)
  164. {
  165. // Provide strings for scope tree items
  166. if (prdi->bScopeItem == TRUE)
  167. {
  168. if (prdi->mask & RDI_STR)
  169. {
  170. if (prdi->nCol == 0)
  171. {
  172. switch (prdi->lParam)
  173. {
  174. case DISPLAY_MANAGER_WALLPAPER:
  175. if (m_toggle == FALSE)
  176. prdi->str = (LPOLESTR)L"Wallpaper";
  177. else
  178. prdi->str = (LPOLESTR)L"RenamedWallpaper";
  179. break;
  180. case DISPLAY_MANAGER_PATTERN:
  181. prdi->str = (LPOLESTR)L"Pattern";
  182. break;
  183. case DISPLAY_MANAGER_PATTERN_CHILD:
  184. prdi->str = (LPOLESTR)L"Pattern child";
  185. break;
  186. default:
  187. prdi->str = (LPOLESTR)L"Hey! You shouldn't see this!";
  188. break;
  189. }
  190. }
  191. else if (prdi->nCol == 1)
  192. prdi->str = (LPOLESTR)L"Display Option";
  193. else
  194. prdi->str = (LPOLESTR)L"Error:Should not see this!";
  195. }
  196. if (prdi->mask & RDI_IMAGE)
  197. prdi->nImage = 0;
  198. }
  199. else
  200. {
  201. // listpad uses lparam on -1, anything else is wallpaper
  202. if (prdi->lParam == -1)
  203. {
  204. if (prdi->mask & RDI_STR)
  205. if (m_toggleEntry == FALSE)
  206. prdi->str = (LPOLESTR)L"here's a listpad entry";
  207. else
  208. prdi->str = (LPOLESTR)L"Changed listpad entry";
  209. if (prdi->mask & RDI_IMAGE)
  210. prdi->nImage = 0;
  211. }
  212. else
  213. {
  214. lParamWallpaper * lpwp = NULL;
  215. if (prdi->lParam)
  216. lpwp = (lParamWallpaper *)prdi->lParam;
  217. if (prdi->mask & RDI_STR)
  218. {
  219. if (prdi->nCol == 0)
  220. {
  221. if (lpwp && (!IsBadReadPtr (lpwp, sizeof (lParamWallpaper))))
  222. prdi->str = lpwp->filename;
  223. else
  224. prdi->str = (LPOLESTR)L"hmm.... error";
  225. }
  226. else if (prdi->nCol == 1)
  227. prdi->str = (LPOLESTR)L"result pane display name col 1";
  228. else
  229. prdi->str = (LPOLESTR)L"Error:Should not see this!";
  230. }
  231. if (prdi->mask & RDI_IMAGE)
  232. {
  233. switch (prdi->lParam)
  234. {
  235. case DISPLAY_MANAGER_WALLPAPER:
  236. case DISPLAY_MANAGER_PATTERN:
  237. case DISPLAY_MANAGER_PATTERN_CHILD:
  238. prdi->nImage = 0;
  239. break;
  240. default:
  241. prdi->nImage = 3;
  242. break;
  243. }
  244. }
  245. }
  246. }
  247. }
  248. return S_OK;
  249. }
  250. HRESULT CComponent::CompareObjects (LPDATAOBJECT lpDataObjectA, LPDATAOBJECT lpDataObjectB)
  251. { return E_NOTIMPL;}
  252. // private functions
  253. HRESULT CComponent::OnShow(LPDATAOBJECT pDataObject, long arg, long param)
  254. {
  255. USES_CONVERSION;
  256. CDataObject * pcdo = (CDataObject *)pDataObject;
  257. if (arg == 0)
  258. { // de-selecting: free up resources, if any
  259. if (pcdo->GetCookie() == DISPLAY_MANAGER_WALLPAPER)
  260. {
  261. // enumerate result data items
  262. RESULTDATAITEM rdi;
  263. ZeroMemory(&rdi, sizeof(rdi));
  264. rdi.mask = RDI_PARAM | RDI_STATE;
  265. rdi.nIndex = -1;
  266. while (1)
  267. {
  268. if (m_pResultData->GetNextItem (&rdi) != S_OK)
  269. break;
  270. if (rdi.lParam)
  271. {
  272. lParamWallpaper * lpwp = (lParamWallpaper *)rdi.lParam;
  273. delete lpwp;
  274. }
  275. }
  276. m_pResultData->DeleteAllRsltItems ();
  277. }
  278. return S_OK;
  279. }
  280. // init column headers
  281. _ASSERT (m_pHeaderCtrl != NULL);
  282. m_pHeaderCtrl->InsertColumn (0, L"Name", 0, 120);
  283. if (m_pComponentData)
  284. {
  285. if (m_pResultData) // use large icons by default
  286. m_pResultData->SetViewMode (m_pComponentData->GetViewMode ());
  287. }
  288. // add our stuff
  289. RESULTDATAITEM rdi;
  290. ZeroMemory(&rdi, sizeof(rdi));
  291. rdi.mask = RDI_PARAM | RDI_STR | RDI_IMAGE;
  292. rdi.nImage = (int)MMC_CALLBACK;
  293. rdi.str = MMC_CALLBACK;
  294. if (pcdo->GetCookie () == DISPLAY_MANAGER_WALLPAPER)
  295. {
  296. // enumerate all .bmp files in "c:\winnt.40\" (windows directory)
  297. TCHAR path[MAX_PATH];
  298. GetWindowsDirectory (path, MAX_PATH);
  299. lstrcat (path, _T("\\*.bmp"));
  300. int i = 0;
  301. // first do "(none)"
  302. lParamWallpaper * lpwp = new lParamWallpaper;
  303. wcscpy (lpwp->filename, L"(none)");
  304. rdi.lParam = reinterpret_cast<LONG>(lpwp);
  305. rdi.nImage = i++;
  306. m_pResultData->InsertItem (&rdi);
  307. WIN32_FIND_DATA fd;
  308. ZeroMemory(&fd, sizeof(fd));
  309. HANDLE hFind = FindFirstFile (path, &fd);
  310. if (hFind != INVALID_HANDLE_VALUE)
  311. {
  312. do
  313. {
  314. if ((fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ||
  315. (fd.dwFileAttributes & FILE_ATTRIBUTE_SYSTEM) ||
  316. (fd.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) )
  317. continue; // files only
  318. // new a struct to hold info, and cast to lParam.
  319. lParamWallpaper * lpwp = new lParamWallpaper;
  320. wcscpy (lpwp->filename, T2OLE(fd.cFileName));
  321. // rdi.str = lpwp->filename;
  322. rdi.lParam = reinterpret_cast<LONG>(lpwp);
  323. rdi.nImage = i++;
  324. m_pResultData->InsertItem (&rdi);
  325. } while (FindNextFile (hFind, &fd) == TRUE);
  326. FindClose(hFind);
  327. }
  328. }
  329. else
  330. {
  331. // DISPLAY_MANAGER_PATTERN
  332. ; // hard code a few things.
  333. }
  334. return S_OK;
  335. }
  336. #include <windowsx.h>
  337. inline long LongScanBytes (long bits)
  338. {
  339. bits += 31;
  340. bits /= 8;
  341. bits &= ~3;
  342. return bits;
  343. }
  344. void GetBitmaps (TCHAR * fn, HBITMAP * smallbm, HBITMAP * largebm)
  345. {
  346. *smallbm = *largebm = (HBITMAP)NULL; // in case of error
  347. // read bmp file into DIB
  348. DWORD dwRead;
  349. HANDLE hf = CreateFile (fn, GENERIC_READ,
  350. FILE_SHARE_READ, (LPSECURITY_ATTRIBUTES) NULL,
  351. OPEN_EXISTING, FILE_ATTRIBUTE_READONLY,
  352. (HANDLE) NULL);
  353. if (hf != (HANDLE)HFILE_ERROR)
  354. {
  355. BITMAPFILEHEADER bmfh;
  356. ReadFile(hf, &bmfh, sizeof(BITMAPFILEHEADER), &dwRead, (LPOVERLAPPED)NULL);
  357. BITMAPINFOHEADER bmih;
  358. ReadFile(hf, &bmih, sizeof(BITMAPINFOHEADER), &dwRead, (LPOVERLAPPED)NULL);
  359. // Allocate memory for the DIB
  360. DWORD dwSize = sizeof(BITMAPINFOHEADER);
  361. if (bmih.biBitCount*bmih.biPlanes <= 8)
  362. dwSize += (sizeof(RGBQUAD))*(1<<(bmih.biBitCount*bmih.biPlanes));
  363. dwSize += bmih.biHeight*LongScanBytes (bmih.biWidth*(bmih.biBitCount*bmih.biPlanes));
  364. BITMAPINFOHEADER * lpbmih = (BITMAPINFOHEADER *)GlobalAllocPtr(GHND, dwSize);
  365. if (lpbmih)
  366. {
  367. *lpbmih = bmih;
  368. RGBQUAD * rgbq = (RGBQUAD *)&lpbmih[1];
  369. char * bits = (char *)rgbq;
  370. if (bmih.biBitCount*bmih.biPlanes <= 8)
  371. {
  372. ReadFile (hf, rgbq,
  373. ((1<<(bmih.biBitCount*bmih.biPlanes))*sizeof(RGBQUAD)),
  374. &dwRead, (LPOVERLAPPED) NULL);
  375. bits += dwRead;
  376. }
  377. SetFilePointer (hf, bmfh.bfOffBits, NULL, FILE_BEGIN);
  378. ReadFile (hf, bits, dwSize - (bits - (char *)lpbmih),
  379. &dwRead, (LPOVERLAPPED) NULL);
  380. // we should now have a decent DIB
  381. HWND hwnd = GetDesktopWindow ();
  382. HDC hdc = GetDC (hwnd);
  383. HDC hcompdc = CreateCompatibleDC (hdc);
  384. // SetStretchBltMode (hcompdc, COLORONCOLOR);
  385. // SetStretchBltMode (hcompdc, WHITEONBLACK);
  386. SetStretchBltMode (hcompdc, HALFTONE);
  387. HGDIOBJ hold;
  388. // *smallbm = CreateCompatibleBitmap (hcompdc, 16, 16);
  389. *smallbm = CreateCompatibleBitmap (hdc, 16, 16);
  390. if (*smallbm)
  391. {
  392. hold = SelectObject (hcompdc, (HGDIOBJ)(*smallbm));
  393. StretchDIBits (hcompdc, // handle of device context
  394. 0, 0, 16, 16,
  395. 0, 0,
  396. lpbmih->biWidth,
  397. lpbmih->biHeight,
  398. (CONST VOID *)bits,
  399. (CONST BITMAPINFO *)lpbmih,
  400. DIB_RGB_COLORS, // usage
  401. SRCCOPY // raster operation code
  402. );
  403. SelectObject (hcompdc, hold);
  404. }
  405. // *largebm = CreateCompatibleBitmap (hcompdc, 32, 32);
  406. *largebm = CreateCompatibleBitmap (hdc, 32, 32);
  407. if (*largebm)
  408. {
  409. // testing
  410. /*
  411. HDC nullDC = GetDC (NULL);
  412. hold = SelectObject (nullDC, (HGDIOBJ)*largebm);
  413. StretchDIBits (nullDC, // handle of device context
  414. 0, 0, lpbmih->biWidth, lpbmih->biHeight,
  415. 0, 0,
  416. lpbmih->biWidth,
  417. lpbmih->biHeight,
  418. (CONST VOID *)bits,
  419. (CONST BITMAPINFO *)lpbmih,
  420. DIB_RGB_COLORS, // usage
  421. SRCCOPY // raster operation code
  422. );
  423. SelectObject (hdc, hold);
  424. ReleaseDC (NULL, nullDC);
  425. */
  426. // testing
  427. hold = SelectObject (hcompdc, (HGDIOBJ)*largebm);
  428. StretchDIBits (hcompdc, // handle of device context
  429. 0, 0, 32, 32,
  430. 0, 0,
  431. lpbmih->biWidth,
  432. lpbmih->biHeight,
  433. (CONST VOID *)bits,
  434. (CONST BITMAPINFO *)lpbmih,
  435. DIB_RGB_COLORS, // usage
  436. SRCCOPY // raster operation code
  437. );
  438. SelectObject (hcompdc, hold);
  439. }
  440. DeleteDC (hcompdc);
  441. ReleaseDC (hwnd, hdc);
  442. GlobalFreePtr (lpbmih);
  443. }
  444. CloseHandle(hf);
  445. }
  446. }
  447. HRESULT CComponent::OnAddImages (LPDATAOBJECT pDataObject, long arg, long param)
  448. {
  449. IImageList * pImageList = (IImageList *)arg;
  450. HSCOPEITEM hsi = (HSCOPEITEM)param;
  451. _ASSERT (pImageList != NULL);
  452. CDataObject * cdo = (CDataObject *)pDataObject;
  453. if (cdo->GetCookie () != DISPLAY_MANAGER_WALLPAPER)
  454. {
  455. if (cdo->GetCookie () == 0)
  456. {
  457. g_root_scope_item = hsi;
  458. if (cdo->GetType () == CCT_RESULT)
  459. {
  460. // add a custom image
  461. HBITMAP hbmSmall, hbmLarge;
  462. GetBitmaps (_T("c:\\winnt\\dax.bmp"), &hbmSmall, &hbmLarge);
  463. pImageList->ImageListSetStrip ((long *)hbmSmall,
  464. (long *)hbmLarge,
  465. 3, RGB(1, 0, 254));
  466. DeleteObject (hbmSmall);
  467. DeleteObject (hbmLarge);
  468. }
  469. }
  470. return S_OK; // TODO: for now
  471. }
  472. // create HBITMAPs from bmp files
  473. int i = 0;
  474. // create some invisible bitmaps
  475. {
  476. BYTE bits[] = {
  477. 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
  478. 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
  479. 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
  480. 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
  481. 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
  482. 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
  483. 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
  484. 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255};
  485. HBITMAP hbmSmall = CreateBitmap (16, 16, 1, 1, (CONST VOID *)bits);
  486. HBITMAP hbmLarge = CreateBitmap (32, 32, 1, 1, (CONST VOID *)bits);
  487. pImageList->ImageListSetStrip ((long *)hbmSmall,
  488. (long *)hbmLarge,
  489. i++, RGB(1, 0, 254));
  490. DeleteObject (hbmSmall);
  491. DeleteObject (hbmLarge);
  492. }
  493. TCHAR path[MAX_PATH];
  494. GetWindowsDirectory (path, MAX_PATH);
  495. TCHAR * pfqfn = path + lstrlen(path) + 1;
  496. lstrcat (path, _T("\\*.bmp"));
  497. WIN32_FIND_DATA fd;
  498. ZeroMemory(&fd, sizeof(fd));
  499. HANDLE hFind = FindFirstFile (path, &fd);
  500. if (hFind != INVALID_HANDLE_VALUE)
  501. {
  502. do
  503. {
  504. if ((fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ||
  505. (fd.dwFileAttributes & FILE_ATTRIBUTE_SYSTEM) ||
  506. (fd.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) )
  507. continue; // files only
  508. lstrcpy (pfqfn, fd.cFileName);
  509. HBITMAP hbmSmall, hbmLarge;
  510. GetBitmaps (path, &hbmSmall, &hbmLarge);
  511. pImageList->ImageListSetStrip ((long *)hbmSmall,
  512. (long *)hbmLarge,
  513. i++, RGB(1, 0, 254));
  514. DeleteObject (hbmSmall);
  515. DeleteObject (hbmLarge);
  516. } while (FindNextFile (hFind, &fd) == TRUE);
  517. FindClose(hFind);
  518. }
  519. return S_OK;
  520. }
  521. #ifdef TODO_FIGURE_THIS_OUT
  522. HRESULT CComponent::OnSelect(LPDATAOBJECT pDataObject, long arg, long param)
  523. {
  524. if (!HIWORD(arg)) // being de-selected
  525. return S_OK; // don't care about this
  526. if (LOWORD(arg)) // in scope pane
  527. return S_OK; // don't care about this, either
  528. CDataObject *cdo = (CDataObject *)pDataObject;
  529. if (cdo->GetCookie() != DISPLAY_MANAGER_WALLPAPER)
  530. return S_OK; // TODO: do patterns later
  531. //
  532. // Bail if we couldn't get the console verb interface, or if the
  533. // selected item is the root;
  534. //
  535. if (!m_pConsoleVerb || pdo->GetCookieType() == COOKIE_IS_ROOT)
  536. {
  537. return S_OK;
  538. }
  539. //
  540. // Use selections and set which verbs are allowed
  541. //
  542. if (bScope)
  543. {
  544. if (pdo->GetCookieType() == COOKIE_IS_STATUS)
  545. {
  546. hr = m_pConsoleVerb->SetVerbState(MMC_VERB_REFRESH, ENABLED, TRUE);
  547. _ASSERT(hr == S_OK);
  548. }
  549. }
  550. else
  551. {
  552. //
  553. // Selection is in the result pane
  554. //
  555. }
  556. return S_OK;
  557. }
  558. #endif
  559. HRESULT CComponent::OnDblClick(LPDATAOBJECT pDataObject, long arg, long param)
  560. {//see note in CComponent::Command, below !!!
  561. _ASSERT (pDataObject);
  562. _ASSERT (m_pResultData);
  563. // hmmm: no documentation on arg or param....
  564. CDataObject *cdo = (CDataObject *)pDataObject;
  565. lParamWallpaper * lpwp = (lParamWallpaper *)cdo->GetCookie();
  566. if (lpwp)
  567. if (!IsBadReadPtr (lpwp, sizeof (lParamWallpaper)))
  568. {
  569. USES_CONVERSION;
  570. SystemParametersInfo (SPI_SETDESKWALLPAPER,
  571. 0,
  572. (void *)OLE2T(lpwp->filename),
  573. SPIF_UPDATEINIFILE | SPIF_SENDWININICHANGE);
  574. }
  575. return S_OK;
  576. }
  577. HRESULT CComponent::OnListPad (LPDATAOBJECT pDataObject, long arg, long param)
  578. {
  579. if (arg == TRUE)
  580. { // attaching
  581. IImageList* pImageList = NULL;
  582. m_pConsole->QueryResultImageList (&pImageList);
  583. if (pImageList)
  584. {
  585. HBITMAP hbmSmall, hbmLarge;
  586. GetBitmaps (_T("c:\\winnt\\dax.bmp"), &hbmSmall, &hbmLarge);
  587. pImageList->ImageListSetStrip ((long *)hbmSmall,
  588. (long *)hbmLarge,
  589. 0, RGB(1, 0, 254));
  590. pImageList->Release();
  591. }
  592. // m_pResultData->SetViewMode (LVS_ICON);
  593. m_pResultData->SetViewMode (LVS_REPORT);
  594. m_pHeaderCtrl->InsertColumn (0, L"Name", 0, 170);
  595. // populate listview control via IResultData
  596. RESULTDATAITEM rdi;
  597. ZeroMemory(&rdi, sizeof(rdi));
  598. rdi.mask = RDI_PARAM | RDI_STR | RDI_IMAGE;
  599. rdi.nImage = (int)MMC_CALLBACK;
  600. rdi.str = MMC_CALLBACK;
  601. rdi.lParam = -1;
  602. for (int i=0; i<11; i++)
  603. m_pResultData->InsertItem (&rdi);
  604. }
  605. return S_OK;
  606. }
  607. HRESULT CComponent::OnRestoreView (LPDATAOBJECT pDataObject, long arg, long param)
  608. {
  609. MMC_RESTORE_VIEW* pmrv = (MMC_RESTORE_VIEW*)arg;
  610. BOOL * pb = (BOOL *)param;
  611. _ASSERT (pmrv);
  612. _ASSERT (pb);
  613. // some versioning (not really necessary since this is the new rev.)
  614. if (pmrv->dwSize < sizeof(MMC_RESTORE_VIEW))
  615. return E_FAIL; // version too old
  616. // maintain my internal state
  617. if (pmrv->pViewType)
  618. {
  619. USES_CONVERSION;
  620. // there are going to be two cases:
  621. // 1. custom html pages (res in my .dll)
  622. // 2. default html pages (res in mmc.exe)
  623. // get path to my .dll and compare to pViewType
  624. TCHAR szPath[MAX_PATH];
  625. ::GetModuleFileName (g_hinst, szPath, MAX_PATH);
  626. if (wcsstr (pmrv->pViewType, T2OLE(szPath)))
  627. {
  628. // custom html
  629. if (wcsstr (pmrv->pViewType, L"/default.htm"))
  630. m_IsTaskPad = IDM_CUSTOMPAD;
  631. else
  632. if (wcsstr (pmrv->pViewType, L"/listview.htm"))
  633. m_IsTaskPad = IDM_TASKPAD_LISTVIEW;
  634. else
  635. {
  636. // this will happen when you can get to a taskpad by clicking
  637. // on a task, but there is no corresponding view menu option
  638. // to select. Therefore do something reasonable.
  639. // In my case, I can get to "wallpapr.htm" by either custom
  640. // or default routes (which is probably rather unusual). So,
  641. // I think I'll just leave the m_IsTaskPad value alone if
  642. // it's non-NULL, else pick one.
  643. if (m_IsTaskPad == 0)
  644. m_IsTaskPad = IDM_TASKPAD;
  645. }
  646. }
  647. else
  648. {
  649. // default html
  650. if (wcsstr (pmrv->pViewType, L"/default.htm#wallpaper_options"))
  651. m_IsTaskPad = IDM_TASKPAD_WALLPAPER_OPTIONS;
  652. else
  653. if (wcsstr (pmrv->pViewType, L"/default.htm"))
  654. m_IsTaskPad = IDM_TASKPAD;
  655. else
  656. if (wcsstr (pmrv->pViewType, L"/listpad.htm"))
  657. m_IsTaskPad = IDM_DEFAULT_LISTVIEW;
  658. else
  659. if (wcsstr (pmrv->pViewType, L"/horizontal.htm"))
  660. m_IsTaskPad = IDM_TASKPAD_LISTVIEW;
  661. else
  662. {
  663. _ASSERT (0 && "can't find MMC's resources");
  664. return E_FAIL;
  665. }
  666. }
  667. }
  668. else
  669. m_IsTaskPad = 0;
  670. *pb = TRUE; // I'm handling the new history notify
  671. return S_OK;
  672. }
  673. // IExtendContextMenu
  674. HRESULT CComponent::AddMenuItems (LPDATAOBJECT pDataObject, LPCONTEXTMENUCALLBACK pContextMenuCallback, long *pInsertionAllowed)
  675. {
  676. CDataObject * cdo = (CDataObject *)pDataObject;
  677. switch (cdo->GetCookie ())
  678. {
  679. case DISPLAY_MANAGER_WALLPAPER:
  680. case DISPLAY_MANAGER_PATTERN:
  681. return S_OK;
  682. case 0: // root
  683. // this is when they pull down the view menu
  684. if (*pInsertionAllowed & CCM_INSERTIONALLOWED_VIEW)
  685. {
  686. // add my taskpads and delete thingy
  687. CONTEXTMENUITEM m[] = {
  688. {L"Custom TaskPad", L"Custom TaskPad", IDM_CUSTOMPAD, CCM_INSERTIONPOINTID_PRIMARY_VIEW, 0, 0},
  689. {L"Default TaskPad", L"Default TaskPad", IDM_TASKPAD, CCM_INSERTIONPOINTID_PRIMARY_VIEW, 0, 0},
  690. {L"Wallpaper Options TaskPad", L"Wallpaper Options TaskPad", IDM_TASKPAD_WALLPAPER_OPTIONS, CCM_INSERTIONPOINTID_PRIMARY_VIEW, 0, 0},
  691. {L"Horizontal ListView", L"ListView TaskPad", IDM_TASKPAD_LISTVIEW, CCM_INSERTIONPOINTID_PRIMARY_VIEW, 0, 0},
  692. {L"Default ListPad", L"Default ListPad", IDM_DEFAULT_LISTVIEW, CCM_INSERTIONPOINTID_PRIMARY_VIEW, 0, 0},
  693. {L"DeleteRootChildren", L"just testing", IDM_DELETECHILDREN, CCM_INSERTIONPOINTID_PRIMARY_VIEW, 0, 0},
  694. {L"RenameRoot", L"just testing", IDM_RENAMEROOT, CCM_INSERTIONPOINTID_PRIMARY_VIEW, 0, 0},
  695. {L"RenameWallPaperNode",L"just testing", IDM_RENAMEWALL, CCM_INSERTIONPOINTID_PRIMARY_VIEW, 0, 0},
  696. {L"ChangeIcon", L"just testing", IDM_CHANGEICON, CCM_INSERTIONPOINTID_PRIMARY_VIEW, 0, 0},
  697. {L"Pre-Load", L"just testing", IDM_PRELOAD, CCM_INSERTIONPOINTID_PRIMARY_VIEW, 0, 0},
  698. {L"Test IConsoleVerb", L"just testing", IDM_CONSOLEVERB, CCM_INSERTIONPOINTID_PRIMARY_VIEW, 0, 0}
  699. };
  700. if (m_IsTaskPad == IDM_CUSTOMPAD) m[0].fFlags = MF_CHECKED;
  701. if (m_IsTaskPad == IDM_TASKPAD) m[1].fFlags = MF_CHECKED;
  702. if (m_IsTaskPad == IDM_TASKPAD_WALLPAPER_OPTIONS) m[2].fFlags = MF_CHECKED;
  703. if (m_IsTaskPad == IDM_TASKPAD_LISTVIEW) m[3].fFlags = MF_CHECKED;
  704. if (m_IsTaskPad == IDM_DEFAULT_LISTVIEW) m[4].fFlags = MF_CHECKED;
  705. if (m_pComponentData->GetPreload() == TRUE) m[9].fFlags = MF_CHECKED;
  706. pContextMenuCallback->AddItem (&m[0]);
  707. pContextMenuCallback->AddItem (&m[1]);
  708. pContextMenuCallback->AddItem (&m[2]);
  709. pContextMenuCallback->AddItem (&m[3]);
  710. pContextMenuCallback->AddItem (&m[4]);
  711. pContextMenuCallback->AddItem (&m[5]);
  712. pContextMenuCallback->AddItem (&m[6]);
  713. pContextMenuCallback->AddItem (&m[7]);
  714. pContextMenuCallback->AddItem (&m[8]);
  715. pContextMenuCallback->AddItem (&m[9]);
  716. return pContextMenuCallback->AddItem (&m[10]);
  717. }
  718. return S_OK;
  719. default:
  720. break;
  721. }
  722. // add to context menu, only if in result pane:
  723. // this is when they right-click on the result pane.
  724. if (cdo->GetType() == CCT_RESULT)
  725. {
  726. CONTEXTMENUITEM cmi;
  727. cmi.strName = L"Center";
  728. cmi.strStatusBarText = L"Center Desktop Wallpaper";
  729. cmi.lCommandID = IDM_CENTER;
  730. cmi.lInsertionPointID = CCM_INSERTIONPOINTID_PRIMARY_TOP;
  731. cmi.fFlags = 0;
  732. cmi.fSpecialFlags = CCM_SPECIAL_DEFAULT_ITEM;
  733. pContextMenuCallback->AddItem (&cmi);
  734. cmi.strName = L"Tile";
  735. cmi.strStatusBarText = L"Tile Desktop Wallpaper";
  736. cmi.lCommandID = IDM_TILE;
  737. cmi.lInsertionPointID = CCM_INSERTIONPOINTID_PRIMARY_TOP;
  738. cmi.fFlags = 0;
  739. cmi.fSpecialFlags = 0; // CCM_SPECIAL_DEFAULT_ITEM;
  740. pContextMenuCallback->AddItem (&cmi);
  741. cmi.strName = L"Stretch";
  742. cmi.strStatusBarText = L"Stretch Desktop Wallpaper";
  743. cmi.lCommandID = IDM_STRETCH;
  744. cmi.lInsertionPointID = CCM_INSERTIONPOINTID_PRIMARY_TOP;
  745. cmi.fFlags = 0;
  746. cmi.fSpecialFlags = 0; // CCM_SPECIAL_DEFAULT_ITEM;
  747. pContextMenuCallback->AddItem (&cmi);
  748. }
  749. return S_OK;
  750. }
  751. HRESULT CComponent::Command (long nCommandID, LPDATAOBJECT pDataObject)
  752. {
  753. m_IsTaskPad = 0;
  754. CDataObject * cdo = reinterpret_cast<CDataObject *>(pDataObject);
  755. switch (nCommandID)
  756. {
  757. case IDM_TILE:
  758. case IDM_CENTER:
  759. case IDM_STRETCH:
  760. // write registry key:
  761. {
  762. HKEY hkey;
  763. HRESULT r = RegOpenKeyEx (HKEY_CURRENT_USER,
  764. _T("Control Panel\\Desktop"),
  765. 0, KEY_ALL_ACCESS, &hkey);
  766. if (r == ERROR_SUCCESS)
  767. {
  768. // write new value(s)
  769. DWORD dwType = REG_SZ;
  770. TCHAR szBuffer[2];
  771. // first do "TileWallpaper"
  772. if (nCommandID == IDM_TILE)
  773. lstrcpy (szBuffer, _T("1"));
  774. else
  775. lstrcpy (szBuffer, _T("0"));
  776. DWORD dwCount = sizeof(TCHAR)*(1+lstrlen (szBuffer));
  777. r = RegSetValueEx (hkey,
  778. (LPCTSTR)_T("TileWallpaper"),
  779. NULL,
  780. dwType,
  781. (CONST BYTE *)&szBuffer,
  782. dwCount);
  783. // then do "WallpaperStyle"
  784. if (nCommandID == IDM_STRETCH)
  785. lstrcpy (szBuffer, _T("2"));
  786. else
  787. lstrcpy (szBuffer, _T("0"));
  788. r = RegSetValueEx (hkey,
  789. (LPCTSTR)_T("WallpaperStyle"),
  790. NULL,
  791. dwType,
  792. (CONST BYTE *)&szBuffer,
  793. dwCount);
  794. // close up shop
  795. RegCloseKey(hkey);
  796. _ASSERT(r == ERROR_SUCCESS);
  797. /*
  798. [HKEY_CURRENT_USER\Control Panel\Desktop]
  799. "CoolSwitch"="1"
  800. "CoolSwitchRows"="3"
  801. "CoolSwitchColumns"="7"
  802. "CursorBlinkRate"="530"
  803. "ScreenSaveTimeOut"="900"
  804. "ScreenSaveActive"="0"
  805. "ScreenSaverIsSecure"="0"
  806. "Pattern"="(None)"
  807. "Wallpaper"="C:\\WINNT\\dax.bmp"
  808. "TileWallpaper"="0"
  809. "GridGranularity"="0"
  810. "IconSpacing"="75"
  811. "IconTitleWrap"="1"
  812. "IconTitleFaceName"="MS Sans Serif"
  813. "IconTitleSize"="9"
  814. "IconTitleStyle"="0"
  815. "DragFullWindows"="1"
  816. "HungAppTimeout"="5000"
  817. "WaitToKillAppTimeout"="20000"
  818. "AutoEndTasks"="0"
  819. "FontSmoothing"="0"
  820. "MenuShowDelay"="400"
  821. "DragHeight"="2"
  822. "DragWidth"="2"
  823. "WheelScrollLines"="3"
  824. "WallpaperStyle"="0"
  825. */
  826. }
  827. }
  828. break;
  829. case IDM_TASKPAD:
  830. case IDM_CUSTOMPAD:
  831. case IDM_TASKPAD_LISTVIEW:
  832. case IDM_DEFAULT_LISTVIEW:
  833. case IDM_TASKPAD_WALLPAPER_OPTIONS:
  834. if (cdo->GetCookie() == 0)
  835. {
  836. HSCOPEITEM root = m_pComponentData->GetRoot();
  837. if (root)
  838. {
  839. // we should now be ready for taskpad "view"
  840. m_IsTaskPad = nCommandID; // set before selecting node
  841. // cause new view to be "created"
  842. m_pConsole->SelectScopeItem (root);
  843. }
  844. }
  845. return S_OK;
  846. case IDM_DELETECHILDREN:
  847. if (g_root_scope_item != 0)
  848. m_pComponentData->myDeleteItem (g_root_scope_item, TRUE);
  849. return S_OK;
  850. case IDM_RENAMEROOT:
  851. if (g_root_scope_item != 0)
  852. m_pComponentData->myRenameItem (g_root_scope_item, L"Yippee!");
  853. return S_OK;
  854. case IDM_RENAMEWALL:
  855. if (m_toggle)
  856. m_toggle = FALSE;
  857. else
  858. m_toggle = TRUE;
  859. m_pComponentData->myRenameItem (m_pComponentData->GetWallPaperNode(), NULL);
  860. return S_OK;
  861. case IDM_CHANGEICON:
  862. m_pComponentData->myChangeIcon ();
  863. return S_OK;
  864. case IDM_PRELOAD:
  865. m_pComponentData->myPreLoad();
  866. return S_OK;
  867. case IDM_CONSOLEVERB:
  868. TestConsoleVerb();
  869. return S_OK;
  870. default:
  871. return E_UNEXPECTED;
  872. }
  873. return OnDblClick (pDataObject, NULL, NULL); // note what I'm passing!
  874. }
  875. long CComponent::GetViewMode ()
  876. {
  877. long vm = LVS_ICON;
  878. if (m_pResultData)
  879. m_pResultData->GetViewMode (&vm);
  880. return vm;
  881. }
  882. ///////////////////////////////////////////////////////////////////////////////
  883. // IExtendTaskPad interface members
  884. HRESULT CComponent::TaskNotify (IDataObject * pdo, VARIANT * pvarg, VARIANT * pvparam)
  885. {
  886. if (pvarg->vt == VT_BSTR)
  887. {
  888. USES_CONVERSION;
  889. OLECHAR * path = pvarg->bstrVal;
  890. // replace any '*' with ' ': see enumtask.cpp
  891. // hash mechanism can't handle spaces, and
  892. // filenames can't have '*'s, so this works out ok.
  893. OLECHAR * temp;
  894. while (temp = wcschr (path, '*'))
  895. *temp = ' ';
  896. // now go do it!
  897. SystemParametersInfo (SPI_SETDESKWALLPAPER,
  898. 0,
  899. (void *)OLE2T(path),
  900. SPIF_UPDATEINIFILE | SPIF_SENDWININICHANGE);
  901. return S_OK;
  902. }
  903. if (pvarg->vt == VT_I4)
  904. {
  905. switch (pvarg->lVal)
  906. {
  907. case 1:
  908. if (m_pComponentData->GetWallPaperNode () != (HSCOPEITEM)0)
  909. {
  910. _ASSERT (m_pConsole != NULL);
  911. m_pConsole->SelectScopeItem (m_pComponentData->GetWallPaperNode());
  912. return S_OK;
  913. }
  914. break;
  915. case 2: // Center
  916. return ApplyOption (IDM_CENTER);
  917. case 3: // Tile
  918. return ApplyOption (IDM_TILE);
  919. case 4: // Stretch
  920. return ApplyOption (IDM_STRETCH);
  921. case -1:
  922. if (m_toggleEntry == FALSE)
  923. m_toggleEntry = TRUE;
  924. else
  925. m_toggleEntry = FALSE;
  926. // empty and repopulate listpad
  927. m_pResultData->DeleteAllRsltItems();
  928. m_pHeaderCtrl->DeleteColumn (0);
  929. OnListPad (NULL, TRUE, 0);
  930. return S_OK;
  931. }
  932. }
  933. ::MessageBox (NULL, _T("unrecognized task notification"), _T("Display Manager"), MB_OK);
  934. return S_OK;
  935. }
  936. HRESULT CComponent::GetTitle (LPOLESTR szGroup, LPOLESTR * pszTitle)
  937. {
  938. *pszTitle = CoTaskDupString (L"Display Manager TaskPad");
  939. if (!pszTitle)
  940. return E_OUTOFMEMORY;
  941. return S_OK;
  942. }
  943. HRESULT CComponent::GetDescriptiveText (LPOLESTR szGroup, LPOLESTR * pszTitle)
  944. {
  945. *pszTitle = CoTaskDupString (L"Bill's Handy-Dandy Display Manager TaskPad Sample");
  946. if (!pszTitle)
  947. return E_OUTOFMEMORY;
  948. return S_OK;
  949. }
  950. HRESULT CComponent::GetBackground (LPOLESTR szGroup, MMC_TASK_DISPLAY_OBJECT * pdo)
  951. {
  952. USES_CONVERSION;
  953. if(NULL==szGroup)
  954. return E_FAIL;
  955. if (szGroup[0] == 0)
  956. {
  957. // bitmap case
  958. pdo->eDisplayType = MMC_TASK_DISPLAY_TYPE_BITMAP;
  959. MMC_TASK_DISPLAY_BITMAP *pdb = &pdo->uBitmap;
  960. // fill out bitmap URL
  961. TCHAR szBuffer[MAX_PATH*2]; // that should be enough
  962. _tcscpy (szBuffer, _T("res://"));
  963. ::GetModuleFileName (g_hinst, szBuffer + _tcslen(szBuffer), MAX_PATH);
  964. _tcscat (szBuffer, _T("/img\\ntbanner.gif"));
  965. pdb->szMouseOverBitmap = CoTaskDupString (T2OLE(szBuffer));
  966. if (pdb->szMouseOverBitmap)
  967. return S_OK;
  968. return E_OUTOFMEMORY;
  969. }
  970. else
  971. {
  972. // symbol case
  973. pdo->eDisplayType = MMC_TASK_DISPLAY_TYPE_SYMBOL;
  974. MMC_TASK_DISPLAY_SYMBOL *pds = &pdo->uSymbol;
  975. // fill out symbol stuff
  976. pds->szFontFamilyName = CoTaskDupString (L"Kingston"); // name of font family
  977. if (pds->szFontFamilyName)
  978. {
  979. TCHAR szBuffer[MAX_PATH*2]; // that should be enough
  980. _tcscpy (szBuffer, _T("res://"));
  981. ::GetModuleFileName (g_hinst, szBuffer + _tcslen(szBuffer), MAX_PATH);
  982. _tcscat (szBuffer, _T("/KINGSTON.eot"));
  983. pds->szURLtoEOT = CoTaskDupString (T2OLE(szBuffer)); // "res://"-type URL to EOT file
  984. if (pds->szURLtoEOT)
  985. {
  986. pds->szSymbolString = CoTaskDupString (T2OLE(_T("A<BR>BCDEFGHIJKLMNOPQRSTUVWXYZ"))); // 1 or more symbol characters
  987. if (pds->szSymbolString)
  988. return S_OK;
  989. CoTaskFreeString (pds->szURLtoEOT);
  990. }
  991. CoTaskFreeString (pds->szFontFamilyName);
  992. }
  993. return E_OUTOFMEMORY;
  994. }
  995. }
  996. HRESULT CComponent::EnumTasks (IDataObject * pdo, LPOLESTR szTaskGroup, IEnumTASK** ppEnumTASK)
  997. {
  998. HRESULT hresult = S_OK;
  999. CEnumTasks * pet = new CEnumTasks;
  1000. if (!pet)
  1001. hresult = E_OUTOFMEMORY;
  1002. else
  1003. {
  1004. pet->AddRef (); // make sure release works properly on failure
  1005. hresult = pet->Init (pdo, szTaskGroup);
  1006. if (hresult == S_OK)
  1007. hresult = pet->QueryInterface (IID_IEnumTASK, (void **)ppEnumTASK);
  1008. pet->Release ();
  1009. }
  1010. return hresult;
  1011. }
  1012. HRESULT CComponent::GetListPadInfo (LPOLESTR szGroup, MMC_LISTPAD_INFO * pListPadInfo)
  1013. {
  1014. pListPadInfo->szTitle = CoTaskDupString (L"Display Manager ListPad Title");
  1015. pListPadInfo->szButtonText = CoTaskDupString (L"Change...");
  1016. pListPadInfo->nCommandID = -1;
  1017. return S_OK;
  1018. }
  1019. HRESULT ApplyOption (int nCommandID)
  1020. {
  1021. switch (nCommandID)
  1022. {
  1023. case IDM_TILE:
  1024. case IDM_CENTER:
  1025. case IDM_STRETCH:
  1026. // write registry key:
  1027. {
  1028. HKEY hkey;
  1029. HRESULT r = RegOpenKeyEx (HKEY_CURRENT_USER,
  1030. _T("Control Panel\\Desktop"),
  1031. 0, KEY_ALL_ACCESS, &hkey);
  1032. if (r == ERROR_SUCCESS)
  1033. {
  1034. // write new value(s)
  1035. DWORD dwType = REG_SZ;
  1036. TCHAR szBuffer[2];
  1037. // first do "TileWallpaper"
  1038. if (nCommandID == IDM_TILE)
  1039. lstrcpy (szBuffer, _T("1"));
  1040. else
  1041. lstrcpy (szBuffer, _T("0"));
  1042. DWORD dwCount = sizeof(TCHAR)*(1+lstrlen (szBuffer));
  1043. r = RegSetValueEx (hkey,
  1044. (LPCTSTR)_T("TileWallpaper"),
  1045. NULL,
  1046. dwType,
  1047. (CONST BYTE *)&szBuffer,
  1048. dwCount);
  1049. // then do "WallpaperStyle"
  1050. if (nCommandID == IDM_STRETCH)
  1051. lstrcpy (szBuffer, _T("2"));
  1052. else
  1053. lstrcpy (szBuffer, _T("0"));
  1054. r = RegSetValueEx (hkey,
  1055. (LPCTSTR)_T("WallpaperStyle"),
  1056. NULL,
  1057. dwType,
  1058. (CONST BYTE *)&szBuffer,
  1059. dwCount);
  1060. // close up shop
  1061. RegCloseKey(hkey);
  1062. _ASSERT(r == ERROR_SUCCESS);
  1063. /*
  1064. [HKEY_CURRENT_USER\Control Panel\Desktop]
  1065. "CoolSwitch"="1"
  1066. "CoolSwitchRows"="3"
  1067. "CoolSwitchColumns"="7"
  1068. "CursorBlinkRate"="530"
  1069. "ScreenSaveTimeOut"="900"
  1070. "ScreenSaveActive"="0"
  1071. "ScreenSaverIsSecure"="0"
  1072. "Pattern"="(None)"
  1073. "Wallpaper"="C:\\WINNT\\dax.bmp"
  1074. "TileWallpaper"="0"
  1075. "GridGranularity"="0"
  1076. "IconSpacing"="75"
  1077. "IconTitleWrap"="1"
  1078. "IconTitleFaceName"="MS Sans Serif"
  1079. "IconTitleSize"="9"
  1080. "IconTitleStyle"="0"
  1081. "DragFullWindows"="1"
  1082. "HungAppTimeout"="5000"
  1083. "WaitToKillAppTimeout"="20000"
  1084. "AutoEndTasks"="0"
  1085. "FontSmoothing"="0"
  1086. "MenuShowDelay"="400"
  1087. "DragHeight"="2"
  1088. "DragWidth"="2"
  1089. "WheelScrollLines"="3"
  1090. "WallpaperStyle"="0"
  1091. */
  1092. }
  1093. if (r == ERROR_SUCCESS)
  1094. ::MessageBox (NULL, _T("Option set Successfully!"), _T("Display Manager"), MB_OK);
  1095. return r;
  1096. }
  1097. default:
  1098. break;
  1099. }
  1100. return S_FALSE;
  1101. }
  1102. void CComponent::TestConsoleVerb(void)
  1103. {
  1104. IConsoleVerb* pConsoleVerb = NULL;
  1105. m_pConsole->QueryConsoleVerb (&pConsoleVerb);
  1106. _ASSERT (pConsoleVerb != NULL);
  1107. if (pConsoleVerb)
  1108. {
  1109. pConsoleVerb->SetVerbState (MMC_VERB_PASTE, ENABLED, TRUE);
  1110. pConsoleVerb->Release();
  1111. }
  1112. }