setupDetails.cpp 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #include "./common.h"
  2. #include "./setupDetails.h"
  3. #include "./setupServicePanel.h"
  4. EXTERN_C ATOM DETAILS_PROP = 0;
  5. HMODULE hEditModule = NULL;
  6. BOOL SetupDetails_Initialize()
  7. {
  8. if (0 == DETAILS_PROP)
  9. {
  10. DETAILS_PROP = GlobalAddAtom(L"omSetupDetailsProp");
  11. if (0 == DETAILS_PROP) return FALSE;
  12. }
  13. if (NULL == (hEditModule = LoadLibrary(L"riched20.dll")))
  14. return FALSE;
  15. return TRUE;
  16. }
  17. void SetupDetails_Uninitialize()
  18. {
  19. if (NULL != hEditModule)
  20. {
  21. FreeLibrary(hEditModule);
  22. hEditModule = NULL;
  23. }
  24. if (0 != DETAILS_PROP)
  25. {
  26. GlobalDeleteAtom(DETAILS_PROP);
  27. DETAILS_PROP = 0;
  28. }
  29. }
  30. void SetupDetails_SetDescription(HWND hEdit, LPCWSTR pszText)
  31. {
  32. SetWindowText(hEdit, pszText);
  33. DWORD originalStyle = GetWindowStyle(hEdit);
  34. DWORD windowStyle = originalStyle & ~WS_VSCROLL;
  35. INT lineCount = (INT)SendMessage(hEdit, EM_GETLINECOUNT, 0, 0L);
  36. if (lineCount > 0)
  37. {
  38. INT charIndex = (INT)SendMessage(hEdit, EM_LINEINDEX, (WPARAM)(lineCount - 1), 0L);
  39. if (-1 != charIndex)
  40. {
  41. LRESULT result = SendMessage(hEdit, EM_POSFROMCHAR, charIndex, 0L);
  42. POINTS pts = MAKEPOINTS(result);
  43. RECT clientRect;
  44. if (GetClientRect(hEdit, &clientRect) && pts.y > (clientRect.bottom - 14))
  45. {
  46. windowStyle |= WS_VSCROLL;
  47. }
  48. }
  49. }
  50. if (windowStyle != originalStyle)
  51. {
  52. SetWindowLongPtr(hEdit, GWL_STYLE, windowStyle);
  53. SetWindowPos(hEdit, NULL, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOSIZE | SWP_NOMOVE | SWP_FRAMECHANGED);
  54. }
  55. ShowWindow(hEdit, SW_HIDE);
  56. if (0 != ShowWindow(hEdit, (L'\0' != *pszText) ? SW_SHOWNA : SW_HIDE))
  57. InvalidateRect(hEdit, NULL, TRUE);
  58. }
  59. HWND SetupDetails_CreateServiceView(HWND hParent, LPCWSTR pszName, ifc_omservice *service)
  60. {
  61. return ServicePanel::CreateInstance(hParent, pszName, service, NULL);
  62. }
  63. BOOL SetupDetails_GetUniqueName(HWND hwnd, LPWSTR pszBuffer, UINT cchBufferMax)
  64. {
  65. return (BOOL)SendMessage(hwnd, NSDM_GETUNIQUENAME, (WPARAM)cchBufferMax, (LPARAM)pszBuffer);
  66. }