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.

673 lines
22 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1999 - 1999
  6. //
  7. // File: enumtask.cpp
  8. //
  9. //--------------------------------------------------------------------------
  10. #include "stdafx.h"
  11. #include "displ2.h"
  12. #include "DsplMgr2.h"
  13. extern HINSTANCE g_hinst; // in displ2.cpp
  14. #define NEW_WAY
  15. LPOLESTR CoTaskDupString (LPOLESTR szString)
  16. {
  17. #ifdef NEW_WAY
  18. OLECHAR * lpString = (OLECHAR *)CoTaskMemAlloc (sizeof(OLECHAR)*(wcslen(szString)+1));
  19. if (lpString)
  20. wcscpy (lpString, szString);
  21. return lpString;
  22. #else
  23. return(LPOLESTR)SysAllocString (szString);
  24. #endif
  25. }
  26. void CoTaskFreeString (LPOLESTR szString)
  27. {
  28. #ifdef NEW_WAY
  29. CoTaskMemFree (szString);
  30. #else
  31. SysFreeString (szString);
  32. #endif
  33. }
  34. CEnumTasks::CEnumTasks()
  35. {
  36. m_refs = 0;
  37. m_index = 0;
  38. m_type = 0; // default group/category
  39. // filenames for wallpaper mode
  40. m_bmps = NULL;
  41. }
  42. CEnumTasks::~CEnumTasks()
  43. {
  44. if (m_bmps)
  45. delete m_bmps;
  46. }
  47. HRESULT CEnumTasks::QueryInterface (REFIID riid, LPVOID FAR* ppv)
  48. {
  49. if ( (riid == IID_IUnknown) ||
  50. (riid == IID_IEnumTASK) )
  51. {
  52. *ppv = this;
  53. ((LPUNKNOWN)(*ppv))->AddRef();
  54. return NOERROR;
  55. }
  56. *ppv = NULL;
  57. return E_NOINTERFACE;
  58. }
  59. ULONG CEnumTasks::AddRef ()
  60. {
  61. return ++m_refs;
  62. }
  63. ULONG CEnumTasks::Release ()
  64. {
  65. if (--m_refs == 0)
  66. {
  67. delete this;
  68. return 0;
  69. }
  70. return m_refs;
  71. }
  72. #define NUMBER_OF_TASKS 4
  73. LPTSTR g_bitmaps[NUMBER_OF_TASKS] = { _T("/img\\ntauto.gif"),
  74. _T("/img\\mariners.gif"),
  75. _T("/img\\ntstart.gif"),
  76. _T("/img\\ntmonitor.gif")};
  77. LPTSTR g_text [NUMBER_OF_TASKS] = { _T("Set Wallpaper"),
  78. _T("Wallpaper Node"),
  79. _T("Wallpaper Options"),
  80. _T("Alert Script")};
  81. LPTSTR g_help [NUMBER_OF_TASKS] = { _T("Pick Bitmap Image for Wallpaper"),
  82. _T("Jump to Wallpaper Node"),
  83. _T("Select Stretch, Tile, or Center"),
  84. _T("Script demo")};
  85. LPTSTR g_action [NUMBER_OF_TASKS] = { _T("/wallpapr.htm"),
  86. _T("1"),
  87. _T("/default.htm#wallpaper_options"),
  88. _T("JSCRIPT:alert('my location is: ' + location);")};
  89. // _T("vbscript:MsgBox 'hi' ")};
  90. HRESULT OneOfEach(ULONG index, MMC_TASK *rgelt, ULONG *pceltFetched)
  91. { // NOTE: not bothering with error checking!!!
  92. if (index >= 20 /*NUMBER_OF_TASKS*/)
  93. {
  94. if (pceltFetched)
  95. *pceltFetched = 0;
  96. return S_FALSE; // all done
  97. }
  98. USES_CONVERSION;
  99. // setup path for reuse
  100. TCHAR szPath[MAX_PATH*2]; // that should be enough
  101. lstrcpy (szPath, _T("res://"));
  102. ::GetModuleFileName (g_hinst, szPath + lstrlen(szPath), MAX_PATH);
  103. TCHAR * szBuffer = szPath + lstrlen(szPath);
  104. MMC_TASK * task = rgelt;
  105. MMC_TASK_DISPLAY_OBJECT* pdo = &task->sDisplayObject;
  106. MMC_TASK_DISPLAY_BITMAP* pdb = &pdo->uBitmap;
  107. MMC_TASK_DISPLAY_SYMBOL* pds = &pdo->uSymbol;
  108. switch (index)
  109. {
  110. default:
  111. {
  112. TCHAR szNumber[10];
  113. if (index < 200)
  114. _itot (index, szNumber, 10);
  115. else
  116. _itot (index-200, szNumber, 10);
  117. task->szText = CoTaskDupString (T2OLE(szNumber));
  118. }
  119. task->szHelpString = CoTaskDupString (T2OLE(g_help[0]));
  120. task->eActionType = MMC_ACTION_LINK;
  121. _tcscpy (szBuffer, _T("/wallpapr.htm"));
  122. task->szActionURL = CoTaskDupString (T2OLE(szPath));
  123. lstrcpy (szPath, _T("res://"));
  124. ::GetModuleFileName (NULL, szPath + lstrlen(szPath), MAX_PATH);
  125. szBuffer = szPath + lstrlen(szPath);
  126. pdo->eDisplayType = MMC_TASK_DISPLAY_TYPE_SYMBOL;
  127. if (index < 200)
  128. {
  129. pds->szFontFamilyName = CoTaskDupString (L"Glyph 100"); // name of font family
  130. _tcscpy (szBuffer, _T("/GLYPH100.eot"));
  131. }
  132. else
  133. {
  134. pds->szFontFamilyName = CoTaskDupString (L"Glyph 110"); // name of font family
  135. _tcscpy (szBuffer, _T("/GLYPH110.eot"));
  136. }
  137. pds->szURLtoEOT = CoTaskDupString (T2OLE(szPath)); // "res://"-type URL to EOT file
  138. {
  139. OLECHAR szChar[2] = {0,0};
  140. szChar[0] = (WORD) (index%20 + 32); // cycle the same 20 symbols starting at 32
  141. pds->szSymbolString= CoTaskDupString (szChar); // 1 or more symbol characters
  142. }
  143. break;
  144. case 0:
  145. pdo->eDisplayType = MMC_TASK_DISPLAY_TYPE_VANILLA_GIF;
  146. _tcscpy (szBuffer, _T("/img\\vanilla.gif"));
  147. pdb->szMouseOffBitmap = CoTaskDupString (T2OLE(szPath));
  148. pdb->szMouseOverBitmap = NULL; // skipping mouse over bitmap
  149. task->szText = CoTaskDupString (T2OLE(g_text[index]));
  150. task->szHelpString = CoTaskDupString (T2OLE(g_help[index]));
  151. task->eActionType = MMC_ACTION_LINK;
  152. _tcscpy (szBuffer, _T("/wallpapr.htm"));
  153. task->szActionURL = CoTaskDupString (T2OLE(szPath));
  154. break;
  155. case 1:
  156. pdo->eDisplayType = MMC_TASK_DISPLAY_TYPE_CHOCOLATE_GIF;
  157. _tcscpy (szBuffer, _T("/img\\chocolate.gif"));
  158. pdb->szMouseOffBitmap = CoTaskDupString (T2OLE(szPath));
  159. pdb->szMouseOverBitmap = NULL; // skipping mouse off bitmap
  160. task->szText = CoTaskDupString (T2OLE(g_text[index]));
  161. task->szHelpString = CoTaskDupString (T2OLE(g_help[index]));
  162. task->eActionType = MMC_ACTION_ID;
  163. task->nCommandID = 1;
  164. break;
  165. case 2:
  166. pdo->eDisplayType = MMC_TASK_DISPLAY_TYPE_BITMAP;
  167. _tcscpy (szBuffer, _T("/img\\ntstart.gif"));
  168. pdb->szMouseOffBitmap = CoTaskDupString (T2OLE(szPath));
  169. _tcscpy (szBuffer, _T("/img\\dax.bmp"));
  170. pdb->szMouseOverBitmap = CoTaskDupString (T2OLE(szPath));
  171. task->szText = CoTaskDupString (T2OLE(g_text[index]));
  172. task->szHelpString = CoTaskDupString (T2OLE(g_help[index]));
  173. task->eActionType = MMC_ACTION_LINK;
  174. _tcscpy (szBuffer, _T("/default.htm#wallpaper_options"));
  175. task->szActionURL = CoTaskDupString (T2OLE(szPath));
  176. break;
  177. case 3:
  178. pdo->eDisplayType = MMC_TASK_DISPLAY_TYPE_SYMBOL;
  179. pds->szFontFamilyName = CoTaskDupString (L"Kingston"); // name of font family
  180. _tcscpy (szBuffer, _T("/KINGSTON.eot"));
  181. pds->szURLtoEOT = CoTaskDupString (T2OLE(szPath)); // "res://"-type URL to EOT file
  182. pds->szSymbolString = CoTaskDupString (T2OLE(_T("A"))); // 1 or more symbol characters
  183. task->szText = CoTaskDupString (T2OLE(g_text[index]));
  184. task->szHelpString = CoTaskDupString (T2OLE(g_help[index]));
  185. task->eActionType = MMC_ACTION_SCRIPT;
  186. task->szScript = CoTaskDupString (T2OLE(g_action[index]));
  187. break;
  188. }
  189. return S_OK;
  190. }
  191. HRESULT CEnumTasks::Next (ULONG celt, MMC_TASK *rgelt, ULONG *pceltFetched)
  192. { // will be called with celt == 1
  193. // caller alloc's array of MMC_TASKs
  194. // callee fills MMC_TASK elements (via CoTaskDupString)
  195. _ASSERT (!IsBadWritePtr (rgelt, celt*sizeof(MMC_TASK)));
  196. if (m_type == 2)
  197. return EnumBitmaps (celt, rgelt, pceltFetched);
  198. if (m_type == 3)
  199. return EnumOptions (celt, rgelt, pceltFetched);
  200. // new stuff
  201. return OneOfEach (m_index++, rgelt, pceltFetched);
  202. // new stuff
  203. if (m_index >= NUMBER_OF_TASKS)
  204. {
  205. if (pceltFetched)
  206. *pceltFetched = 0;
  207. return S_FALSE; // failure
  208. }
  209. USES_CONVERSION;
  210. // setup path for reuse
  211. TCHAR szBuffer[MAX_PATH*2]; // that should be enough
  212. lstrcpy (szBuffer, _T("res://"));
  213. ::GetModuleFileName (g_hinst, szBuffer + lstrlen(szBuffer), MAX_PATH);
  214. TCHAR * temp = szBuffer + lstrlen(szBuffer);
  215. MMC_TASK * task = rgelt;
  216. MMC_TASK_DISPLAY_OBJECT* pdo = &task->sDisplayObject;
  217. pdo->eDisplayType = MMC_TASK_DISPLAY_TYPE_BITMAP;
  218. MMC_TASK_DISPLAY_BITMAP *pdb = &pdo->uBitmap;
  219. // fill out bitmap URL
  220. lstrcpy (temp, g_bitmaps[m_index]);
  221. pdb->szMouseOffBitmap = CoTaskDupString (T2OLE(szBuffer));
  222. if (pdb->szMouseOffBitmap)
  223. {
  224. lstrcpy (temp, _T("/img\\dax.bmp"));
  225. pdb->szMouseOverBitmap = CoTaskDupString (T2OLE(szBuffer));
  226. if (pdb->szMouseOverBitmap)
  227. {
  228. // add button text
  229. task->szText = CoTaskDupString (T2OLE(g_text[m_index]));
  230. if (task->szText)
  231. {
  232. // add help string
  233. task->szHelpString = CoTaskDupString (T2OLE(g_help[m_index]));
  234. if (task->szHelpString)
  235. {
  236. // add action URL (link or script)
  237. switch (m_index)
  238. {
  239. default:
  240. case 0:
  241. task->eActionType = MMC_ACTION_LINK;
  242. break;
  243. case 1:
  244. task->eActionType = MMC_ACTION_ID;
  245. break;
  246. case 2:
  247. task->eActionType = MMC_ACTION_LINK;
  248. break;
  249. case 3:
  250. task->eActionType = MMC_ACTION_SCRIPT;
  251. break;
  252. }
  253. // the stuff below works, because of the nameless union.
  254. if (m_index == 1)
  255. {
  256. task->nCommandID = _ttol (g_action[m_index]);
  257. m_index++;
  258. // if we get here all is well
  259. if (pceltFetched)
  260. *pceltFetched = 1;
  261. return S_OK;
  262. }
  263. else
  264. {
  265. if (m_index == 0)
  266. {
  267. lstrcpy (temp, g_action[m_index]);
  268. task->szActionURL = CoTaskDupString (T2OLE(szBuffer));
  269. }
  270. else
  271. task->szActionURL = CoTaskDupString (T2OLE(g_action[m_index]));
  272. if (task->szActionURL)
  273. {
  274. m_index++;
  275. // if we get here all is well
  276. if (pceltFetched)
  277. *pceltFetched = 1;
  278. return S_OK;
  279. }
  280. }
  281. CoTaskFreeString (task->szHelpString);
  282. }
  283. CoTaskFreeString (task->szText);
  284. }
  285. CoTaskFreeString (pdb->szMouseOverBitmap);
  286. }
  287. CoTaskFreeString (pdb->szMouseOffBitmap);
  288. }
  289. // if we get here, we have some kinda failure
  290. if (pceltFetched)
  291. *pceltFetched = 0;
  292. return S_FALSE; // failure
  293. }
  294. HRESULT CEnumTasks::Skip (ULONG celt)
  295. { // won't be called
  296. m_index += celt;
  297. return S_OK;
  298. }
  299. HRESULT CEnumTasks::Reset()
  300. {
  301. m_index = 0;
  302. return S_OK;
  303. }
  304. HRESULT CEnumTasks::Clone(IEnumTASK **ppenum)
  305. { // won't be called
  306. // clone maintaining state info
  307. CEnumTasks * pet = new CEnumTasks();
  308. if (pet)
  309. {
  310. pet->m_index = m_index;
  311. return pet->QueryInterface (IID_IEnumTASK, (void **)ppenum); // can't fail
  312. }
  313. return E_OUTOFMEMORY;
  314. }
  315. HRESULT CEnumTasks::Init (IDataObject * pdo, LPOLESTR szTaskGroup)
  316. { // return ok, if we can handle data object and group
  317. if (!wcscmp (szTaskGroup, L""))
  318. m_type = 1; // default tasks
  319. else
  320. if (!wcscmp (szTaskGroup, L"wallpaper"))
  321. m_type = 2; // enum wallpaper tasks
  322. else
  323. if (!wcscmp (szTaskGroup, L"wallpaper_options"))
  324. m_type = 3; // enum option-tasks (tile/center/stretch)
  325. // else
  326. // if (!wcscmp (szTaskGroup, L"ListPad"))
  327. // m_type = 4; // default tasks
  328. return S_OK;
  329. }
  330. HRESULT CEnumTasks::EnumBitmaps (ULONG celt, MMC_TASK *rgelt, ULONG *pceltFetched)
  331. { // will be called with celt == 1
  332. // enum wallpaper tasks
  333. // may only be called when m_type == 2
  334. _ASSERT (m_type == 2);
  335. USES_CONVERSION;
  336. TCHAR temp2[MAX_PATH*2];
  337. // setup path for reuse
  338. TCHAR szBuffer[MAX_PATH*2]; // that should be enough
  339. lstrcpy (szBuffer, _T("file://"));
  340. TCHAR * path = szBuffer + lstrlen(szBuffer);
  341. ::GetWindowsDirectory (path, MAX_PATH);
  342. lstrcat (path, _T("\\"));
  343. path = szBuffer + lstrlen(szBuffer);
  344. // if we haven't already, get all .bmp files in the windows directory
  345. if (!m_bmps)
  346. GetBitmaps ();
  347. if (!m_bmps)
  348. {
  349. if (pceltFetched)
  350. *pceltFetched = 0;
  351. return S_FALSE; // failure
  352. }
  353. TCHAR * temp = m_bmps;
  354. // skip past names of stuff we've already enum'ed
  355. for (ULONG j=0; j<m_index; j++)
  356. temp += lstrlen (temp) + 1;
  357. if (*temp == 0)
  358. {
  359. // all done!
  360. if (pceltFetched)
  361. *pceltFetched = 0;
  362. return S_FALSE; // failure
  363. }
  364. MMC_TASK * task = rgelt;
  365. MMC_TASK_DISPLAY_OBJECT* pdo = &task->sDisplayObject;
  366. pdo->eDisplayType = MMC_TASK_DISPLAY_TYPE_BITMAP;
  367. MMC_TASK_DISPLAY_BITMAP *pdb = &pdo->uBitmap;
  368. // fill out bitmap URL
  369. lstrcpy (path, temp);
  370. if (!lstrcmp (temp, _T("(none)")))
  371. {
  372. // special case for none
  373. lstrcpy (temp2, _T("res://"));
  374. ::GetModuleFileName (g_hinst, temp2 + lstrlen (temp2), MAX_PATH);
  375. lstrcat (temp2, _T("/img\\none.gif"));
  376. pdb->szMouseOffBitmap = CoTaskDupString (T2OLE(temp2));
  377. }
  378. else
  379. {
  380. lstrcpy (temp2, _T("\""));
  381. lstrcat (temp2, szBuffer);
  382. lstrcat (temp2, _T("\""));
  383. pdb->szMouseOffBitmap = CoTaskDupString (T2OLE(temp2));
  384. }
  385. if (pdb->szMouseOffBitmap)
  386. {
  387. // am using same bitmap for both!!!
  388. pdb->szMouseOverBitmap = CoTaskDupString ((LPOLESTR)pdb->szMouseOffBitmap);
  389. if (pdb->szMouseOverBitmap)
  390. {
  391. // add button text
  392. task->szText = CoTaskDupString (T2OLE(temp));
  393. if (task->szText)
  394. {
  395. // add help string
  396. OLECHAR help[] = L"Add this Bitmap as Wallpaper";
  397. task->szHelpString = CoTaskDupString (help);
  398. if (task->szHelpString)
  399. {
  400. // add action URL (link or script)
  401. task->eActionType = MMC_ACTION_LINK; // always link to scriptlet
  402. TCHAR wallpaper[] = _T("#wallpaper");
  403. #ifndef TRY_THIS
  404. TCHAR action[] = _T("/button.htm#");
  405. lstrcpy (temp2, _T("res://"));
  406. ::GetModuleFileName (g_hinst, temp2 + lstrlen (temp2), MAX_PATH);
  407. lstrcat (temp2, action);
  408. #else
  409. TCHAR action[] = _T("button.htm#");
  410. lstrcpy (temp2, action);
  411. #endif
  412. TCHAR * sztemp = temp2 + lstrlen (temp2);
  413. lstrcat (temp2, temp);
  414. // replace any spaces with '*' char
  415. // script can't handle hashes with ' ' in 'em
  416. // and there can't be any filenames with '*' char,
  417. // so this works ok.
  418. TCHAR * space;
  419. while (space = _tcschr (sztemp, ' '))
  420. *space = '*';
  421. lstrcat (temp2, wallpaper);
  422. task->szActionURL = CoTaskDupString (T2OLE(temp2));
  423. if (task->szActionURL)
  424. {
  425. m_index++;
  426. // if we get here all is well
  427. if (pceltFetched)
  428. *pceltFetched = 1;
  429. return S_OK;
  430. }
  431. CoTaskFreeString (task->szHelpString);
  432. }
  433. CoTaskFreeString (task->szText);
  434. }
  435. CoTaskFreeString (pdb->szMouseOverBitmap);
  436. }
  437. CoTaskFreeString (pdb->szMouseOffBitmap);
  438. }
  439. // if we get here, we failed above
  440. if (pceltFetched)
  441. *pceltFetched = 0;
  442. return S_FALSE; // failure
  443. }
  444. void CEnumTasks::GetBitmaps (void)
  445. {
  446. if (m_bmps)
  447. return; // knuckle-head
  448. TCHAR path[MAX_PATH];
  449. GetWindowsDirectory (path, MAX_PATH);
  450. lstrcat (path, _T("\\*.bmp"));
  451. // count up *.bmp files in windows directory (also add an entry for "(none)" )
  452. int numBMPs = 0;
  453. int length = 0; // get total length of all filenames
  454. WIN32_FIND_DATA fd;
  455. ZeroMemory(&fd, sizeof(fd));
  456. HANDLE hFind = FindFirstFile (path, &fd);
  457. if (hFind != INVALID_HANDLE_VALUE)
  458. {
  459. do
  460. {
  461. if ((fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ||
  462. (fd.dwFileAttributes & FILE_ATTRIBUTE_SYSTEM) ||
  463. (fd.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) )
  464. continue; // files only
  465. numBMPs++;
  466. length += lstrlen (fd.cFileName) + 1;
  467. } while (FindNextFile (hFind, &fd) == TRUE);
  468. FindClose(hFind);
  469. }
  470. numBMPs++; // one for "(none)"
  471. length += lstrlen (_T("(none)")) + 1;
  472. length++; // add trailing double NULL
  473. // alloc space to hold filenames (plus extra NULL entry)
  474. m_bmps = new TCHAR[length];
  475. if (!m_bmps)
  476. return; // fail, but no return mechanism
  477. // add none first
  478. TCHAR * temp = m_bmps;
  479. lstrcpy (temp, _T("(none)"));
  480. temp += lstrlen (temp) + 1;
  481. // add all bmp files
  482. ZeroMemory(&fd, sizeof(fd));
  483. hFind = FindFirstFile (path, &fd);
  484. if (hFind != INVALID_HANDLE_VALUE)
  485. {
  486. do
  487. {
  488. if ((fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ||
  489. (fd.dwFileAttributes & FILE_ATTRIBUTE_SYSTEM) ||
  490. (fd.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) )
  491. continue; // files only
  492. lstrcpy (temp, fd.cFileName);
  493. temp += lstrlen (temp) + 1;
  494. } while (FindNextFile (hFind, &fd) == TRUE);
  495. FindClose(hFind);
  496. }
  497. *temp = 0; // double null terminator
  498. }
  499. #define NUMBER_OF_O_TASKS 3
  500. LPTSTR g_o_bitmaps[NUMBER_OF_O_TASKS] = {_T("/img\\ntauto.gif"),
  501. _T("/img\\mariners.gif"),
  502. _T("/img\\ntstart.gif")};
  503. LPTSTR g_o_text [NUMBER_OF_O_TASKS] = {_T("Center"),
  504. _T("Tile"),
  505. _T("Stretch")};
  506. LPTSTR g_o_help [NUMBER_OF_O_TASKS] = {_T("Center Wallpaper"),
  507. _T("Tile Wallpaper"),
  508. _T("Stretch Wallpaper")};
  509. LPTSTR g_o_action [NUMBER_OF_O_TASKS] = {_T("2"), // command ids
  510. _T("3"),
  511. _T("4")};
  512. HRESULT CEnumTasks::EnumOptions (ULONG celt, MMC_TASK *rgelt, ULONG *pceltFetched)
  513. { // will be called with celt == 1
  514. // enum option tasks
  515. // may only be called when m_type == 3
  516. _ASSERT (m_type == 3);
  517. _ASSERT (celt == 1);
  518. if (m_index >= NUMBER_OF_O_TASKS)
  519. {
  520. if (pceltFetched)
  521. *pceltFetched = 0;
  522. return S_FALSE; // failure
  523. }
  524. USES_CONVERSION;
  525. // setup path for reuse
  526. TCHAR szBuffer[MAX_PATH*2]; // that should be enough
  527. _tcscpy (szBuffer, _T("res://"));
  528. ::GetModuleFileName (g_hinst, szBuffer + _tcslen(szBuffer), MAX_PATH);
  529. TCHAR * path = szBuffer + _tcslen(szBuffer);
  530. MMC_TASK * task = rgelt;
  531. MMC_TASK_DISPLAY_OBJECT* pdo = &task->sDisplayObject;
  532. #ifdef BITMAP_CASE
  533. pdo->eDisplayType = MMC_TASK_DISPLAY_TYPE_BITMAP;
  534. MMC_TASK_DISPLAY_BITMAP *pdb = &pdo->uBitmap;
  535. // fill out bitmap URL
  536. lstrcpy (path, g_o_bitmaps[m_index]);
  537. pdb->szMouseOffBitmap = CoTaskDupString (T2OLE(szBuffer));
  538. if (pdb->szMouseOffBitmap)
  539. {
  540. // am using same bitmap for both!!!
  541. pdb->szMouseOverBitmap = CoTaskDupString (T2OLE(szBuffer));
  542. if (pdb->szMouseOverBitmap)
  543. {
  544. #else
  545. // symbol case
  546. pdo->eDisplayType = MMC_TASK_DISPLAY_TYPE_SYMBOL;
  547. MMC_TASK_DISPLAY_SYMBOL *pds = &pdo->uSymbol;
  548. // fill out symbol stuff
  549. pds->szFontFamilyName = CoTaskDupString (L"Kingston"); // name of font family
  550. if (pds->szFontFamilyName)
  551. {
  552. _tcscpy (path, _T("/KINGSTON.eot"));
  553. pds->szURLtoEOT = CoTaskDupString (T2OLE(szBuffer)); // "res://"-type URL to EOT file
  554. if (pds->szURLtoEOT)
  555. {
  556. TCHAR szSymbols[2];
  557. szSymbols[0] = (TCHAR)(m_index + 'A');
  558. szSymbols[1] = 0;
  559. pds->szSymbolString = CoTaskDupString (T2OLE(szSymbols)); // 1 or more symbol characters
  560. if (pds->szSymbolString)
  561. {
  562. #endif
  563. // add button text
  564. task->szText = CoTaskDupString (T2OLE(g_o_text[m_index]));
  565. if (task->szText)
  566. {
  567. // add help string
  568. task->szHelpString = CoTaskDupString (T2OLE(g_o_help[m_index]));
  569. if (task->szHelpString)
  570. {
  571. // add action
  572. task->eActionType = MMC_ACTION_ID;
  573. task->nCommandID = _ttol(g_o_action[m_index]);
  574. m_index++;
  575. return S_OK; // all is well
  576. }
  577. CoTaskFreeString (task->szText);
  578. }
  579. #ifdef BITMAP_CASE
  580. CoTaskFreeString (pdb->szMouseOverBitmap);
  581. }
  582. CoTaskFreeString (pdb->szMouseOffBitmap);
  583. #else
  584. CoTaskFreeString (pds->szSymbolString);
  585. }
  586. CoTaskFreeString (pds->szURLtoEOT);
  587. }
  588. CoTaskFreeString (pds->szFontFamilyName);
  589. #endif
  590. }
  591. // we get here on failure
  592. if (pceltFetched)
  593. *pceltFetched = 0;
  594. return S_FALSE; // failure
  595. }