optionsInfo.cpp 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. #include "main.h"
  2. #include "./options.h"
  3. #include "./resource.h"
  4. #include "./obj_ombrowser.h"
  5. #include "./ifc_omconfig.h"
  6. #include "./ifc_ombrowserclass.h"
  7. #include "./ieversion.h"
  8. #include <windows.h>
  9. #include <shlwapi.h>
  10. #include <strsafe.h>
  11. static INT_PTR CALLBACK OptionsInfo_DialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  12. HWND CALLBACK OptionsInfo_CreatePage(HWND hParent, UINT style)
  13. {
  14. return Plugin_CreateDialogParam(MAKEINTRESOURCE(IDD_OPTIONS_INFO), hParent, OptionsInfo_DialogProc, 0L);
  15. }
  16. static void OptionsInfo_SetClassName(HWND hwnd, obj_ombrowser *browserManager)
  17. {
  18. HWND hControl = GetDlgItem(hwnd, IDC_CLASS);
  19. if (NULL == hControl) return;
  20. WCHAR szBuffer[512] = {0};
  21. BOOL valueInvalid = TRUE;
  22. ifc_ombrowserclass *browserClass;
  23. if (NULL != browserManager && SUCCEEDED(browserManager->GetClass(&browserClass)))
  24. {
  25. if (SUCCEEDED(browserClass->GetName(szBuffer, ARRAYSIZE(szBuffer))))
  26. valueInvalid = FALSE;
  27. browserClass->Release();
  28. }
  29. if (FALSE != valueInvalid)
  30. Plugin_LoadString(IDS_UNKNOWN, szBuffer, ARRAYSIZE(szBuffer));
  31. SetWindowText(hControl, szBuffer);
  32. }
  33. static void OptionsInfo_SetConfigPath(HWND hwnd, obj_ombrowser *browserManager)
  34. {
  35. HWND hControl = GetDlgItem(hwnd, IDC_CONFIGPATH);
  36. if (NULL == hControl) return;
  37. WCHAR szBuffer[512] = {0};
  38. BOOL valueInvalid = TRUE;
  39. ifc_omconfig *browserConfig;
  40. if (NULL != browserManager && SUCCEEDED(browserManager->GetConfig(NULL, (void**)&browserConfig)))
  41. {
  42. if (SUCCEEDED(browserConfig->GetPath(szBuffer, ARRAYSIZE(szBuffer))))
  43. valueInvalid = FALSE;
  44. browserConfig->Release();
  45. }
  46. if (FALSE != valueInvalid)
  47. Plugin_LoadString(IDS_UNKNOWN, szBuffer, ARRAYSIZE(szBuffer));
  48. SetWindowText(hControl, szBuffer);
  49. }
  50. static void OptionsInfo_SetIEVersion(HWND hwnd)
  51. {
  52. HWND hControl = GetDlgItem(hwnd, IDC_MSIEVERSION);
  53. if (NULL == hControl) return;
  54. WCHAR szBuffer[128] = {0};
  55. if (FAILED(MSIE_GetVersionString(szBuffer, ARRAYSIZE(szBuffer))))
  56. Plugin_LoadString(IDS_UNKNOWN, szBuffer, ARRAYSIZE(szBuffer));
  57. SetWindowText(hControl, szBuffer);
  58. }
  59. static void OptionsInfo_SetVersion(HWND hwnd, obj_ombrowser *browserManager)
  60. {
  61. HWND hControl = GetDlgItem(hwnd, IDC_VERSION);
  62. if (NULL == hControl) return;
  63. WCHAR szBuffer[32] = {0};
  64. INT major, minor;
  65. if (NULL == browserManager ||
  66. FAILED(browserManager->GetVersion(&major, &minor)) ||
  67. FAILED(StringCchPrintf(szBuffer, ARRAYSIZE(szBuffer), L"%d.%d", major, minor)))
  68. {
  69. Plugin_LoadString(IDS_UNKNOWN, szBuffer, ARRAYSIZE(szBuffer));
  70. }
  71. SetWindowText(hControl, szBuffer);
  72. }
  73. static void OptionsInfo_SetClientId(HWND hwnd, obj_ombrowser *browserManager)
  74. {
  75. HWND hControl = GetDlgItem(hwnd, IDC_CLIENTID);
  76. if (NULL == hControl) return;
  77. WCHAR szBuffer[256] = {0};
  78. if (NULL == browserManager || FAILED(browserManager->GetClientId(szBuffer, ARRAYSIZE(szBuffer))))
  79. Plugin_LoadString(IDS_UNKNOWN, szBuffer, ARRAYSIZE(szBuffer));
  80. SetWindowText(hControl, szBuffer);
  81. }
  82. static void OptionsInfo_SetSessionId(HWND hwnd, obj_ombrowser *browserManager)
  83. {
  84. HWND hControl = GetDlgItem(hwnd, IDC_SESSIONID);
  85. if (NULL == hControl) return;
  86. WCHAR szBuffer[256] = {0};
  87. if (NULL == browserManager || FAILED(browserManager->GetSessionId(szBuffer, ARRAYSIZE(szBuffer))))
  88. Plugin_LoadString(IDS_UNKNOWN, szBuffer, ARRAYSIZE(szBuffer));
  89. SetWindowText(hControl, szBuffer);
  90. }
  91. static void OptionsInfo_SetTitleFont(HWND hwnd)
  92. {
  93. HWND hControl = GetDlgItem(hwnd, IDC_TITLE);
  94. if (NULL == hControl) return;
  95. LOGFONT lfTitle;
  96. HFONT hFont = (HFONT)SendMessage(hwnd, WM_GETFONT, 0, 0L);
  97. INT fontHeight;
  98. fontHeight = (NULL != hFont && 0 != GetObject(hFont, sizeof(lfTitle), &lfTitle)) ? lfTitle.lfHeight : -11;
  99. fontHeight += (fontHeight > 0) ? 2 : -2;
  100. ZeroMemory(&lfTitle, sizeof(lfTitle));
  101. lfTitle.lfHeight = fontHeight;
  102. lfTitle.lfWeight = FW_NORMAL;
  103. lfTitle.lfItalic = FALSE;
  104. lfTitle.lfUnderline = FALSE;
  105. lfTitle.lfStrikeOut = FALSE;
  106. lfTitle.lfCharSet = DEFAULT_CHARSET;
  107. lfTitle.lfOutPrecision = OUT_DEFAULT_PRECIS;
  108. lfTitle.lfClipPrecision = CLIP_DEFAULT_PRECIS;
  109. lfTitle.lfQuality = CLEARTYPE_QUALITY;
  110. lfTitle.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
  111. StringCchCopy(lfTitle.lfFaceName, ARRAYSIZE(lfTitle.lfFaceName), L"Arial");
  112. HFONT titleFont = CreateFontIndirect(&lfTitle);
  113. if (NULL == titleFont) return;
  114. SendMessage(hControl, WM_SETFONT, (WPARAM)titleFont, 0);
  115. }
  116. static INT_PTR OptionsInfo_OnInitDialog(HWND hwnd, HWND hFocus, LPARAM param)
  117. {
  118. WCHAR szBuffer[512] = {0};
  119. Plugin_LoadString(IDS_OPTIONS_INFO, szBuffer, ARRAYSIZE(szBuffer));
  120. SetWindowText(hwnd, szBuffer);
  121. HWND hParent = GetParent(hwnd);
  122. obj_ombrowser *browserManager;
  123. if (FALSE == SendMessage(hParent, BOM_GETBROWSER, 0, (LPARAM)&browserManager))
  124. browserManager = NULL;
  125. OptionsInfo_SetVersion(hwnd, browserManager);
  126. OptionsInfo_SetClassName(hwnd, browserManager);
  127. OptionsInfo_SetClientId(hwnd, browserManager);
  128. OptionsInfo_SetSessionId(hwnd, browserManager);
  129. OptionsInfo_SetConfigPath(hwnd, browserManager);
  130. OptionsInfo_SetIEVersion(hwnd);
  131. if (NULL != browserManager)
  132. browserManager->Release();
  133. OptionsInfo_SetTitleFont(hwnd);
  134. return 0;
  135. }
  136. static void OptionsInfo_OnDestroy(HWND hwnd)
  137. {
  138. }
  139. static INT_PTR OptionsInfo_OnColorStatic(HWND hwnd, HDC hdc, HWND hControl)
  140. {
  141. UINT controlId = (UINT)GetWindowLongPtr(hControl, GWLP_ID);
  142. if (((UINT)-1) == controlId)
  143. SetTextColor(hdc, GetSysColor(COLOR_HOTLIGHT));
  144. return 0;
  145. }
  146. static INT_PTR CALLBACK OptionsInfo_DialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
  147. {
  148. switch(uMsg)
  149. {
  150. case WM_INITDIALOG: return OptionsInfo_OnInitDialog(hwnd, (HWND)wParam, lParam);
  151. case WM_DESTROY: OptionsInfo_OnDestroy(hwnd); return 0;
  152. case WM_CTLCOLORSTATIC: return OptionsInfo_OnColorStatic(hwnd, (HDC)wParam, (HWND)lParam);
  153. }
  154. return 0;
  155. }