about.c 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. /*
  2. * WineCfg about panel
  3. *
  4. * Copyright 2002 Jaco Greeff
  5. * Copyright 2003 Dimitrie O. Paun
  6. * Copyright 2003 Mike Hearn
  7. * Copyright 2010 Joel Holdsworth
  8. *
  9. * This library is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation; either
  12. * version 2.1 of the License, or (at your option) any later version.
  13. *
  14. * This library is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with this library; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  22. *
  23. */
  24. #define COBJMACROS
  25. #include <windows.h>
  26. #include <commctrl.h>
  27. #include <shellapi.h>
  28. #include "resource.h"
  29. #include "winecfg.h"
  30. static HICON logo = NULL;
  31. static HFONT titleFont = NULL;
  32. INT_PTR CALLBACK
  33. AboutDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
  34. {
  35. const char * (CDECL *wine_get_version)(void);
  36. HWND hWnd;
  37. HDC hDC;
  38. RECT rcClient, rcRect;
  39. WCHAR *owner, *org;
  40. switch (uMsg)
  41. {
  42. case WM_NOTIFY:
  43. switch(((LPNMHDR)lParam)->code)
  44. {
  45. case PSN_APPLY:
  46. /*save registration info to registry */
  47. owner = get_text(hDlg, IDC_ABT_OWNER);
  48. org = get_text(hDlg, IDC_ABT_ORG);
  49. set_reg_key(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows\\CurrentVersion",
  50. L"RegisteredOwner", owner ? owner : L"");
  51. set_reg_key(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows\\CurrentVersion",
  52. L"RegisteredOrganization", org ? org : L"");
  53. set_reg_key(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows NT\\CurrentVersion",
  54. L"RegisteredOwner", owner ? owner : L"");
  55. set_reg_key(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows NT\\CurrentVersion",
  56. L"RegisteredOrganization", org ? org : L"");
  57. apply();
  58. HeapFree(GetProcessHeap(), 0, owner);
  59. HeapFree(GetProcessHeap(), 0, org);
  60. break;
  61. case NM_CLICK:
  62. case NM_RETURN:
  63. if(wParam == IDC_ABT_WEB_LINK)
  64. ShellExecuteW(NULL, L"open", ((NMLINK *)lParam)->item.szUrl, NULL, NULL, SW_SHOW);
  65. break;
  66. }
  67. break;
  68. case WM_INITDIALOG:
  69. hDC = GetDC(hDlg);
  70. /* read owner and organization info from registry, load it into text box */
  71. owner = get_reg_key(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows NT\\CurrentVersion",
  72. L"RegisteredOwner", L"");
  73. org = get_reg_key(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows NT\\CurrentVersion",
  74. L"RegisteredOrganization", L"");
  75. SetDlgItemTextW(hDlg, IDC_ABT_OWNER, owner);
  76. SetDlgItemTextW(hDlg, IDC_ABT_ORG, org);
  77. SendMessageW(GetParent(hDlg), PSM_UNCHANGED, 0, 0);
  78. HeapFree(GetProcessHeap(), 0, owner);
  79. HeapFree(GetProcessHeap(), 0, org);
  80. /* prepare the panel */
  81. hWnd = GetDlgItem(hDlg, IDC_ABT_PANEL);
  82. if(hWnd)
  83. {
  84. GetClientRect(hDlg, &rcClient);
  85. GetClientRect(hWnd, &rcRect);
  86. MoveWindow(hWnd, 0, 0, rcClient.right, rcRect.bottom, FALSE);
  87. logo = LoadImageW((HINSTANCE)GetWindowLongPtrW(hDlg, GWLP_HINSTANCE),
  88. MAKEINTRESOURCEW(IDI_LOGO), IMAGE_ICON, 0, 0, LR_SHARED);
  89. }
  90. /* prepare the title text */
  91. titleFont = CreateFontW( -MulDiv(24, GetDeviceCaps(hDC, LOGPIXELSY), 72),
  92. 0, 0, 0, 0, FALSE, 0, 0, 0, 0, 0, 0, 0, L"Tahoma" );
  93. SendDlgItemMessageW(hDlg, IDC_ABT_TITLE_TEXT, WM_SETFONT, (WPARAM)titleFont, TRUE);
  94. wine_get_version = (void *)GetProcAddress( GetModuleHandleW(L"ntdll.dll"), "wine_get_version" );
  95. if (wine_get_version) SetDlgItemTextA(hDlg, IDC_ABT_PANEL_TEXT, wine_get_version());
  96. ReleaseDC(hDlg, hDC);
  97. break;
  98. case WM_DESTROY:
  99. if(logo)
  100. {
  101. DestroyIcon(logo);
  102. logo = NULL;
  103. }
  104. if(titleFont)
  105. {
  106. DeleteObject(titleFont);
  107. titleFont = NULL;
  108. }
  109. break;
  110. case WM_COMMAND:
  111. switch(HIWORD(wParam))
  112. {
  113. case EN_CHANGE:
  114. /* enable apply button */
  115. SendMessageW(GetParent(hDlg), PSM_CHANGED, 0, 0);
  116. break;
  117. }
  118. break;
  119. case WM_DRAWITEM:
  120. if(wParam == IDC_ABT_PANEL)
  121. {
  122. LPDRAWITEMSTRUCT pDIS = (LPDRAWITEMSTRUCT)lParam;
  123. FillRect(pDIS->hDC, &pDIS->rcItem, (HBRUSH) (COLOR_WINDOW+1));
  124. DrawIconEx(pDIS->hDC, 0, 0, logo, 0, 0, 0, 0, DI_IMAGE);
  125. DrawEdge(pDIS->hDC, &pDIS->rcItem, EDGE_SUNKEN, BF_BOTTOM);
  126. }
  127. break;
  128. case WM_CTLCOLORSTATIC:
  129. switch(GetDlgCtrlID((HWND)lParam))
  130. {
  131. case IDC_ABT_TITLE_TEXT:
  132. /* set the title to a wine color */
  133. SetTextColor((HDC)wParam, 0x0000007F);
  134. SetBkColor((HDC)wParam, GetSysColor(COLOR_WINDOW));
  135. return (INT_PTR)GetSysColorBrush(COLOR_WINDOW);
  136. case IDC_ABT_PANEL_TEXT:
  137. case IDC_ABT_LICENSE_TEXT:
  138. case IDC_ABT_WEB_LINK:
  139. SetTextColor((HDC)wParam, GetSysColor(COLOR_WINDOWTEXT));
  140. SetBkColor((HDC)wParam, GetSysColor(COLOR_WINDOW));
  141. return (INT_PTR)GetSysColorBrush(COLOR_WINDOW);
  142. }
  143. break;
  144. }
  145. return FALSE;
  146. }