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
4.5 KiB

  1. #ifndef __DBGCDRAW_H_INCLUDED
  2. #define __DBGCDRAW_H_INCLUDED
  3. #ifndef ARRAYSIZE
  4. #define ARRAYSIZE(x) (sizeof(x)/sizeof(x[0]))
  5. #endif
  6. #define MKFLAG(x) { (x), TEXT(#x) }
  7. struct FlagString
  8. {
  9. DWORD dwFlag;
  10. LPCTSTR pszString;
  11. };
  12. inline LPCTSTR GetString( LPTSTR szString, FlagString *pFlagStrings, size_t nSize, DWORD dwValue, bool bFlag )
  13. {
  14. TCHAR szFlag[200] = TEXT("");
  15. wsprintf( szFlag, TEXT("(0x%08X)"), dwValue );
  16. TCHAR szText[256] = TEXT("");
  17. lstrcpy( szString, TEXT("") );
  18. if (bFlag)
  19. {
  20. for (size_t i=0;i<nSize;i++)
  21. {
  22. if (dwValue & pFlagStrings[i].dwFlag)
  23. {
  24. if (lstrlen(szText))
  25. {
  26. lstrcat(szText,TEXT("|"));
  27. }
  28. lstrcat( szText, pFlagStrings[i].pszString );
  29. }
  30. }
  31. }
  32. else
  33. {
  34. for (size_t i=0;i<nSize;i++)
  35. {
  36. if (dwValue == pFlagStrings[i].dwFlag)
  37. {
  38. lstrcpy( szText, pFlagStrings[i].pszString );
  39. break;
  40. }
  41. }
  42. }
  43. lstrcpy( szString, szText );
  44. if (lstrlen(szString))
  45. {
  46. lstrcat( szString, TEXT(" ") );
  47. }
  48. lstrcat( szString, szFlag );
  49. return szString;
  50. }
  51. inline void DumpCustomDraw( LPARAM lParam, LPCTSTR pszControlType=NULL, DWORD dwDrawStage=0 )
  52. {
  53. FlagString DrawStages[] =
  54. {
  55. MKFLAG(CDDS_PREPAINT),
  56. MKFLAG(CDDS_POSTPAINT),
  57. MKFLAG(CDDS_PREERASE),
  58. MKFLAG(CDDS_POSTERASE),
  59. MKFLAG(CDDS_ITEMPREPAINT),
  60. MKFLAG(CDDS_ITEMPOSTPAINT),
  61. MKFLAG(CDDS_ITEMPREERASE),
  62. MKFLAG(CDDS_ITEMPOSTERASE)
  63. };
  64. FlagString ItemStates[] =
  65. {
  66. MKFLAG(CDIS_CHECKED),
  67. MKFLAG(CDIS_DEFAULT),
  68. MKFLAG(CDIS_DISABLED),
  69. MKFLAG(CDIS_FOCUS),
  70. MKFLAG(CDIS_GRAYED),
  71. MKFLAG(CDIS_HOT),
  72. MKFLAG(CDIS_INDETERMINATE),
  73. MKFLAG(CDIS_MARKED),
  74. MKFLAG(CDIS_SELECTED),
  75. MKFLAG(CDIS_SHOWKEYBOARDCUES)
  76. };
  77. TCHAR szClassName[MAX_PATH];
  78. if (GetClassName( reinterpret_cast<NMHDR*>(lParam)->hwndFrom, szClassName, sizeof(szClassName)/sizeof(szClassName[0]) ))
  79. {
  80. if (!pszControlType || !lstrcmp(pszControlType,szClassName))
  81. {
  82. if (!dwDrawStage || dwDrawStage == reinterpret_cast<NMCUSTOMDRAW*>(lParam)->dwDrawStage)
  83. {
  84. TCHAR szBuffer[MAX_PATH];
  85. WIA_TRACE((TEXT("Dumping Custom Draw for control: [%s]"), szClassName ));
  86. #if 0
  87. WIA_TRACE((TEXT(" hwndFrom: 0x%p"),reinterpret_cast<NMHDR*>(lParam)->hwndFrom ));
  88. WIA_TRACE((TEXT(" idFrom: %d"),reinterpret_cast<NMHDR*>(lParam)->idFrom ));
  89. WIA_TRACE((TEXT(" code: %d"),reinterpret_cast<NMHDR*>(lParam)->code ));
  90. #endif
  91. WIA_TRACE((TEXT(" dwDrawStage: %s"),GetString(szBuffer,DrawStages,ARRAYSIZE(DrawStages),reinterpret_cast<NMCUSTOMDRAW*>(lParam)->dwDrawStage,false)));
  92. WIA_TRACE((TEXT(" hdc: %p"),reinterpret_cast<NMCUSTOMDRAW*>(lParam)->hdc ));
  93. WIA_TRACE((TEXT(" rc: (%d,%d), (%d,%d)"),reinterpret_cast<NMCUSTOMDRAW*>(lParam)->rc.left, reinterpret_cast<NMCUSTOMDRAW*>(lParam)->rc.top,reinterpret_cast<NMCUSTOMDRAW*>(lParam)->rc.right,reinterpret_cast<NMCUSTOMDRAW*>(lParam)->rc.bottom ));
  94. WIA_TRACE((TEXT(" dwItemSpec: %d"),reinterpret_cast<NMCUSTOMDRAW*>(lParam)->dwItemSpec ));
  95. WIA_TRACE((TEXT(" uItemState: %s"),GetString(szBuffer,ItemStates,ARRAYSIZE(ItemStates),reinterpret_cast<NMCUSTOMDRAW*>(lParam)->uItemState,true)));
  96. WIA_TRACE((TEXT(" lItemlParam: 0x%p"),reinterpret_cast<NMCUSTOMDRAW*>(lParam)->lItemlParam ));
  97. if (!lstrcmp(TEXT("SysListView32"),szClassName))
  98. {
  99. WIA_TRACE((TEXT(" clrText: RGB(0x%02X,0x%02X,0x%02X)"),GetRValue(reinterpret_cast<NMLVCUSTOMDRAW*>(lParam)->clrText),GetGValue(reinterpret_cast<NMLVCUSTOMDRAW*>(lParam)->clrText),GetBValue(reinterpret_cast<NMLVCUSTOMDRAW*>(lParam)->clrText) ));
  100. WIA_TRACE((TEXT(" clrTextBk: RGB(0x%02X,0x%02X,0x%02X)"),GetRValue(reinterpret_cast<NMLVCUSTOMDRAW*>(lParam)->clrTextBk),GetGValue(reinterpret_cast<NMLVCUSTOMDRAW*>(lParam)->clrTextBk),GetBValue(reinterpret_cast<NMLVCUSTOMDRAW*>(lParam)->clrTextBk) ));
  101. WIA_TRACE((TEXT(" iSubItem: %d"),reinterpret_cast<NMLVCUSTOMDRAW*>(lParam)->iSubItem ));
  102. }
  103. WIA_TRACE((TEXT("")));
  104. }
  105. }
  106. }
  107. }
  108. #endif //__DBGCDRAW_H_INCLUDED