about.c 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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. static const WCHAR openW[] = {'o','p','e','n',0};
  36. static const WCHAR tahomaW[] = {'T','a','h','o','m','a',0};
  37. const char * (CDECL *wine_get_version)(void);
  38. HWND hWnd;
  39. HDC hDC;
  40. RECT rcClient, rcRect;
  41. char *owner, *org;
  42. switch (uMsg)
  43. {
  44. case WM_NOTIFY:
  45. switch(((LPNMHDR)lParam)->code)
  46. {
  47. case PSN_APPLY:
  48. /*save registration info to registry */
  49. owner = get_text(hDlg, IDC_ABT_OWNER);
  50. org = get_text(hDlg, IDC_ABT_ORG);
  51. set_reg_key(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion",
  52. "RegisteredOwner", owner ? owner : "");
  53. set_reg_key(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion",
  54. "RegisteredOrganization", org ? org : "");
  55. set_reg_key(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows NT\\CurrentVersion",
  56. "RegisteredOwner", owner ? owner : "");
  57. set_reg_key(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows NT\\CurrentVersion",
  58. "RegisteredOrganization", org ? org : "");
  59. apply();
  60. HeapFree(GetProcessHeap(), 0, owner);
  61. HeapFree(GetProcessHeap(), 0, org);
  62. break;
  63. case NM_CLICK:
  64. case NM_RETURN:
  65. if(wParam == IDC_ABT_WEB_LINK)
  66. ShellExecuteW(NULL, openW, ((NMLINK *)lParam)->item.szUrl, NULL, NULL, SW_SHOW);
  67. break;
  68. }
  69. break;
  70. case WM_INITDIALOG:
  71. hDC = GetDC(hDlg);
  72. /* read owner and organization info from registry, load it into text box */
  73. owner = get_reg_key(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows NT\\CurrentVersion",
  74. "RegisteredOwner", "");
  75. org = get_reg_key(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows NT\\CurrentVersion",
  76. "RegisteredOrganization", "");
  77. SetDlgItemTextA(hDlg, IDC_ABT_OWNER, owner);
  78. SetDlgItemTextA(hDlg, IDC_ABT_ORG, org);
  79. SendMessageW(GetParent(hDlg), PSM_UNCHANGED, 0, 0);
  80. HeapFree(GetProcessHeap(), 0, owner);
  81. HeapFree(GetProcessHeap(), 0, org);
  82. /* prepare the panel */
  83. hWnd = GetDlgItem(hDlg, IDC_ABT_PANEL);
  84. if(hWnd)
  85. {
  86. GetClientRect(hDlg, &rcClient);
  87. GetClientRect(hWnd, &rcRect);
  88. MoveWindow(hWnd, 0, 0, rcClient.right, rcRect.bottom, FALSE);
  89. logo = LoadImageW((HINSTANCE)GetWindowLongPtrW(hDlg, GWLP_HINSTANCE),
  90. MAKEINTRESOURCEW(IDI_LOGO), IMAGE_ICON, 0, 0, LR_SHARED);
  91. }
  92. /* prepare the title text */
  93. titleFont = CreateFontW( -MulDiv(24, GetDeviceCaps(hDC, LOGPIXELSY), 72),
  94. 0, 0, 0, 0, FALSE, 0, 0, 0, 0, 0, 0, 0, tahomaW );
  95. SendDlgItemMessageW(hDlg, IDC_ABT_TITLE_TEXT, WM_SETFONT, (WPARAM)titleFont, TRUE);
  96. wine_get_version = (void *)GetProcAddress( GetModuleHandleA("ntdll.dll"), "wine_get_version" );
  97. if (wine_get_version) SetDlgItemTextA(hDlg, IDC_ABT_PANEL_TEXT, wine_get_version());
  98. ReleaseDC(hDlg, hDC);
  99. break;
  100. case WM_DESTROY:
  101. if(logo)
  102. {
  103. DestroyIcon(logo);
  104. logo = NULL;
  105. }
  106. if(titleFont)
  107. {
  108. DeleteObject(titleFont);
  109. titleFont = NULL;
  110. }
  111. break;
  112. case WM_COMMAND:
  113. switch(HIWORD(wParam))
  114. {
  115. case EN_CHANGE:
  116. /* enable apply button */
  117. SendMessageW(GetParent(hDlg), PSM_CHANGED, 0, 0);
  118. break;
  119. }
  120. break;
  121. case WM_DRAWITEM:
  122. if(wParam == IDC_ABT_PANEL)
  123. {
  124. LPDRAWITEMSTRUCT pDIS = (LPDRAWITEMSTRUCT)lParam;
  125. FillRect(pDIS->hDC, &pDIS->rcItem, (HBRUSH) (COLOR_WINDOW+1));
  126. DrawIconEx(pDIS->hDC, 0, 0, logo, 0, 0, 0, 0, DI_IMAGE);
  127. DrawEdge(pDIS->hDC, &pDIS->rcItem, EDGE_SUNKEN, BF_BOTTOM);
  128. }
  129. break;
  130. case WM_CTLCOLORSTATIC:
  131. switch(GetDlgCtrlID((HWND)lParam))
  132. {
  133. case IDC_ABT_TITLE_TEXT:
  134. /* set the title to a wine color */
  135. SetTextColor((HDC)wParam, 0x0000007F);
  136. SetBkColor((HDC)wParam, GetSysColor(COLOR_WINDOW));
  137. return (INT_PTR)GetSysColorBrush(COLOR_WINDOW);
  138. case IDC_ABT_PANEL_TEXT:
  139. case IDC_ABT_LICENSE_TEXT:
  140. case IDC_ABT_WEB_LINK:
  141. SetTextColor((HDC)wParam, GetSysColor(COLOR_WINDOWTEXT));
  142. SetBkColor((HDC)wParam, GetSysColor(COLOR_WINDOW));
  143. return (INT_PTR)GetSysColorBrush(COLOR_WINDOW);
  144. }
  145. break;
  146. }
  147. return FALSE;
  148. }