winapi_test: '* long *' is 4 bytes, not pointer size, on Windows.
[wine.git] / programs / winecfg / about.c
blobfb604dda1848470c8d69874e7273670c98cae7fe
1 /*
2 * WineCfg about panel
4 * Copyright 2002 Jaco Greeff
5 * Copyright 2003 Dimitrie O. Paun
6 * Copyright 2003 Mike Hearn
7 * Copyright 2010 Joel Holdsworth
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.
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.
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
25 #define COBJMACROS
27 #include <windows.h>
28 #include <commctrl.h>
29 #include <shellapi.h>
31 #include "resource.h"
32 #include "winecfg.h"
35 static HICON logo = NULL;
36 static HFONT titleFont = NULL;
38 INT_PTR CALLBACK
39 AboutDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
41 static const WCHAR openW[] = {'o','p','e','n',0};
42 static const WCHAR tahomaW[] = {'T','a','h','o','m','a',0};
43 const char * (CDECL *wine_get_version)(void);
44 HWND hWnd;
45 HDC hDC;
46 RECT rcClient, rcRect;
47 char *owner, *org;
49 switch (uMsg)
51 case WM_NOTIFY:
52 switch(((LPNMHDR)lParam)->code)
54 case PSN_APPLY:
55 /*save registration info to registry */
56 owner = get_text(hDlg, IDC_ABT_OWNER);
57 org = get_text(hDlg, IDC_ABT_ORG);
59 set_reg_key(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion",
60 "RegisteredOwner", owner ? owner : "");
61 set_reg_key(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion",
62 "RegisteredOrganization", org ? org : "");
63 set_reg_key(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows NT\\CurrentVersion",
64 "RegisteredOwner", owner ? owner : "");
65 set_reg_key(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows NT\\CurrentVersion",
66 "RegisteredOrganization", org ? org : "");
67 apply();
69 HeapFree(GetProcessHeap(), 0, owner);
70 HeapFree(GetProcessHeap(), 0, org);
71 break;
73 case NM_CLICK:
74 case NM_RETURN:
75 if(wParam == IDC_ABT_WEB_LINK)
76 ShellExecuteW(NULL, openW, ((NMLINK *)lParam)->item.szUrl, NULL, NULL, SW_SHOW);
77 break;
79 break;
81 case WM_INITDIALOG:
82 hDC = GetDC(hDlg);
84 /* read owner and organization info from registry, load it into text box */
85 owner = get_reg_key(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows NT\\CurrentVersion",
86 "RegisteredOwner", "");
87 org = get_reg_key(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows NT\\CurrentVersion",
88 "RegisteredOrganization", "");
90 SetDlgItemTextA(hDlg, IDC_ABT_OWNER, owner);
91 SetDlgItemTextA(hDlg, IDC_ABT_ORG, org);
93 SendMessageW(GetParent(hDlg), PSM_UNCHANGED, 0, 0);
95 HeapFree(GetProcessHeap(), 0, owner);
96 HeapFree(GetProcessHeap(), 0, org);
98 /* prepare the panel */
99 hWnd = GetDlgItem(hDlg, IDC_ABT_PANEL);
100 if(hWnd)
102 GetClientRect(hDlg, &rcClient);
103 GetClientRect(hWnd, &rcRect);
104 MoveWindow(hWnd, 0, 0, rcClient.right, rcRect.bottom, FALSE);
106 logo = LoadImageW((HINSTANCE)GetWindowLongPtrW(hDlg, GWLP_HINSTANCE),
107 MAKEINTRESOURCEW(IDI_LOGO), IMAGE_ICON, 0, 0, LR_SHARED);
110 /* prepare the title text */
111 titleFont = CreateFontW( -MulDiv(24, GetDeviceCaps(hDC, LOGPIXELSY), 72),
112 0, 0, 0, 0, FALSE, 0, 0, 0, 0, 0, 0, 0, tahomaW );
113 SendDlgItemMessageW(hDlg, IDC_ABT_TITLE_TEXT, WM_SETFONT, (WPARAM)titleFont, TRUE);
115 wine_get_version = (void *)GetProcAddress( GetModuleHandleA("ntdll.dll"), "wine_get_version" );
116 if (wine_get_version) SetDlgItemTextA(hDlg, IDC_ABT_PANEL_TEXT, wine_get_version());
118 ReleaseDC(hDlg, hDC);
120 break;
122 case WM_DESTROY:
123 if(logo)
125 DestroyIcon(logo);
126 logo = NULL;
129 if(titleFont)
131 DeleteObject(titleFont);
132 titleFont = NULL;
135 break;
137 case WM_COMMAND:
138 switch(HIWORD(wParam))
140 case EN_CHANGE:
141 /* enable apply button */
142 SendMessageW(GetParent(hDlg), PSM_CHANGED, 0, 0);
143 break;
145 break;
147 case WM_DRAWITEM:
148 if(wParam == IDC_ABT_PANEL)
150 LPDRAWITEMSTRUCT pDIS = (LPDRAWITEMSTRUCT)lParam;
151 FillRect(pDIS->hDC, &pDIS->rcItem, (HBRUSH) (COLOR_WINDOW+1));
152 DrawIconEx(pDIS->hDC, 0, 0, logo, 0, 0, 0, 0, DI_IMAGE);
153 DrawEdge(pDIS->hDC, &pDIS->rcItem, EDGE_SUNKEN, BF_BOTTOM);
155 break;
157 case WM_CTLCOLORSTATIC:
158 switch(GetDlgCtrlID((HWND)lParam))
160 case IDC_ABT_TITLE_TEXT:
161 /* set the title to a wine color */
162 SetTextColor((HDC)wParam, 0x0000007F);
163 SetBkColor((HDC)wParam, GetSysColor(COLOR_WINDOW));
164 return (INT_PTR)GetSysColorBrush(COLOR_WINDOW);
165 case IDC_ABT_PANEL_TEXT:
166 case IDC_ABT_LICENSE_TEXT:
167 case IDC_ABT_WEB_LINK:
168 SetTextColor((HDC)wParam, GetSysColor(COLOR_WINDOWTEXT));
169 SetBkColor((HDC)wParam, GetSysColor(COLOR_WINDOW));
170 return (INT_PTR)GetSysColorBrush(COLOR_WINDOW);
172 break;
175 return FALSE;