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.

674 lines
17 KiB

  1. #define WIN31
  2. #include <windows.h>
  3. #include "SDKRegEd.h"
  4. #define RONSPACE 3
  5. #define misParam ((MEASUREITEMSTRUCT FAR *)lParam)
  6. #define disParam ((DRAWITEMSTRUCT FAR *)lParam)
  7. extern char szNull[];
  8. extern char szSDKRegEd[];
  9. static char szEquals[] = " = ";
  10. static WORD wKey=0;
  11. static HANDLE hSearchString = NULL;
  12. static BOOL bDoUpdate = TRUE;
  13. static HWND hStat1, hEdit1, hEdit2;
  14. extern BOOL bChangesMade;
  15. extern HWND hWndIds;
  16. extern HANDLE hAcc;
  17. extern BOOL fOpenError;
  18. #pragma warning(4:4146) // unary minus operator applied to unsigned type, result still unsigned
  19. VOID NEAR PASCAL MySetSel(HWND hWndList, int index)
  20. {
  21. if (!bDoUpdate)
  22. return;
  23. if(index == -2)
  24. index = (int)SendMessage(hWndList, LB_GETCURSEL, 0, 0L);
  25. else
  26. SendMessage(hWndList, LB_SETCURSEL, index, 0L);
  27. SendMessage(GetParent(hWndList), WM_COMMAND, GetWindowWord(hWndList, GWW_ID),
  28. MAKELONG(hWndList, LBN_SELCHANGE));
  29. }
  30. int FAR PASCAL SDKMainWndDlg(HWND hDlg, WORD message, WORD wParam, DWORD lParam)
  31. {
  32. static int xSpace;
  33. static int nTop, nLeft, nValHgt, nPthHgt;
  34. switch(message) {
  35. case WM_COMMAND:
  36. switch(wParam) {
  37. case IDCANCEL:
  38. SendDlgItemMessage(hDlg, ID_VALUE, EM_SETMODIFY, 0, 0L);
  39. goto NewSelection;
  40. case ID_VALUE:
  41. if (HIWORD(lParam) == EN_KILLFOCUS) {
  42. hAcc = LoadAccelerators(hInstance, szSDKRegEd);
  43. goto NewSelection;
  44. } else if (HIWORD(lParam) == EN_SETFOCUS)
  45. hAcc = LoadAccelerators(hInstance, "SDKRegEdVal");
  46. break;
  47. case ID_IDLIST:
  48. if(HIWORD(lParam) == LBN_SELCHANGE) {
  49. HANDLE hTmp;
  50. HWND hWndTmp;
  51. WORD wErrMsg, wNewKey;
  52. NewSelection:
  53. wNewKey = (WORD)SendMessage(hWndIds, LB_GETCURSEL, 0, 0L);
  54. hWndTmp = GetDlgItem(hDlg, ID_VALUE);
  55. if (SendMessage(hWndTmp, EM_GETMODIFY, 0, 0L)) {
  56. SendMessage(hWndTmp, EM_SETMODIFY, 0, 0L);
  57. bDoUpdate = FALSE;
  58. wErrMsg = IDS_OUTOFMEMORY;
  59. if(hEdit1 = GetEditString(hWndTmp)) {
  60. wErrMsg = GetErrMsg((WORD)SDKSetValue(-wKey, szNull,
  61. LocalLock(hEdit1)));
  62. LocalUnlock(hEdit1);
  63. }
  64. if(wErrMsg) {
  65. MyMessageBox(hWndMain, wErrMsg, MB_OK, 0);
  66. break;
  67. }
  68. bDoUpdate = TRUE;
  69. InvalidateRect(hWndIds, NULL, TRUE);
  70. }
  71. if((wKey=wNewKey)!=(WORD)SendMessage(hWndIds, LB_GETCURSEL, 0, 0L))
  72. SendMessage(hWndIds, LB_SETCURSEL, wKey, 0L);
  73. if(!MyGetValue(wKey, &hTmp)) {
  74. SendMessage(hWndTmp, WM_SETTEXT, 0,
  75. (DWORD)((LPSTR)LocalLock(hTmp)));
  76. LocalUnlock(hTmp);
  77. LocalFree(hTmp);
  78. } else
  79. SendMessage(hWndTmp, WM_SETTEXT, 0, (DWORD)((LPSTR)szNull));
  80. hWndTmp = GetDlgItem(hDlg, ID_FULLPATH);
  81. if(hTmp=MyGetPath(wKey)) {
  82. SendMessage(hWndTmp, WM_SETTEXT, 0,
  83. (DWORD)((LPSTR)LocalLock(hTmp)));
  84. LocalUnlock(hTmp);
  85. LocalFree(hTmp);
  86. } else
  87. SendMessage(hWndTmp, WM_SETTEXT, 0, (DWORD)((LPSTR)szNull));
  88. }
  89. break;
  90. default:
  91. break;
  92. }
  93. return(FALSE);
  94. break;
  95. case WM_SIZE:
  96. {
  97. HWND hWndTmp;
  98. RECT rcList, rcWnd;
  99. int hgtWnd, hgt;
  100. hgtWnd = HIWORD(lParam) + 1;
  101. hgt = hgtWnd - nTop;
  102. SetWindowPos(hWndIds, NULL, -1, nTop, LOWORD(lParam)+2, hgt,
  103. SWP_NOZORDER);
  104. GetWindowRect(hWndIds, &rcList);
  105. ScreenToClient(hDlg, (POINT *)(&rcList) + 1);
  106. if(rcList.bottom != hgtWnd) {
  107. GetWindowRect(hDlg, &rcWnd);
  108. SetWindowPos(hDlg, NULL, 0, 0, rcWnd.right-rcWnd.left,
  109. rcWnd.bottom-rcWnd.top-hgtWnd+rcList.bottom,
  110. SWP_NOMOVE | SWP_NOZORDER);
  111. }
  112. hWndTmp = GetDlgItem(hDlg, ID_VALUE);
  113. SetWindowPos(hWndTmp, NULL, 0, 0, LOWORD(lParam)-nLeft,
  114. nValHgt, SWP_NOMOVE | SWP_NOZORDER);
  115. InvalidateRect(hWndTmp, NULL, TRUE);
  116. hWndTmp = GetDlgItem(hDlg, ID_FULLPATH);
  117. SetWindowPos(hWndTmp, NULL, 0, 0, LOWORD(lParam)-nLeft,
  118. nPthHgt, SWP_NOMOVE | SWP_NOZORDER);
  119. InvalidateRect(hWndTmp, NULL, TRUE);
  120. break;
  121. }
  122. case WM_INITDIALOG:
  123. {
  124. RECT rcTemp;
  125. WORD wErrMsg;
  126. hWndIds = GetDlgItem(hDlg, ID_IDLIST);
  127. SendMessage(hWndIds, WM_SETREDRAW, 0, 0L);
  128. if(wErrMsg=MyResetIdList(hDlg)) {
  129. MyMessageBox(hWndMain, wErrMsg, MB_OK, 0);
  130. fOpenError = TRUE;
  131. }
  132. SendMessage(hWndIds, WM_SETREDRAW, 1, 0L);
  133. InvalidateRect(hWndIds, NULL, TRUE);
  134. GetWindowRect(hWndIds, &rcTemp);
  135. ScreenToClient(hDlg, (POINT FAR *)&rcTemp);
  136. nTop = rcTemp.top;
  137. GetWindowRect(GetDlgItem(hDlg, ID_VALUE), &rcTemp);
  138. nValHgt = rcTemp.bottom - rcTemp.top;
  139. GetWindowRect(GetDlgItem(hDlg, ID_FULLPATH), &rcTemp);
  140. nPthHgt = rcTemp.bottom - rcTemp.top;
  141. ScreenToClient(hDlg, (POINT FAR *)&rcTemp);
  142. nLeft = rcTemp.left;
  143. break;
  144. }
  145. case WM_MEASUREITEM:
  146. {
  147. HDC hDC;
  148. hDC = GetDC(hWndIds);
  149. misParam->itemHeight = HIWORD(GetTextExtent(hDC, "Ag", 2));
  150. xSpace = LOWORD(GetTextExtent(hDC, " ", 1));
  151. ReleaseDC(hWndIds, hDC);
  152. break;
  153. }
  154. case WM_DRAWITEM:
  155. {
  156. HDC hDC;
  157. HANDLE hKeyName, hValue;
  158. PSTR pKeyName;
  159. WORD wSize;
  160. int theLevel;
  161. RECT rcTextExt;
  162. DWORD dwMarkers, thisMarker;
  163. DWORD dwRGBBkGnd, dwRGBText;
  164. hDC = disParam->hDC;
  165. if(!(hKeyName=GetListboxString(disParam->hwndItem, disParam->itemID)))
  166. break;
  167. pKeyName = LocalLock(hKeyName);
  168. wSize = lstrlen(pKeyName);
  169. if(!MyGetValue(disParam->itemID, &hValue)) {
  170. PSTR pValue;
  171. HANDLE hTemp;
  172. WORD wTemp;
  173. if(*(pValue = LocalLock(hValue))) {
  174. LocalUnlock(hKeyName);
  175. wTemp = wSize + sizeof(szEquals) - 1 + lstrlen(pValue);
  176. if(hTemp=LocalReAlloc(hKeyName, wTemp+1, LMEM_MOVEABLE)) {
  177. hKeyName = hTemp;
  178. pKeyName = LocalLock(hKeyName);
  179. lstrcat(pKeyName, szEquals);
  180. lstrcat(pKeyName, pValue);
  181. wSize = wTemp;
  182. } else {
  183. pKeyName = LocalLock(hKeyName);
  184. }
  185. }
  186. LocalUnlock(hValue);
  187. LocalFree(hValue);
  188. }
  189. theLevel = GetLevel(disParam->itemID);
  190. rcTextExt.left = disParam->rcItem.left + RONSPACE*theLevel*xSpace;
  191. rcTextExt.top = disParam->rcItem.top;
  192. rcTextExt.right = rcTextExt.left + LOWORD(GetTextExtent(hDC,
  193. pKeyName, wSize)) + 2*xSpace;
  194. rcTextExt.bottom = disParam->rcItem.bottom;
  195. if(disParam->itemAction & (ODA_DRAWENTIRE | ODA_SELECT)) {
  196. if(disParam->itemID>0 && (disParam->itemAction&ODA_DRAWENTIRE)) {
  197. HPEN hPen, hOldPen;
  198. int theLeft, theMiddle;
  199. if(theLevel <= 32)
  200. dwMarkers = GetTreeMarkers(disParam->itemID);
  201. else
  202. dwMarkers = 0;
  203. --theLevel;
  204. theLeft = disParam->rcItem.left + RONSPACE*theLevel*xSpace + xSpace;
  205. theMiddle = (rcTextExt.top+rcTextExt.bottom)/2;
  206. thisMarker = 1L << (LONG)theLevel;
  207. if(hPen=CreatePen(PS_SOLID, 1, GetTextColor(hDC)))
  208. hOldPen = SelectObject(hDC, hPen);
  209. MoveTo(hDC, theLeft, theMiddle);
  210. LineTo(hDC, theLeft+(RONSPACE-1)*xSpace, theMiddle);
  211. MoveTo(hDC, theLeft, rcTextExt.top);
  212. LineTo(hDC, theLeft,
  213. (dwMarkers&thisMarker) ? rcTextExt.bottom : theMiddle);
  214. goto NextLevel;
  215. for( ; theLevel>=0;
  216. --theLevel, thisMarker>>=1, theLeft-=RONSPACE*xSpace) {
  217. if(dwMarkers&thisMarker) {
  218. MoveTo(hDC, theLeft, rcTextExt.top);
  219. LineTo(hDC, theLeft, rcTextExt.bottom);
  220. }
  221. NextLevel:
  222. ;
  223. }
  224. if(hPen) {
  225. if(hOldPen)
  226. SelectObject(hDC, hOldPen);
  227. DeleteObject(hPen);
  228. }
  229. }
  230. if(disParam->itemState & ODS_SELECTED) {
  231. dwRGBBkGnd = SetBkColor(hDC, GetSysColor(COLOR_HIGHLIGHT));
  232. dwRGBText = SetTextColor(hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
  233. }
  234. ExtTextOut(hDC, rcTextExt.left+xSpace, rcTextExt.top+1,
  235. ETO_CLIPPED | ETO_OPAQUE, &rcTextExt, pKeyName, wSize, 0L);
  236. if(disParam->itemState & ODS_SELECTED) {
  237. SetBkColor(hDC, dwRGBBkGnd);
  238. SetTextColor(hDC, dwRGBText);
  239. }
  240. if(disParam->itemState & ODS_FOCUS)
  241. disParam->itemAction |= ODA_FOCUS;
  242. }
  243. if(disParam->itemAction & ODA_FOCUS)
  244. DrawFocusRect(disParam->hDC, &rcTextExt);
  245. LocalUnlock(hKeyName);
  246. LocalFree(hKeyName);
  247. break;
  248. }
  249. default:
  250. return(FALSE);
  251. }
  252. return(TRUE);
  253. }
  254. VOID NEAR _fastcall FillDlgItem(HWND hDlg, WORD wId, HANDLE hTemp)
  255. {
  256. if(hTemp) {
  257. SendDlgItemMessage(hDlg, wId, WM_SETTEXT, 0,
  258. (DWORD)((LPSTR)LocalLock(hTemp)));
  259. LocalUnlock(hTemp);
  260. LocalFree(hTemp);
  261. }
  262. }
  263. int FAR PASCAL GetKeyProc(HWND hDlg, WORD message, WORD wParam, DWORD lParam)
  264. {
  265. switch(message) {
  266. case WM_ACTIVATE:
  267. if(wParam)
  268. hWndHelp = hDlg;
  269. return(FALSE);
  270. case WM_COMMAND:
  271. switch(wParam) {
  272. case IDOK:
  273. {
  274. HWND hWndEdit2;
  275. if(!(hEdit1=GetEditString(GetDlgItem(hDlg, ID_EDIT1))))
  276. goto Error1;
  277. if((hWndEdit2=GetDlgItem(hDlg, ID_EDIT2)) &&
  278. !(hEdit2 = GetEditString(hWndEdit2)))
  279. goto Error2;
  280. }
  281. case IDCANCEL:
  282. EndDialog(hDlg, wParam);
  283. break;
  284. Error2:
  285. LocalFree(hEdit1);
  286. Error1:
  287. MyMessageBox(hDlg, IDS_OUTOFMEMORY, MB_OK, 0);
  288. break;
  289. case ID_HELP:
  290. if(GetParent(LOWORD(lParam)) != hDlg)
  291. break;
  292. case ID_HELPBUTTON:
  293. MyHelp(hDlg, HELP_CONTEXT, wHelpId);
  294. break;
  295. }
  296. break;
  297. case WM_INITDIALOG:
  298. FillDlgItem(hDlg, ID_STAT1, hStat1);
  299. FillDlgItem(hDlg, ID_EDIT1, hEdit1);
  300. FillDlgItem(hDlg, ID_EDIT2, hEdit2);
  301. return(TRUE);
  302. default:
  303. return(FALSE);
  304. }
  305. return(TRUE);
  306. }
  307. long FAR PASCAL SDKMainWnd(HWND hWnd, WORD message, WORD wParam, LONG lParam)
  308. {
  309. HCURSOR oldCursor;
  310. switch(message) {
  311. case WM_ACTIVATE:
  312. if(wParam)
  313. break;
  314. goto DoDefault;
  315. case WM_CREATE:
  316. {
  317. hWndMain = hWnd;
  318. if(!(lpMainWndDlg=MakeProcInstance(SDKMainWndDlg, hInstance)))
  319. goto Error1_1;
  320. if(!(hWndDlg=CreateDialog(hInstance, MAKEINTRESOURCE(SDKMAINWND), hWnd,
  321. lpMainWndDlg)))
  322. goto Error1_1;
  323. ShowWindow(hWndDlg, SW_SHOW);
  324. goto DoDefault;
  325. }
  326. Error1_1:
  327. /* BUG: There should be a MessageBox here
  328. */
  329. DestroyWindow(hWnd);
  330. break;
  331. /* We need to return 1 if it is OK to close, 0 otherwise
  332. */
  333. case WM_CLOSE:
  334. case WM_QUERYENDSESSION:
  335. {
  336. MySetSel(hWndIds, -2);
  337. if(bChangesMade) {
  338. int nReturn;
  339. nReturn = MyMessageBox(hWnd, IDS_SAVECHANGES, MB_YESNOCANCEL, 0);
  340. if(nReturn == IDYES) {
  341. if(!SendMessage(hWnd, WM_COMMAND, ID_SAVE, 0L))
  342. break;
  343. } else if(nReturn == IDCANCEL)
  344. break;
  345. }
  346. return(1L);
  347. }
  348. case WM_DROPFILES:
  349. goto DoMergeFile;
  350. case WM_COMMAND:
  351. oldCursor = SetCursor(LoadCursor(NULL, IDC_WAIT));
  352. switch(wParam) {
  353. case ID_MODIFY:
  354. SetFocus(GetDlgItem(hWndDlg, ID_IDLIST));
  355. break;
  356. case ID_EDITVAL:
  357. SetFocus(GetDlgItem(hWndDlg, ID_VALUE));
  358. break;
  359. case ID_SAVE:
  360. {
  361. WORD wErrMsg;
  362. MySetSel(hWndIds, -2);
  363. if(wErrMsg=MySaveChanges()) {
  364. MyMessageBox(hWnd, wErrMsg, MB_OK, 0);
  365. break;
  366. }
  367. /* Now we reset our local version of the database to make sure
  368. * we are all talking about the same thing
  369. */
  370. PostMessage(hWnd, WM_COMMAND, ID_DORESTORE, 0L);
  371. return(1L);
  372. }
  373. case ID_RESTORE:
  374. if(MyMessageBox(hWnd, IDS_SURERESTORE, MB_OKCANCEL, 0)
  375. != IDOK)
  376. break;
  377. /* Fall through */
  378. case ID_DORESTORE:
  379. {
  380. WORD wErrMsg;
  381. SendMessage(hWnd, WM_ACTIVATEAPP, 0, 0L);
  382. SendMessage(hWndIds, WM_SETREDRAW, 0, 0L);
  383. if(wErrMsg=MyResetIdList(hWndDlg)) {
  384. MyMessageBox(hWnd, wErrMsg, MB_OK, 0);
  385. PostMessage(hWnd, WM_COMMAND, ID_EXIT, 0L);
  386. fOpenError = TRUE;
  387. }
  388. SendMessage(hWndIds, WM_SETREDRAW, 1, 0L);
  389. InvalidateRect(hWndIds, NULL, TRUE);
  390. SendMessage(hWnd, WM_ACTIVATEAPP, 1, 0L);
  391. break;
  392. }
  393. case ID_MERGEFILE:
  394. DoMergeFile:
  395. MySetSel(hWndIds, -2);
  396. SendMessage(hWndIds, WM_SETREDRAW, 0, 0L);
  397. break;
  398. case ID_FINISHMERGE:
  399. SendMessage(hWndIds, WM_SETREDRAW, 1, 0L);
  400. InvalidateRect(hWndIds, NULL, TRUE);
  401. break;
  402. case ID_WRITEFILE:
  403. {
  404. WORD wErrMsg;
  405. MySetSel(hWndIds, -2);
  406. if(!LOWORD(lParam))
  407. break;
  408. if(wErrMsg=DoWriteFile(wKey, LOWORD(lParam)))
  409. MyMessageBox(hWnd, wErrMsg, MB_OK, 0);
  410. GlobalUnlock(LOWORD(lParam));
  411. GlobalFree(LOWORD(lParam));
  412. break;
  413. }
  414. case ID_ADD:
  415. {
  416. int nResult;
  417. WORD wErrMsg;
  418. MySetSel(hWndIds, -2);
  419. if(!(hStat1=MyGetPath(wKey)))
  420. goto Error6_1;
  421. hEdit1 = hEdit2 = NULL;
  422. wHelpId = IDW_ADDKEY;
  423. if((nResult=DoDialogBox(MAKEINTRESOURCE(AddKey), hWnd, GetKeyProc))
  424. < 0)
  425. goto Error6_2;
  426. else if(nResult == IDCANCEL)
  427. break;
  428. SendMessage(hWndIds, WM_SETREDRAW, 0, 0L);
  429. if (wErrMsg=GetErrMsg((WORD)SDKSetValue(-wKey, LocalLock(hEdit1),
  430. LocalLock(hEdit2))))
  431. MyMessageBox(hWnd, wErrMsg, MB_OK, 0);
  432. SendMessage(hWndIds, WM_SETREDRAW, 1, 0L);
  433. InvalidateRect(hWndIds, NULL, TRUE);
  434. LocalUnlock(hEdit2);
  435. LocalFree(hEdit2);
  436. LocalUnlock(hEdit1);
  437. LocalFree(hEdit1);
  438. break;
  439. Error6_2:
  440. LocalFree(hStat1);
  441. Error6_1:
  442. MyMessageBox(hWnd, IDS_OUTOFMEMORY, MB_OK, 0);
  443. break;
  444. }
  445. case ID_DELETE:
  446. /* Fall through */
  447. case ID_COPY:
  448. {
  449. int nNewKey, nOldKey, nResult;
  450. PSTR pEdit1, pEdit2;
  451. MySetSel(hWndIds, -2);
  452. /* Get the key name to copy to */
  453. if(!(hEdit1=MyGetPath(wKey)))
  454. goto Error5_1;
  455. hStat1 = hEdit2 = NULL;
  456. wHelpId = wParam==ID_COPY ? IDW_COPYKEY : IDW_DELETE;
  457. if((nResult=DoDialogBox(wParam==ID_COPY ? MAKEINTRESOURCE(CopyKey) :
  458. MAKEINTRESOURCE(DeleteKey), hWnd, GetKeyProc)) < 0)
  459. goto Error5_2;
  460. else if(nResult == IDCANCEL)
  461. break;
  462. /* Do the operation and clean up */
  463. pEdit1 = LocalLock(hEdit1);
  464. if((nOldKey=FindKey(pEdit1)) < 0) {
  465. MyMessageBox(hWnd, IDS_SOURCENOTEXIST, MB_OK, lstrlen(pEdit1),
  466. (LPSTR)pEdit1);
  467. goto Error5_3;
  468. }
  469. SendMessage(hWndIds, WM_SETREDRAW, 0, 0L);
  470. if(wParam == ID_COPY) {
  471. /* hEdit2 is only set in the copy dialog; not the delete
  472. */
  473. pEdit2 = LocalLock(hEdit2);
  474. if((nNewKey=DoCopyKey(nOldKey, pEdit2)) < 0)
  475. MyMessageBox(hWnd, -nNewKey, MB_OK, 0);
  476. LocalUnlock(hEdit2);
  477. LocalFree(hEdit2);
  478. } else {
  479. nNewKey = IDS_NODELROOT;
  480. if(!nOldKey || (nNewKey=MyDeleteKey(nOldKey)))
  481. MyMessageBox(hWnd, nNewKey, MB_OK, 0);
  482. if(nOldKey >= (int)SendMessage(hWndIds, LB_GETCOUNT, 0, 0L))
  483. --nOldKey;
  484. MySetSel(hWndIds, nOldKey);
  485. }
  486. SendMessage(hWndIds, WM_SETREDRAW, 1, 0L);
  487. InvalidateRect(hWndIds, NULL, TRUE);
  488. Error5_3:
  489. LocalUnlock(hEdit1);
  490. LocalFree(hEdit1);
  491. break;
  492. /* WARNING: ID_FIND also uses these error labels */
  493. Error5_2:
  494. LocalFree(hEdit1);
  495. Error5_1:
  496. MyMessageBox(hWnd, IDS_OUTOFMEMORY, MB_OK, 0);
  497. break;
  498. }
  499. case ID_FINDKEY:
  500. {
  501. int nResult;
  502. if(!(hEdit1=StringToLocalHandle(LocalLock(hSearchString),
  503. LMEM_MOVEABLE)))
  504. goto Error5_1;
  505. LocalUnlock(hSearchString);
  506. hStat1 = hEdit2 = NULL;
  507. wHelpId = IDW_FINDKEY;
  508. if((nResult=DoDialogBox(MAKEINTRESOURCE(FindKeyDlg), hWnd,
  509. GetKeyProc)) < 0)
  510. goto Error5_2;
  511. else if(nResult == IDCANCEL)
  512. break;
  513. if(hSearchString)
  514. LocalFree(hSearchString);
  515. hSearchString = hEdit1;
  516. }
  517. /* Fall through */
  518. case ID_FINDNEXT:
  519. {
  520. int index = LB_ERR;
  521. PSTR pSearchString;
  522. if(!hSearchString)
  523. goto Error2_1;
  524. pSearchString = LocalLock(hSearchString);
  525. if(*pSearchString == '\\') {
  526. if((index=FindKey(pSearchString)) == -1)
  527. goto Error2_2;
  528. } else {
  529. if((index=(int)SendMessage(hWndIds, LB_FINDSTRING, wKey,
  530. (DWORD)((LPSTR)pSearchString)))==LB_ERR)
  531. goto Error2_2;
  532. }
  533. MySetSel(hWndIds, index);
  534. Error2_2:
  535. LocalUnlock(hSearchString);
  536. Error2_1:
  537. if(index < 0)
  538. MessageBeep(0);
  539. break;
  540. }
  541. default:
  542. break;
  543. }
  544. SetCursor(oldCursor);
  545. break;
  546. default:
  547. DoDefault:
  548. return(DefWindowProc(hWnd, message, wParam, lParam));
  549. break;
  550. }
  551. return(0L);
  552. }