win32: fixes for unicode in GetMonitorInfo()

git-svn-id: trunk@19241 -
This commit is contained in:
paul 2009-04-06 09:10:30 +00:00
parent 0ef22bee57
commit e2075dffd2
3 changed files with 45 additions and 5 deletions

View File

@ -20,6 +20,7 @@
unit Win32Extra;
{$mode objfpc}{$H+}
{$I win32defines.inc}
{$IFDEF TRACE}
{$ASSERTIONS ON}
@ -953,13 +954,21 @@ begin
lpMonitorInfo^.rcWork := rcWork;
lpMonitorInfo^.dwFlags := MONITORINFOF_PRIMARY;
{$IFDEF WindowsUnicodeSupport}
if UnicodeEnabledOS then
begin
if (lpMonitorInfo^.cbSize >= sizeof(TMonitorInfoExW)) then
PMonitorInfoExW(lpMonitorInfo)^.szDevice := 'DISPLAY'
end
else
{$ENDIF}
if (lpMonitorInfo^.cbSize >= sizeof(TMonitorInfoEx)) then
PMonitorInfoEx(lpMonitorInfo)^.szDevice := 'DISPLAY';
Exit(True);
end;
Result := False;
Result := True;
end
else
Result := False;
end;

View File

@ -1956,8 +1956,29 @@ begin
end;
function TWin32WidgetSet.GetMonitorInfo(hMonitor: HMONITOR; lpmi: PMonitorInfo): Boolean;
{$IFDEF WindowsUnicodeSupport}
var
LocalInfo: TMonitorInfoExW;
{$ENDIF}
begin
Result := Win32Extra.GetMonitorInfo(hMonitor, lpmi);
{$IFDEF WindowsUnicodeSupport}
if (lpmi <> nil) and (lpmi^.cbSize >= SizeOf(TMonitorInfoEx)) then
begin
if UnicodeEnabledOS then
begin
LocalInfo.cbSize := SizeOf(TMonitorInfoExW);
Result := Win32Extra.GetMonitorInfo(hMonitor, @LocalInfo);
lpmi^.rcMonitor := LocalInfo.rcMonitor;
lpmi^.rcWork := LocalInfo.rcWork;
lpmi^.dwFlags := LocalInfo.dwFlags;
PMonitorInfoEx(lpmi)^.szDevice := UTF16ToUTF8(LocalInfo.szDevice);
end
else
PMonitorInfoEx(lpmi)^.szDevice := AnsiToUtf8(PMonitorInfoEx(lpmi)^.szDevice);
end
else
{$ENDIF}
Result := Win32Extra.GetMonitorInfo(hMonitor, lpmi);
end;
{------------------------------------------------------------------------------

View File

@ -885,6 +885,16 @@ type
PMonitorInfoEx = ^TMonitorInfoEx;
TMonitorInfoEx = tagMonitorInfoEx;
tagMonitorInfoExW = record
cbSize: DWord;
rcMonitor: TRect;
rcWork: TRect;
dwFlags: DWord;
szDevice: array[0..CCHDEVICENAME - 1] of WideChar;
end;
PMonitorInfoExW = ^TMonitorInfoExW;
TMonitorInfoExW = tagMonitorInfoExW;
{painting stuff}
PDrawItemStruct = ^TDrawItemStruct;