mfplat: Only convert MEDIASUBTYPE for the formats which need it.
[wine.git] / programs / winecfg / about.c
blob0b860bb19558ab8c8f1b1c8e12f282a482b64fe7
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 const char * (CDECL *wine_get_version)(void);
42 HWND hWnd;
43 HDC hDC;
44 RECT rcClient, rcRect;
45 WCHAR *owner, *org;
47 switch (uMsg)
49 case WM_NOTIFY:
50 switch(((LPNMHDR)lParam)->code)
52 case PSN_APPLY:
53 /*save registration info to registry */
54 owner = get_text(hDlg, IDC_ABT_OWNER);
55 org = get_text(hDlg, IDC_ABT_ORG);
57 set_reg_key(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows\\CurrentVersion",
58 L"RegisteredOwner", owner ? owner : L"");
59 set_reg_key(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows\\CurrentVersion",
60 L"RegisteredOrganization", org ? org : L"");
61 set_reg_key(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows NT\\CurrentVersion",
62 L"RegisteredOwner", owner ? owner : L"");
63 set_reg_key(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows NT\\CurrentVersion",
64 L"RegisteredOrganization", org ? org : L"");
65 apply();
67 free(owner);
68 free(org);
69 break;
71 case NM_CLICK:
72 case NM_RETURN:
73 if(wParam == IDC_ABT_WEB_LINK)
74 ShellExecuteW(NULL, L"open", ((NMLINK *)lParam)->item.szUrl, NULL, NULL, SW_SHOW);
75 break;
77 break;
79 case WM_INITDIALOG:
80 hDC = GetDC(hDlg);
82 /* read owner and organization info from registry, load it into text box */
83 owner = get_reg_key(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows NT\\CurrentVersion",
84 L"RegisteredOwner", L"");
85 org = get_reg_key(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows NT\\CurrentVersion",
86 L"RegisteredOrganization", L"");
88 SetDlgItemTextW(hDlg, IDC_ABT_OWNER, owner);
89 SetDlgItemTextW(hDlg, IDC_ABT_ORG, org);
91 SendMessageW(GetParent(hDlg), PSM_UNCHANGED, 0, 0);
93 free(owner);
94 free(org);
96 /* prepare the panel */
97 hWnd = GetDlgItem(hDlg, IDC_ABT_PANEL);
98 if(hWnd)
100 GetClientRect(hDlg, &rcClient);
101 GetClientRect(hWnd, &rcRect);
102 MoveWindow(hWnd, 0, 0, rcClient.right, rcRect.bottom, FALSE);
104 logo = LoadImageW((HINSTANCE)GetWindowLongPtrW(hDlg, GWLP_HINSTANCE),
105 MAKEINTRESOURCEW(IDI_LOGO), IMAGE_ICON, 0, 0, LR_SHARED);
108 /* prepare the title text */
109 titleFont = CreateFontW( -MulDiv(24, GetDeviceCaps(hDC, LOGPIXELSY), 72),
110 0, 0, 0, 0, FALSE, 0, 0, 0, 0, 0, 0, 0, L"Tahoma" );
111 SendDlgItemMessageW(hDlg, IDC_ABT_TITLE_TEXT, WM_SETFONT, (WPARAM)titleFont, TRUE);
113 wine_get_version = (void *)GetProcAddress( GetModuleHandleW(L"ntdll.dll"), "wine_get_version" );
114 if (wine_get_version) SetDlgItemTextA(hDlg, IDC_ABT_PANEL_TEXT, wine_get_version());
116 ReleaseDC(hDlg, hDC);
118 break;
120 case WM_DESTROY:
121 if(logo)
123 DestroyIcon(logo);
124 logo = NULL;
127 if(titleFont)
129 DeleteObject(titleFont);
130 titleFont = NULL;
133 break;
135 case WM_COMMAND:
136 switch(HIWORD(wParam))
138 case EN_CHANGE:
139 /* enable apply button */
140 SendMessageW(GetParent(hDlg), PSM_CHANGED, 0, 0);
141 break;
143 break;
145 case WM_DRAWITEM:
146 if(wParam == IDC_ABT_PANEL)
148 LPDRAWITEMSTRUCT pDIS = (LPDRAWITEMSTRUCT)lParam;
149 FillRect(pDIS->hDC, &pDIS->rcItem, (HBRUSH) (COLOR_WINDOW+1));
150 DrawIconEx(pDIS->hDC, 0, 0, logo, 0, 0, 0, 0, DI_IMAGE);
151 DrawEdge(pDIS->hDC, &pDIS->rcItem, EDGE_SUNKEN, BF_BOTTOM);
153 break;
155 case WM_CTLCOLORSTATIC:
156 switch(GetDlgCtrlID((HWND)lParam))
158 case IDC_ABT_TITLE_TEXT:
159 /* set the title to a wine color */
160 SetTextColor((HDC)wParam, 0x0000007F);
161 SetBkColor((HDC)wParam, GetSysColor(COLOR_WINDOW));
162 return (INT_PTR)GetSysColorBrush(COLOR_WINDOW);
163 case IDC_ABT_PANEL_TEXT:
164 case IDC_ABT_LICENSE_TEXT:
165 case IDC_ABT_WEB_LINK:
166 SetTextColor((HDC)wParam, GetSysColor(COLOR_WINDOWTEXT));
167 SetBkColor((HDC)wParam, GetSysColor(COLOR_WINDOW));
168 return (INT_PTR)GetSysColorBrush(COLOR_WINDOW);
170 break;
173 return FALSE;