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.

120 lines
3.1 KiB

  1. //+----------------------------------------------------------------------------
  2. //
  3. // File: modlessdlg.cpp
  4. //
  5. // Module: CMDIAL32.DLL and CMMON32.EXE
  6. //
  7. // Synopsis: Implementation of the class CModelessDlg
  8. //
  9. // Copyright (c) 1998-2000 Microsoft Corporation
  10. //
  11. // Author: nickball Created 03/22/00
  12. //
  13. //+----------------------------------------------------------------------------
  14. #include "CmDebug.h"
  15. #include "modelessdlg.h"
  16. //
  17. // Flash info.
  18. //
  19. typedef struct {
  20. UINT cbSize;
  21. HWND hwnd;
  22. DWORD dwFlags;
  23. UINT uCount;
  24. DWORD dwTimeout;
  25. } FLASHWINFO, *PFLASHWINFO;
  26. #define FLASHW_STOP 0
  27. #define FLASHW_CAPTION 0x00000001
  28. #define FLASHW_TRAY 0x00000002
  29. #define FLASHW_ALL (FLASHW_CAPTION | FLASHW_TRAY)
  30. #define FLASHW_TIMER 0x00000004
  31. #define FLASHW_TIMERNOFG 0x0000000C
  32. //+----------------------------------------------------------------------------
  33. //
  34. // Function: CModelessDlg::Flash
  35. //
  36. // Synopsis: Helper method to flash the modeless dialog. Currently
  37. // hardwired to flash taskbar until window is in foreground.
  38. //
  39. // Arguments: None
  40. //
  41. // Returns: Nothing
  42. //
  43. // History: nickball Created 03/22/00
  44. //
  45. //+----------------------------------------------------------------------------
  46. void CModelessDlg::Flash()
  47. {
  48. //
  49. // Do the flash window thing, because SetForeGround window has
  50. // been emasculated. We want the user to know something is up.
  51. //
  52. if (OS_NT5 || OS_W98) // no support on NT4 and 95
  53. {
  54. HINSTANCE hInst = LoadLibrary(TEXT("USER32"));
  55. if (hInst)
  56. {
  57. typedef BOOL (WINAPI* FlashWindowExFUNC) (PFLASHWINFO pfwi);
  58. FlashWindowExFUNC pfnFlashWindowEx =
  59. (FlashWindowExFUNC) GetProcAddress(hInst, "FlashWindowEx");
  60. MYDBGASSERT(pfnFlashWindowEx);
  61. if (pfnFlashWindowEx)
  62. {
  63. FLASHWINFO fi;
  64. fi.cbSize = sizeof(fi);
  65. fi.hwnd = m_hWnd;
  66. fi.dwFlags = FLASHW_TRAY | FLASHW_TIMERNOFG;
  67. fi.uCount = -1;
  68. fi.dwTimeout = 0;
  69. pfnFlashWindowEx(&fi);
  70. }
  71. FreeLibrary(hInst);
  72. }
  73. }
  74. }
  75. //+----------------------------------------------------------------------------
  76. //
  77. // Function: CModelessDlg::Create
  78. //
  79. // Synopsis: Same as CreateDialog
  80. //
  81. // Arguments: HINSTANCE hInstance - Same as CreateDialog
  82. // LPCTSTR lpTemplateName -
  83. // HWND hWndParent -
  84. //
  85. // Returns: HWND - Same as CreateDialog
  86. //
  87. // History: Created Header 2/17/98
  88. //
  89. //+----------------------------------------------------------------------------
  90. HWND CModelessDlg::Create(HINSTANCE hInstance,
  91. LPCTSTR lpTemplateName,
  92. HWND hWndParent)
  93. {
  94. m_hWnd = ::CreateDialogParamU(hInstance, lpTemplateName, hWndParent,
  95. (DLGPROC)ModalDialogProc, (LPARAM)this);
  96. #ifdef DEBUG
  97. if (!m_hWnd)
  98. {
  99. CMTRACE1(TEXT("CreateDialogParam failed. LastError %d"), GetLastError());
  100. }
  101. #endif
  102. MYDBGASSERT(m_hWnd);
  103. return m_hWnd;
  104. }