source: trunk/src/user32/display.cpp@ 1818

Last change on this file since 1818 was 1818, checked in by sandervl, 26 years ago

display api fixes

File size: 9.2 KB
Line 
1/* $Id: display.cpp,v 1.1 1999-11-23 19:34:19 sandervl Exp $ */
2/*
3 * Display/Monitor Win32 apis
4 *
5 * Based on Wine code (991031)
6 *
7 * Copyright 1993 Robert J. Amstadt
8 * 1996 Alex Korobka
9 *
10 * Project Odin Software License can be found in LICENSE.TXT
11 *
12 */
13#include <os2win.h>
14#include <misc.h>
15#include <heapstring.h>
16#include "pmwindow.h"
17
18#define NRMODES 5
19#define NRDEPTHS 4
20struct {
21 int w,h;
22} modes[NRMODES]={{512,384},{640,400},{640,480},{800,600},{1024,768}};
23int depths[4] = {8,16,24,32};
24
25/*****************************************************************************
26 * Name : BOOL WIN32API EnumDisplaySettingsA
27 * Purpose : The EnumDisplaySettings function obtains information about one
28 * of a display device's graphics modes. You can obtain information
29 * for all of a display device's graphics modes by making a series
30 * of calls to this function.
31 * Parameters: LPCTSTR lpszDeviceName specifies the display device
32 * DWORD iModeNum specifies the graphics mode
33 * LPDEVMODE lpDevMode points to structure to receive settings
34 * Variables :
35 * Result : If the function succeeds, the return value is TRUE.
36 * If the function fails, the return value is FALSE.
37 * Remark :
38 * Status :
39 *
40 * Author : Wine Port (991031)
41 *****************************************************************************/
42BOOL WIN32API EnumDisplaySettingsA(
43 LPCSTR name, /* [in] huh? */
44 DWORD n, /* [in] nth entry in display settings list*/
45 LPDEVMODEA devmode /* [out] devmode for that setting */
46)
47{
48 dprintf(("USER32: EnumDisplaySettingsA %d", n));
49 if (n==0) {
50 devmode->dmBitsPerPel = ScreenBitsPerPel;
51 devmode->dmPelsHeight = ScreenHeight;
52 devmode->dmPelsWidth = ScreenWidth;
53 return TRUE;
54 }
55 if ((n-1)<NRMODES*NRDEPTHS) {
56 devmode->dmBitsPerPel = depths[(n-1)/NRMODES];
57 devmode->dmPelsHeight = modes[(n-1)%NRMODES].h;
58 devmode->dmPelsWidth = modes[(n-1)%NRMODES].w;
59 return TRUE;
60 }
61 return FALSE;
62}
63
64/*****************************************************************************
65 * Name : BOOL WIN32API EnumDisplaySettingsW
66 * Purpose : The EnumDisplaySettings function obtains information about one
67 * of a display device's graphics modes. You can obtain information
68 * for all of a display device's graphics modes by making a series
69 * of calls to this function.
70 * Parameters: LPCTSTR lpszDeviceName specifies the display device
71 * DWORD iModeNum specifies the graphics mode
72 * LPDEVMODE lpDevMode points to structure to receive settings
73 * Variables :
74 * Result : If the function succeeds, the return value is TRUE.
75 * If the function fails, the return value is FALSE.
76 * Remark :
77 * Status :
78 *
79 * Author : Wine Port (991031)
80 *****************************************************************************/
81BOOL WIN32API EnumDisplaySettingsW(LPCWSTR name,DWORD n,LPDEVMODEW devmode)
82{
83 LPSTR nameA = NULL;
84 DEVMODEA devmodeA;
85 BOOL ret;
86
87 if(name) {
88 nameA = HEAP_strdupWtoA(GetProcessHeap(),0,name);
89 }
90 ret = EnumDisplaySettingsA(nameA,n,&devmodeA);
91
92 if (ret) {
93 devmode->dmBitsPerPel = devmodeA.dmBitsPerPel;
94 devmode->dmPelsHeight = devmodeA.dmPelsHeight;
95 devmode->dmPelsWidth = devmodeA.dmPelsWidth;
96 /* FIXME: convert rest too, if they are ever returned */
97 }
98 if(name)
99 HeapFree(GetProcessHeap(),0,nameA);
100 return ret;
101}
102//******************************************************************************
103//******************************************************************************
104LONG WIN32API ChangeDisplaySettingsA(LPDEVMODEA lpDevMode, DWORD dwFlags)
105{
106 // lpDevMode might be NULL when change to default desktop mode
107 // is being requested, this was the cause of trap
108 if ( !lpDevMode )
109 {
110 return(DISP_CHANGE_SUCCESSFUL);
111 }
112#ifdef DEBUG
113 if(lpDevMode) {
114 WriteLog("USER32: ChangeDisplaySettingsA FAKED %X\n", dwFlags);
115 WriteLog("USER32: ChangeDisplaySettingsA lpDevMode->dmBitsPerPel %d\n", lpDevMode->dmBitsPerPel);
116 WriteLog("USER32: ChangeDisplaySettingsA lpDevMode->dmPelsWidth %d\n", lpDevMode->dmPelsWidth);
117 WriteLog("USER32: ChangeDisplaySettingsA lpDevMode->dmPelsHeight %d\n", lpDevMode->dmPelsHeight);
118 }
119#endif
120 return(DISP_CHANGE_SUCCESSFUL);
121}
122/*****************************************************************************
123 * Name : LONG WIN32API ChangeDisplaySettingsW
124 * Purpose : The ChangeDisplaySettings function changes the display settings
125 * to the specified graphics mode.
126 * Parameters: LPDEVMODEW lpDevModeW
127 * DWORD dwFlags
128 * Variables :
129 * Result : DISP_CHANGE_SUCCESSFUL The settings change was successful.
130 * DISP_CHANGE_RESTART The computer must be restarted in order for the graphics mode to work.
131 * DISP_CHANGE_BADFLAGS An invalid set of flags was passed in.
132 * DISP_CHANGE_FAILED The display driver failed the specified graphics mode.
133 * DISP_CHANGE_BADMODE The graphics mode is not supported.
134 * DISP_CHANGE_NOTUPDATED Unable to write settings to the registry.
135 * Remark :
136 * Status : UNTESTED STUB
137 *
138 * Author : Patrick Haller [Wed, 1998/06/16 11:55]
139 *****************************************************************************/
140LONG WIN32API ChangeDisplaySettingsW(LPDEVMODEW lpDevMode,
141 DWORD dwFlags)
142{
143 dprintf(("USER32:ChangeDisplaySettingsW(%08xh,%08x) not implemented.\n",
144 lpDevMode,
145 dwFlags));
146
147 return (ChangeDisplaySettingsA((LPDEVMODEA)lpDevMode,
148 dwFlags));
149}
150//******************************************************************************
151//******************************************************************************
152LONG WIN32API ChangeDisplaySettingsExA(LPCSTR devname, LPDEVMODEA lpDevMode,
153 HWND hwnd, DWORD dwFlags, LPARAM lparam)
154{
155 // lpDevMode might be NULL when change to default desktop mode
156 // is being requested, this was the cause of trap
157 if ( !lpDevMode )
158 {
159 return(DISP_CHANGE_SUCCESSFUL);
160 }
161#ifdef DEBUG
162 if(lpDevMode) {
163 WriteLog("USER32: ChangeDisplaySettingsExA FAKED %X\n", dwFlags);
164 WriteLog("USER32: ChangeDisplaySettingsExA lpDevMode->dmBitsPerPel %d\n", lpDevMode->dmBitsPerPel);
165 WriteLog("USER32: ChangeDisplaySettingsExA lpDevMode->dmPelsWidth %d\n", lpDevMode->dmPelsWidth);
166 WriteLog("USER32: ChangeDisplaySettingsExA lpDevMode->dmPelsHeight %d\n", lpDevMode->dmPelsHeight);
167 }
168#endif
169 return(DISP_CHANGE_SUCCESSFUL);
170}
171//******************************************************************************
172//******************************************************************************
173LONG WIN32API ChangeDisplaySettingsExW(LPCWSTR devname, LPDEVMODEW lpDevMode,
174 HWND hwnd, DWORD dwFlags, LPARAM lparam)
175{
176 dprintf(("USER32:ChangeDisplaySettingsExW(%08xh,%08x) NOT implemented.\n",
177 lpDevMode,
178 dwFlags));
179
180 //TODO: Need unicode translation
181 return (ChangeDisplaySettingsExA((LPCSTR)devname, (LPDEVMODEA)lpDevMode,
182 hwnd, dwFlags, lparam));
183}
184//******************************************************************************
185//******************************************************************************
186BOOL WIN32API GetMonitorInfoA(HMONITOR,LPMONITORINFO)
187{
188 dprintf(("USER32: GetMonitorInfoA not supported!!\n"));
189 return(FALSE);
190}
191//******************************************************************************
192//******************************************************************************
193BOOL WIN32API GetMonitorInfoW(HMONITOR,LPMONITORINFO)
194{
195 dprintf(("USER32: GetMonitorInfoW not supported!!\n"));
196 return(FALSE);
197}
198//******************************************************************************
199//******************************************************************************
200HMONITOR WIN32API MonitorFromWindow(HWND hwnd, DWORD dwFlags)
201{
202 dprintf(("USER32: MonitorFromWindow not correctly supported??\n"));
203 //Attention: Win32 hwnd!
204
205 return(0);
206}
207//******************************************************************************
208//******************************************************************************
209HMONITOR WIN32API MonitorFromRect(LPRECT rect, DWORD dwFlags)
210{
211 dprintf(("USER32: MonitorFromRect not correctly supported??\n"));
212 return(0);
213}
214//******************************************************************************
215//******************************************************************************
216HMONITOR WIN32API MonitorFromPoint(POINT point, DWORD dwflags)
217{
218 dprintf(("USER32: MonitorFromPoint not correctly supported??\n"));
219 return(0);
220}
221//******************************************************************************
222//******************************************************************************
223BOOL WIN32API EnumDisplayMonitors(HDC,LPRECT,MONITORENUMPROC,LPARAM)
224{
225 dprintf(("USER32: EnumDisplayMonitors not supported??\n"));
226 return(FALSE);
227}
228//******************************************************************************
229//******************************************************************************
Note: See TracBrowser for help on using the repository browser.