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.

112 lines
3.3 KiB

  1. /*---------------------------------------------------------------------------
  2. Dlgs.c : Common functions for Common Dialog Library
  3. Copyright (c) Microsoft Corporation, 1990-
  4. ---------------------------------------------------------------------------*/
  5. #include "windows.h"
  6. #include "commdlg.h"
  7. char szCommdlgHelp[] = HELPMSGSTRING;
  8. UINT msgHELP;
  9. WORD wWinVer = 0x030A;
  10. HANDLE hinsCur;
  11. DWORD dwExtError;
  12. /*---------------------------------------------------------------------------
  13. LibMain
  14. Purpose: To initialize any instance specific data needed by functions
  15. in this DLL
  16. Returns: TRUE if A-OK, FALSE if not
  17. ---------------------------------------------------------------------------*/
  18. int FAR PASCAL
  19. LibMain(HANDLE hModule, WORD wDataSeg, WORD cbHeapSize, LPSTR lpstrCmdLine)
  20. {
  21. hinsCur = (HANDLE) hModule;
  22. wDataSeg = wDataSeg;
  23. cbHeapSize = cbHeapSize;
  24. lpstrCmdLine = lpstrCmdLine;
  25. /* msgHELP is sent whenever a help button is pressed in one of the */
  26. /* common dialogs (provided an owner was declared and the call to */
  27. /* RegisterWindowMessage doesn't fail. 27 Feb 1991 clarkc */
  28. msgHELP = RegisterWindowMessage(szCommdlgHelp);
  29. return(TRUE);
  30. }
  31. /*---------------------------------------------------------------------------
  32. WEP
  33. Purpose: To perform cleanup tasks when DLL is unloaded
  34. Returns: TRUE if OK, FALSE if not
  35. ---------------------------------------------------------------------------*/
  36. int FAR PASCAL
  37. WEP(int fSystemExit)
  38. {
  39. fSystemExit = fSystemExit;
  40. return(TRUE);
  41. }
  42. /*---------------------------------------------------------------------------
  43. CommDlgExtendedError
  44. Purpose: Provide additional information about dialog failure
  45. Assumes: Should be called immediately after failure
  46. Returns: Error code in low word, error specific info in hi word
  47. ---------------------------------------------------------------------------*/
  48. DWORD FAR PASCAL WowCommDlgExtendedError(void);
  49. DWORD FAR PASCAL CommDlgExtendedError()
  50. {
  51. //
  52. // HACKHACK - John Vert (jvert) 8-Jan-1993
  53. // If the high bit of dwExtError is set, then the last
  54. // common dialog call was thunked through to the 32-bit.
  55. // So we need to call the WOW thunk to get the real error.
  56. // This will go away when all the common dialogs are thunked.
  57. //
  58. if (dwExtError & 0x80000000) {
  59. return(WowCommDlgExtendedError());
  60. } else {
  61. return(dwExtError);
  62. }
  63. }
  64. VOID _loadds FAR PASCAL SetWowCommDlg()
  65. {
  66. dwExtError = 0x80000000;
  67. }
  68. /*---------------------------------------------------------------------------
  69. MySetObjectOwner
  70. Purpose: Call SetObjectOwner in GDI, eliminating "<Object> not released"
  71. error messages when an app terminates.
  72. Returns: Yep
  73. ---------------------------------------------------------------------------*/
  74. void FAR PASCAL MySetObjectOwner(HANDLE hObject)
  75. {
  76. extern char szGDI[];
  77. VOID (FAR PASCAL *lpSetObjOwner)(HANDLE, HANDLE);
  78. HMODULE hMod;
  79. if (wWinVer >= 0x030A)
  80. {
  81. if ((hMod = GetModuleHandle(szGDI)) != NULL) {
  82. lpSetObjOwner = (VOID (FAR PASCAL *)(HANDLE, HANDLE))GetProcAddress(hMod, MAKEINTRESOURCE(461));
  83. if (lpSetObjOwner) {
  84. (lpSetObjOwner)(hObject, hinsCur);
  85. }
  86. }
  87. }
  88. return;
  89. }