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.

124 lines
3.1 KiB

  1. #include "pch.hxx"
  2. #include "globals.h"
  3. #include "resource.h"
  4. #include "util.h"
  5. #include "mimeole.h"
  6. INT_PTR CALLBACK GenericDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
  7. void ProcessTooltips(LPTOOLTIPTEXT lpttt)
  8. {
  9. if (lpttt->lpszText = MAKEINTRESOURCE(TTIdFromCmdId(lpttt->hdr.idFrom)))
  10. lpttt->hinst = g_hInst;
  11. else
  12. lpttt->hinst = NULL;
  13. }
  14. UINT TTIdFromCmdId(UINT idCmd)
  15. {
  16. if (idCmd >= IDM_FIRST && idCmd <= IDM_LAST)
  17. idCmd += TT_BASE;
  18. else
  19. idCmd = 0;
  20. return(idCmd);
  21. }
  22. void HandleMenuSelect(HWND hStatus, WPARAM wParam, LPARAM lParam)
  23. {
  24. UINT fuFlags, uItem;
  25. HMENU hmenu=GET_WM_MENUSELECT_HMENU(wParam, lParam);
  26. CHAR rgch[MAX_PATH]={0};
  27. LPSTR psz=NULL;
  28. if (!hStatus)
  29. return;
  30. uItem = (UINT)LOWORD(wParam);
  31. fuFlags = (UINT)HIWORD(wParam);
  32. if(fuFlags & MF_POPUP)
  33. {
  34. MENUITEMINFO mii = { sizeof(MENUITEMINFO), MIIM_ID, 0 };
  35. if(hmenu && IsMenu(hmenu) && GetMenuItemInfo(hmenu, uItem, TRUE, &mii))
  36. {
  37. // change the parameters to simulate a normal menu item
  38. uItem = mii.wID;
  39. fuFlags = 0;
  40. }
  41. }
  42. if(0 == (fuFlags & (MF_SYSMENU | MF_POPUP)))
  43. {
  44. if(uItem >= IDM_FIRST && uItem <= IDM_LAST)
  45. {
  46. uItem = uItem + MH_BASE;
  47. LoadString(g_hInst, (UINT)MAKEINTRESOURCE(uItem), rgch, sizeof(rgch));
  48. psz = rgch;
  49. }
  50. }
  51. SendMessage(hStatus, SB_SETTEXT, SBT_NOBORDERS|255, (LPARAM)psz);
  52. }
  53. typedef struct GPINFO_tag
  54. {
  55. char *szCaption;
  56. char *szPrompt;
  57. char *szBuffer;
  58. int nLen;
  59. } GPINFO, *PGPINFO;
  60. HRESULT GenericPrompt(HWND hwnd, char *szCaption, char *szPrompt, char *szBuffer, int nLen)
  61. {
  62. GPINFO rGInfo;
  63. rGInfo.szCaption = szCaption;
  64. rGInfo.szPrompt = szPrompt;
  65. rGInfo.szBuffer= szBuffer;
  66. rGInfo.nLen = nLen;
  67. if (DialogBoxParam(g_hInst, MAKEINTRESOURCE(iddGeneric), hwnd, GenericDlgProc, (LPARAM)&rGInfo)==IDOK)
  68. return S_OK;
  69. else
  70. return MIMEEDIT_E_USERCANCEL;
  71. }
  72. BOOL CALLBACK GenericDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
  73. {
  74. PGPINFO pGInfo;
  75. switch (msg)
  76. {
  77. case WM_COMMAND:
  78. pGInfo = (PGPINFO)GetWindowLong(hwnd, DWL_USER);
  79. switch (LOWORD(wParam))
  80. {
  81. case IDOK:
  82. GetWindowText(GetDlgItem(hwnd, idcEdit), pGInfo->szBuffer, pGInfo->nLen);
  83. // fall tro'
  84. case IDCANCEL:
  85. EndDialog(hwnd, LOWORD(wParam));
  86. return TRUE;
  87. }
  88. break;
  89. case WM_INITDIALOG:
  90. SetWindowLong(hwnd, DWL_USER, lParam);
  91. pGInfo = (PGPINFO)lParam;
  92. SetWindowText(GetDlgItem(hwnd, -1), pGInfo->szPrompt);
  93. SetWindowText(hwnd, pGInfo->szCaption);
  94. SetWindowText(GetDlgItem(hwnd, idcEdit), pGInfo->szBuffer);
  95. break;
  96. }
  97. return FALSE;
  98. }