Win32: Remove the use of IfDef's for WindowsUnicodeSupport, since it does not make sense anymore (it is always defined).

git-svn-id: trunk@50515 -
This commit is contained in:
bart 2015-11-27 18:19:40 +00:00
parent efc3ca18be
commit f82432a859
23 changed files with 71 additions and 653 deletions

View File

@ -1030,10 +1030,8 @@ var
L: LongWord;
I, C: Integer;
DropForm: TWinControl;
{$IFDEF WindowsUnicodeSupport}
AnsiBuffer: string;
WideBuffer: WideString;
{$ENDIF}
begin
Drop := HDROP(WParam);
try
@ -1043,7 +1041,6 @@ begin
SetLength(Files, C);
for I := 0 to C - 1 do
begin
{$IFDEF WindowsUnicodeSupport}
if UnicodeEnabledOS then
begin
L := DragQueryFileW(Drop, I, nil, 0); // get I. file name length
@ -1060,11 +1057,6 @@ begin
SetLength(WideBuffer, L);
Files[I] := ANSIToUTF8(AnsiBuffer);
end;
{$ELSE}
L := DragQueryFile(Drop, I, nil, 0); // get I. file name length
SetLength(Files[I], L);
DragQueryFile(Drop, I, PChar(Files[I]), L + 1);
{$ENDIF}
end;
if Length(Files) > 0 then
@ -1198,7 +1190,6 @@ end;
procedure TWindowProcHelper.DoMsgChar(var WinResult: LResult);
begin
{$ifdef WindowsUnicodeSupport}
// first send a IntfUTF8KeyPress to the LCL
// if the key was not handled send a CN_CHAR for AnsiChar<=#127
OrgCharCode := Word(WParam);
@ -1220,17 +1211,6 @@ begin
end
else
WParam := OrgCharCode;
{$else}
PLMsg := @LMChar;
with LMChar do
begin
Msg := CN_CHAR;
KeyData := LParam;
CharCode := Word(WParam);
WinResult := 0;
end;
WinProcess := false;
{$endif}
end;
procedure TWindowProcHelper.DoCmdCheckBoxParam;
@ -2455,7 +2435,6 @@ begin
begin
// if key not yet processed, let windows process it
WinProcess := LMChar.Result = 0;
{$IFDEF WindowsUnicodeSupport}
if UnicodeEnabledOS then
begin
// if charcode was modified by LCL, convert ansi char
@ -2465,7 +2444,6 @@ begin
WParam := Word(WideChar(LMChar.CharCode));
end
else
{$ENDIF}
WParam := LMChar.CharCode;
end;

View File

@ -21,9 +21,5 @@
// valuable for investigation of message trees / interrelations
{ $define MSG_DEBUG}
{$IFNDEF DisableWindowsUnicodeSupport}
// Enable WindowsUnicodeSupport for fpc 2.2.1 and higher
{$DEFINE WindowsUnicodeSupport}
{$ENDIF DisableWindowsUnicodeSupport}
{$DEFINE UseVistaDialogs}
{.$DEFINE RedirectDestroyMessages}

View File

@ -296,11 +296,7 @@ initialization
MouseDownTime := GetTickCount - 5000
else
MouseDownTime := 0;
{$IFDEF WindowsUnicodeSupport}
SystemCharSetIsUTF8:=true;
{$ELSE}
SystemCharSetIsUTF8:=false;
{$ENDIF}
if (Win32MajorVersion = 4) and (Win32MinorVersion = 0)
then MMenuItemInfoSize := W95_MENUITEMINFO_SIZE

View File

@ -100,11 +100,7 @@ end;
------------------------------------------------------------------------------}
function TWin32WidgetSet.FontCanUTF8(Font: HFont): boolean;
begin
{$ifdef WindowsUnicodeSupport}
Result := True;
{$else}
Result := False;
{$endif}
Result := True;
end;
procedure TWin32WidgetSet.HandleProcessEvent(AData: PtrInt; AFlags: dword);

View File

@ -119,17 +119,12 @@ var
begin
for Counter := 0 To TheStrings.Count - 1 Do
begin
{$ifdef WindowsUnicodeSupport}
if UnicodeEnabledOS then
AnIndex := Windows.SendMessageW(FWin32List, FFlagAddString, 0,
LPARAM(PWideChar(UTF8ToUTF16(TheStrings[Counter])))) //Insert
else
AnIndex := Windows.SendMessage(FWin32List, FFlagAddString, 0,
LPARAM(PChar(Utf8ToAnsi(TheStrings[Counter])))); //Insert
{$else}
AnIndex := Windows.SendMessage(FWin32List, FFlagAddString, 0,
LPARAM(PChar(TheStrings[Counter]))); //Insert
{$endif}
PutObject(AnIndex, TheStrings.Objects[Counter]);
end;
end;
@ -156,18 +151,13 @@ end;
------------------------------------------------------------------------------}
function TWin32ListStringList.Get(Index: Integer): String;
Var
{$ifdef WindowsUnicodeSupport}
s: string;
w: widestring;
{$else}
Item: PChar;
{$endif}
begin
if (Index < 0) Or (Index >= Count) then
raise Exception.Create('Out of bounds.')
else
begin
{$ifdef WindowsUnicodeSupport}
if UnicodeEnabledOS then
begin
SetLength(w, Windows.SendMessageW(FWin32List, FFlagGetTextLen, Index, 0));
@ -180,12 +170,6 @@ begin
Windows.SendMessage(FWin32List, FFlagGetText, Index, LPARAM(PChar(s)));
Result := AnsiToUtf8(s);
end;
{$else}
Getmem(Item, Windows.SendMessage(FWin32List, FFlagGetTextLen, Index, 0)+1);
Windows.SendMessage(FWin32List, FFlagGetText, Index, LPARAM(Item));
Result := Item;
FreeMem(Item);
{$endif}
end;
end;
@ -251,25 +235,17 @@ begin
FLastInsertedIndex := Index;
if FSorted then
begin
{$ifdef WindowsUnicodeSupport}
if UnicodeEnabledOS then
FLastInsertedIndex := Windows.SendMessageW(FWin32List, FFlagAddString, 0, LPARAM(PWideChar(UTF8ToUTF16(S))))
else
FLastInsertedIndex := Windows.SendMessage(FWin32List, FFlagAddString, 0, LPARAM(PChar(Utf8ToAnsi(S))));
{$else}
FLastInsertedIndex := Windows.SendMessage(FWin32List, FFlagAddString, 0, LPARAM(PChar(S)));
{$endif}
end
else
begin
{$ifdef WindowsUnicodeSupport}
if UnicodeEnabledOS then
Windows.SendMessageW(FWin32List, FFlagInsertString, Index, LPARAM(PWideChar(UTF8ToUTF16(S))))
else
Windows.SendMessage(FWin32List, FFlagInsertString, Index, LPARAM(PChar(Utf8ToAnsi(S))));
{$else}
Windows.SendMessage(FWin32List, FFlagInsertString, Index, LPARAM(PChar(S)));
{$endif}
end;
if (FFlagSetCaretIndex <> 0) and (GetCount = 1) then

View File

@ -38,27 +38,18 @@ type
function TWin32MemoStrings.GetLineLength(Index: Integer): Integer;
begin
//{$ifdef WindowsUnicodeSupport}{$else}{$endif WindowsUnicodeSupport}
{$ifdef WindowsUnicodeSupport}
if UnicodeEnabledOS then
Result := Integer(SendMessageW(FHandle, EM_LINELENGTH, SendMessageW(FHandle, EM_LINEINDEX, Index, 0), 0))
else
Result := Integer(SendMessage(FHandle, EM_LINELENGTH, SendMessage(FHandle, EM_LINEINDEX, Index, 0), 0));
{$else}
Result := Integer(SendMessage(FHandle, EM_LINELENGTH, SendMessage(FHandle, EM_LINEINDEX, Index, 0), 0));
{$endif WindowsUnicodeSupport}
end;
function TWin32MemoStrings.GetLineStart(Index: Integer): Integer;
begin
{$ifdef WindowsUnicodeSupport}
if UnicodeEnabledOS then
Result := Integer(SendMessageW(FHandle, EM_LINEINDEX, Index, 0))
else
Result := Integer(SendMessage(FHandle, EM_LINEINDEX, Index, 0));
{$else}
Result := Integer(SendMessage(FHandle, EM_LINEINDEX, Index, 0));
{$endif WindowsUnicodeSupport}
end;
function TWin32MemoStrings.GetTextStr: string;
@ -80,10 +71,8 @@ end;
function TWin32MemoStrings.Get(Index: Integer): string;
var
len: Integer;
{$ifdef WindowsUnicodeSupport}
WideBuffer: WideString;
AnsiBuffer: string;
{$endif WindowsUnicodeSupport}
begin
len := GetLineLength(Index);
if len=0 then
@ -91,7 +80,6 @@ begin
Result := '';
exit;
end;
{$ifdef WindowsUnicodeSupport}
if UnicodeEnabledOS then
begin
Setlength(WideBuffer, len);
@ -108,17 +96,6 @@ begin
Result := AnsiToUtf8(AnsiBuffer);
end;
{$else}
Setlength(Result, len);
// no need for temp buf and moving
// the result is without null terminator.
PWord(@Result[1])^ := len+1;
len := SendMessage(FHandle, EM_GETLINE, Index, lparam(pchar(Result)));
// read just length in case something went wrong
Setlength(Result, len);
{$endif}
end;
procedure TWin32MemoStrings.SetUpdateState(Updating: Boolean);
@ -176,7 +153,6 @@ begin
LineStart := GetLineStart(Index);
LineEnd := GetLineStart(Index+1);
if LineEnd < 0 then LineEnd := LineStart+GetLineLength(Index);
{$ifdef WindowsUnicodeSupport}
if UnicodeEnabledOS then
begin
SendMessageW(FHandle, EM_SETSEL, LineStart, LineEnd);
@ -187,10 +163,6 @@ begin
SendMessage(FHandle, EM_SETSEL, LineStart, LineEnd);
SendMessage(FHandle, EM_REPLACESEL,0 , lparam(PChar('')));
end;
{$else}
SendMessage(FHandle, EM_SETSEL, LineStart, LineEnd);
SendMessage(FHandle, EM_REPLACESEL,0 , lparam(PChar('')));
{$endif WindowsUnicodeSupport}
end;
procedure TWin32MemoStrings.Insert(Index: integer; const S: string);
@ -204,7 +176,6 @@ begin
//insert with LineEnding
LineStart := GetLineStart(Index);
NewLine := S+LineEnding;
{$ifdef WindowsUnicodeSupport}
if UnicodeEnabledOS
then
begin
@ -216,36 +187,24 @@ begin
SendMessage(FHandle, EM_SETSEL, LineStart, LineStart);
SendMessage(FHandle, EM_REPLACESEL, 0, lparam(Utf8ToAnsi(NewLine)))
end;
{$else}
SendMessage(FHandle, EM_SETSEL, LineStart, LineStart);
SendMessage(FHandle, EM_REPLACESEL, 0, lparam(PChar(NewLine)));
{$endif WindowsUnicodeSupport}
end
else
begin
//append with a preceding LineEnding
LineStart := GetLineStart(Index-1)+GetLineLength(Index-1);
{$ifdef WindowsUnicodeSupport}
if UnicodeEnabledOS then
SendMessageW(FHandle, EM_SETSEL, LineStart, LineStart)
else
SendMessage(FHandle, EM_SETSEL, LineStart, LineStart);
{$else}
SendMessage(FHandle, EM_SETSEL, LineStart, LineStart);
{$endif WindowsUnicodeSupport}
if GetRealCount = Count then
NewLine := LineEnding+S+LineEnding
else
NewLine := S+LineEnding;
{$ifdef WindowsUnicodeSupport}
if UnicodeEnabledOS
then
SendMessageW(FHandle, EM_REPLACESEL, 0, lparam(PWideChar(UTF8ToUTF16(NewLine))))
else
SendMessage(FHandle, EM_REPLACESEL, 0, lparam(Utf8ToAnsi(NewLine)));
{$else}
SendMessage(FHandle, EM_REPLACESEL, 0, lparam(PChar(NewLine)));
{$endif}
end;
end;
@ -257,13 +216,9 @@ begin
AdjustedValue := AdjustLineBreaks(Value);
if (AdjustedValue <> Text) then
begin
{$ifdef WindowsUnicodeSupport}
if UnicodeEnabledOS
then Windows.SetWindowTextW(FHandle, PWideChar(UTF8ToUTF16(AdjustedValue)))
else Windows.SetWindowText(FHandle, PChar(Utf8ToAnsi(AdjustedValue)));
{$else}
SendMessage(FHandle, WM_SETTEXT, 0, LPARAM(PChar(AdjustedValue)));
{$endif}
FillChar(Msg, SizeOf(Msg), 0);
Msg.Msg := CM_TEXTCHANGED;
DeliverMessage(Owner, Msg);

View File

@ -362,14 +362,10 @@ begin
break;
end;
TranslateMessage(@AMessage);
{$IFDEF WindowsUnicodeSupport}
if UnicodeEnabledOS then
DispatchMessageW(@AMessage)
else
DispatchMessage(@AMessage);
{$ELSE}
DispatchMessage(@AMessage);
{$ENDIF}
end;
end else
if retVal = WAIT_TIMEOUT then
@ -472,14 +468,10 @@ procedure TWin32WidgetSet.AppSetTitle(const ATitle: string);
begin
if FAppHandle <> 0 then
begin
{$ifdef WindowsUnicodeSupport}
if UnicodeEnabledOS then
Windows.SetWindowTextW(FAppHandle, PWideChar(UTF8ToUTF16(ATitle)))
else
Windows.SetWindowText(FAppHandle, PChar(Utf8ToAnsi(ATitle)));
{$else}
Windows.SetWindowText(FAppHandle, PChar(ATitle));
{$endif}
end;
end;
@ -534,12 +526,7 @@ begin
lcApplicationWindow: Result := LCL_CAPABILITY_YES;
lcLMHelpSupport: Result := LCL_CAPABILITY_YES;
lcNeedMininimizeAppWithMainForm: Result := LCL_CAPABILITY_NO;
lcSendsUTF8KeyPress:
{$ifdef WindowsUnicodeSupport}
Result := LCL_CAPABILITY_YES;
{$else}
Result := LCL_CAPABILITY_NO;
{$endif}
lcSendsUTF8KeyPress: Result := LCL_CAPABILITY_YES;
else
Result := inherited;
end;
@ -686,7 +673,6 @@ procedure TWin32WidgetSet.CreateAppHandle;
var
SysMenu: HMENU;
begin
{$ifdef WindowsUnicodeSupport}
if UnicodeEnabledOS then
FAppHandle := CreateWindowW(@ClsNameW,
PWideChar(UTF8ToUTF16(Application.Title)),
@ -700,13 +686,6 @@ begin
0, {Windows.GetSystemMetrics(SM_CXSCREEN) div 2,}
0, {Windows.GetSystemMetrics(SM_CYSCREEN) div 2,}
0, 0, HWND(nil), HMENU(nil), HInstance, nil);
{$else}
FAppHandle := CreateWindow(@ClsName, PChar(Application.Title), WS_POPUP or
WS_CLIPSIBLINGS or WS_SYSMENU or WS_MINIMIZEBOX,
0, {Windows.GetSystemMetrics(SM_CXSCREEN) div 2,}
0, {Windows.GetSystemMetrics(SM_CYSCREEN) div 2,}
0, 0, HWND(nil), HMENU(nil), HInstance, nil);
{$endif}
AllocWindowInfo(FAppHandle);
// remove useless menuitems from sysmenu
SysMenu := Windows.GetSystemMenu(FAppHandle, False);

View File

@ -185,7 +185,6 @@ begin
if PtrUInt(TCI.lParam) = PtrUInt(AWinControl) then
begin
TCI.mask := TCIF_TEXT;
{$ifdef WindowsUnicodeSupport}
if UnicodeEnabledOS then
begin
TCI.pszText := PChar(PWideChar(UTF8ToUTF16(AText)));
@ -196,10 +195,6 @@ begin
TCI.pszText := PChar(UTF8ToAnsi(AText));
Windows.SendMessage(TabControlHandle, TCM_SETITEM, RealIndex, LPARAM(@TCI));
end;
{$else}
TCI.pszText := PChar(AText);
Windows.SendMessage(TabControlHandle, TCM_SETITEM, RealIndex, LPARAM(@TCI));
{$endif}
LCLControlSizeNeedsUpdate(TabControl, True);
end;
end;
@ -344,7 +339,6 @@ begin
// store object as extra, so we can verify we got the right page later
TCI.lParam := PtrInt(AChild);
TCI.iImage := ATabControl.GetImageIndex(ATabControl.TabToPageIndex(AIndex));
{$ifdef WindowsUnicodeSupport}
if UnicodeEnabledOS then
begin
TCI.pszText := PChar(PWideChar(UTF8ToUTF16(AChild.Caption)));
@ -355,10 +349,6 @@ begin
TCI.pszText := PChar(Utf8ToAnsi(AChild.Caption));
Windows.SendMessage(Handle, TCM_INSERTITEM, AIndex, LPARAM(@TCI));
end;
{$else}
TCI.pszText := PChar(AChild.Caption);
Windows.SendMessage(Handle, TCM_INSERTITEM, AIndex, LPARAM(@TCI));
{$endif}
end;
// clientrect possible changed, adding first tab, or deleting last
// windows should send a WM_SIZE message because of this, but it doesn't
@ -382,17 +372,12 @@ begin
Index := AChild.VisibleIndex;
TCI.Mask := TCIF_IMAGE or TCIF_PARAM;
{$ifdef WindowsUnicodeSupport}
if UnicodeEnabledOS then
Windows.SendMessage(ATabControl.Handle, TCM_GETITEMW, Windows.WPARAM(Index), LParam(@TCI))
else
Windows.SendMessage(ATabControl.Handle, TCM_GETITEM, Windows.WPARAM(Index), LParam(@TCI));
{$else}
Windows.SendMessage(ATabControl.Handle, TCM_GETITEM, Windows.WPARAM(Index), LParam(@TCI));
{$endif}
Windows.SendMessage(ATabControl.Handle, TCM_DELETEITEM, Windows.WPARAM(Index), 0);
TCI.Mask := TCI.Mask or TCIF_TEXT;
{$ifdef WindowsUnicodeSupport}
if UnicodeEnabledOS then
begin
TCI.pszText := PChar(PWideChar(UTF8ToUTF16(AChild.Caption)));
@ -403,10 +388,6 @@ begin
TCI.pszText := PChar(Utf8ToAnsi(AChild.Caption));
Windows.SendMessage(ATabControl.Handle, TCM_INSERTITEM, NewIndex, LPARAM(@TCI));
end;
{$else}
TCI.pszText := PChar(AChild.Caption);
Windows.SendMessage(ATabControl.Handle, TCM_INSERTITEM, NewIndex, LPARAM(@TCI));
{$endif}
if LCLControlSizeNeedsUpdate(ATabControl, True) then
AdjustSizeTabControlPages(ATabControl);
end;
@ -487,7 +468,6 @@ begin
TCI.Mask := TCIF_TEXT or TCIF_PARAM or TCIF_IMAGE;
TCI.lParam := PtrUInt(APage);
TCI.iImage := ATabControl.GetImageIndex(I);
{$ifdef WindowsUnicodeSupport}
if UnicodeEnabledOS then
begin
TCI.pszText := PChar(PWideChar(UTF8ToUTF16(APage.Caption)));
@ -498,10 +478,6 @@ begin
TCI.pszText := PChar(Utf8ToAnsi(APage.Caption));
Windows.SendMessage(WinHandle, TCM_INSERTITEM, RealIndex, LPARAM(@TCI));
end;
{$else}
TCI.pszText := PChar(APage.Caption);
Windows.SendMessage(WinHandle, TCM_INSERTITEM, RealIndex, LPARAM(@TCI));
{$endif}
end;
Inc(RealIndex);
end;

View File

@ -1041,12 +1041,9 @@ end;
function GetControlText(AHandle: HWND): string;
var
TextLen: dword;
{$ifdef WindowsUnicodeSupport}
AnsiBuffer: string;
WideBuffer: WideString;
{$endif}
begin
{$ifdef WindowsUnicodeSupport}
if UnicodeEnabledOS then
begin
TextLen := Windows.GetWindowTextLengthW(AHandle);
@ -1065,13 +1062,6 @@ begin
SetLength(AnsiBuffer, TextLen);
Result := AnsiToUtf8(AnsiBuffer);
end;
{$else}
TextLen := GetWindowTextLength(AHandle);
SetLength(Result, TextLen);
GetWindowText(AHandle, PChar(Result), TextLen + 1);
{$endif}
end;
procedure FillRawImageDescriptionColors(var ADesc: TRawImageDescription);
@ -1663,10 +1653,7 @@ begin
DefaultWindowInfo.DrawItemIndex := -1;
WindowInfoAtom := Windows.GlobalAddAtom('WindowInfo');
ChangedMenus := TFPList.Create;
{$ifdef WindowsUnicodeSupport}
UnicodeEnabledOS := (Win32Platform = VER_PLATFORM_WIN32_NT);
{$endif}
if WindowsVersion = wvUnknown then
UpdateWindowsVersion;
end;

View File

@ -487,21 +487,15 @@ end;
procedure TWin32ThemeServices.DrawText(DC: HDC; Details: TThemedElementDetails;
const S: String; R: TRect; Flags, Flags2: Cardinal);
{$IFDEF WindowsUnicodeSupport}
var
w: widestring;
{$ENDIF}
begin
if ThemesEnabled then
with Details do
{$IFDEF WindowsUnicodeSupport}
begin
w := UTF8ToUTF16(S);
DrawThemeText(Theme[Element], DC, Part, State, PWideChar(w), Length(w), Flags, Flags2, R);
end
{$ELSE}
DrawThemeText(Theme[Element], DC, Part, State, PWideChar(WideString(S)), Length(S), Flags, Flags2, R)
{$ENDIF}
else
inherited;
end;
@ -547,21 +541,15 @@ end;
procedure TWin32ThemeServices.DrawTextEx(DC: HDC;
Details: TThemedElementDetails; const S: String; R: TRect; Flags: Cardinal;
Options: PDTTOpts);
{$IFDEF WindowsUnicodeSupport}
var
w: widestring;
{$ENDIF}
begin
if ThemesEnabled and (DrawThemeTextEx <> nil) then
with Details do
{$IFDEF WindowsUnicodeSupport}
begin
w := UTF8ToUTF16(S);
DrawThemeTextEx(Theme[Element], DC, Part, State, PWideChar(w), Length(w), Flags, @R, Options);
end
{$ELSE}
DrawThemeTextEx(Theme[Element], DC, Part, State, PWideChar(WideString(S)), Length(S), Flags, @R, Options)
{$ENDIF}
else
DrawText(DC, Details, S, R, Flags, 0);
end;

View File

@ -156,13 +156,10 @@ end;
class function TWin32WSCustomTrayIcon.AddIcon(ATrayIcon: TCustomTrayIcon): Boolean;
var
tnida: TNotifyIconDataA;
{$ifdef WindowsUnicodeSupport}
tnidw: TNotifyIconDataW2;
AnsiBuffer: ansistring;
WideBuffer: widestring;
{$endif}
begin
{$ifdef WindowsUnicodeSupport}
if UnicodeEnabledOS then
begin
// Fill TNotifyIconDataW
@ -204,22 +201,6 @@ begin
Result := Shell_NotifyIconA(NIM_ADD, @tnida);
end;
{$else}
// Fill TNotifyIconDataA
FillChar(tnida, SizeOf(tnida), 0);
tnida.cbSize := SizeOf(TNotifyIconDataA);
tnida.hWnd := ATrayIcon.Handle;
tnida.uID := uIDTrayIcon;
tnida.uFlags := NIF_MESSAGE or NIF_ICON;
if (ATrayIcon.Hint <> '') then tnida.uFlags := tnida.uFlags or NIF_TIP;
tnida.uCallbackMessage := WM_USER + uIDTrayIcon;
tnida.hIcon := ATrayIcon.Icon.Handle;
StrLCopy(@tnida.szTip, PChar(ATrayIcon.Hint), 127);
// Create Taskbar icon
Result := Shell_NotifyIconA(NIM_ADD, @tnida);
{$endif}
end;
{*******************************************************************
@ -308,13 +289,10 @@ end;
class procedure TWin32WSCustomTrayIcon.InternalUpdate(const ATrayIcon: TCustomTrayIcon);
var
tnida: TNotifyIconDataA;
{$ifdef WindowsUnicodeSupport}
tnidw: TNotifyIconDataW2;
AnsiBuffer: ansistring;
WideBuffer: widestring;
{$endif}
begin
{$ifdef WindowsUnicodeSupport}
if UnicodeEnabledOS then
begin
// Fill TNotifyIconDataW
@ -351,19 +329,6 @@ begin
Shell_NotifyIconA(NIM_MODIFY, @tnida);
end;
{$else}
// Fill TNotifyIconDataA
FillChar(tnida, SizeOf(tnida), 0);
tnida.cbSize := SizeOf(TNotifyIconDataA);
tnida.hWnd := ATrayIcon.Handle;
tnida.uID := uIDTrayIcon;
tnida.uFlags := NIF_TIP;
StrLCopy(@tnida.szTip, PChar(ATrayIcon.Hint), 127);
// Create Taskbar icon
Shell_NotifyIconA(NIM_MODIFY, @tnida);
{$endif}
end;
{*******************************************************************

View File

@ -356,11 +356,9 @@ var
DbgFormatID: integer;
{$ENDIF}
Bitmap: TBitmap;
{$IFDEF WindowsUnicodeSupport}
BufferStream: TMemoryStream;
BufferWideString: widestring;
BufferString: ansistring;
{$ENDIF}
function ReadClipboardToStream(DestStream: TStream): Boolean;
begin
@ -413,7 +411,6 @@ begin
Bitmap.Free;
Result := true;
end;
{$IFDEF WindowsUnicodeSupport}
{ In the case of unicode text, it's necessary to
convert it from UTF-16 to UTF-8 }
Windows.CF_UNICODETEXT, Windows.CF_TEXT:
@ -451,7 +448,6 @@ begin
BufferStream.Free;
end;
end
{$ENDIF}
else
Result := ReadClipboardToStream(Stream)
end;
@ -551,10 +547,8 @@ function TWin32WidgetSet.ClipboardGetOwnerShip(ClipboardType: TClipboardType;
var
DataStream, BufferStream: TStream;
Bitmap: TBitmap;
{$IFDEF WindowsUnicodeSupport}
BufferWideString: widestring;
BufferString: ansistring;
{$ENDIF}
ScreenDC, MemDC: HDC;
OldBitmap, NewBitmap, Mask: HBitmap;
begin
@ -593,7 +587,6 @@ function TWin32WidgetSet.ClipboardGetOwnerShip(ClipboardType: TClipboardType;
Bitmap.Free;
end;
end;
{$IFDEF WindowsUnicodeSupport}
Windows.CF_UNICODETEXT, Windows.CF_TEXT:
// CF_UNICODETEXT is used by UnicodeEnabledOS, CF_TEXT by others
// we need to convert it from UTF8 to UTF16 or Ansi
@ -617,9 +610,6 @@ function TWin32WidgetSet.ClipboardGetOwnerShip(ClipboardType: TClipboardType;
end;
WriteStreamToClipBoard(FormatID, BufferStream);
end
{$ELSE}
// no clipboard support without unicode anymore
{$ENDIF}
else
begin
WriteStreamToClipBoard(FormatID, DataStream);
@ -704,13 +694,9 @@ function TWin32WidgetSet.ClipboardRegisterFormat(const AMimeType: String
): TClipboardFormat;
begin
if AMimeType=PredefinedClipboardMimeTypes[pcfText] then
{$IFDEF WindowsUnicodeSupport}
if UnicodeEnabledOS
then Result := Windows.CF_UNICODETEXT
else Result := Windows.CF_TEXT
{$ELSE}
Result := Windows.CF_TEXT
{$ENDIF}
else if (AMimeType=PredefinedClipboardMimeTypes[pcfBitmap]) then
Result := Windows.CF_BITMAP
else
@ -845,12 +831,8 @@ end;
------------------------------------------------------------------------------}
function TWin32WidgetSet.CreateFontIndirect(const LogFont: TLogFont): HFONT;
var
{$ifdef WindowsUnicodeSupport}
TempLogFontW: TLogFontW;
TempLogFont: TLogFontA absolute TempLogFontW;
{$else}
TempLogFont: TLogFont;
{$endif}
FontName: String;
begin
FontName := LogFont.lfFaceName;
@ -858,34 +840,24 @@ begin
TempLogFont := LogFont;
if FontName = DefFontData.Name then
begin
{$ifdef WindowsUnicodeSupport}
if UnicodeEnabledOS then
TempLogFontW.lfFaceName := UTF8ToUTF16(FMetrics.lfMessageFont.lfFaceName) // FMetrics must be UTF16
else
Move(FMetrics.lfMessageFont.lfFaceName, TempLogFont.lfFaceName, LF_FACESIZE);
{$else}
Move(FMetrics.lfMessageFont.lfFaceName, TempLogFont.lfFaceName, LF_FACESIZE);
{$endif}
if TempLogFont.lfHeight = 0 then
TempLogFont.lfHeight := FMetrics.lfMessageFont.lfHeight;
end
else
begin
{$ifdef WindowsUnicodeSupport}
if UnicodeEnabledOS then
TempLogFontW.lfFaceName := UTF8ToUTF16(FontName)
else
TempLogFont.lfFaceName := Utf8ToAnsi(FontName);
{$endif}
end;
{$ifdef WindowsUnicodeSupport}
if UnicodeEnabledOS then
Result := Windows.CreateFontIndirectW(@TempLogFontW)
else
Result := Windows.CreateFontIndirectA(@TempLogFont)
{$else}
Result := Windows.CreateFontIndirect(@TempLogFont);
{$endif}
end;
{------------------------------------------------------------------------------
@ -1127,7 +1099,6 @@ end;
------------------------------------------------------------------------------}
function TWin32WidgetSet.DrawText(DC: HDC; Str: PChar; Count: Integer; var Rect: TRect; Flags: Cardinal): Integer;
{$ifdef WindowsUnicodeSupport}
var
s: AnsiString;
w: WideString;
@ -1136,9 +1107,7 @@ var
aABC: ABC;
paABC: LPABC;
len: Integer;
{$endif}
begin
{$ifdef WindowsUnicodeSupport}
// use temp buffer, if count is set, there might be no null terminator
if count = -1 then
s := str
@ -1193,9 +1162,6 @@ begin
end;
end;
{$else}
Result := Windows.DrawText(DC, Str, Count, @Rect, Flags);
{$endif}
end;
{------------------------------------------------------------------------------
@ -1285,7 +1251,6 @@ begin
Windows.FontEnumProc(EnumFontFamProc), LParam);
end;
{$ifdef WindowsUnicodeSupport}
type
TProcRedirRec = record
LParam: LParam;
@ -1322,19 +1287,15 @@ begin
Result := Rec^.CallBack(ALogFont, Metric, FontType, Rec^.LParam);
end;
{$endif}
function TWin32WidgetSet.EnumFontFamiliesEx(DC: HDC; lpLogFont: PLogFont;
Callback: FontEnumExProc; LParam: Lparam; flags: dword): longint;
{$ifdef WindowsUnicodeSupport}
var
FontName: String;
LFW: LogFontW;
LFA: LogFontA absolute LFW;
Rec: TProcRedirRec;
{$endif}
begin
{$ifdef WindowsUnicodeSupport}
FontName := lpLogFont^.lfFaceName;
ZeroMemory(@LFW, SizeOf(LFW));
LFW.lfCharSet := lpLogFont^.lfCharSet;
@ -1353,11 +1314,6 @@ begin
Result := LongInt(Windows.EnumFontFamiliesExA(DC,
LFA, windows.FontEnumExProc(@EnumExProcRedirA), Windows.LParam(@Rec), Flags));
end;
{$else}
Result := Windows.EnumFontFamiliesEx(DC,
windows.LPLOGFONT(lpLogFont),
windows.FontEnumExProc(Callback), LParam, Flags);
{$endif}
end;
{------------------------------------------------------------------------------
@ -1421,13 +1377,10 @@ end;
------------------------------------------------------------------------------}
function TWin32WidgetSet.ExtTextOut(DC: HDC; X, Y: Integer; Options: LongInt;
Rect: PRect; Str: PChar; Count: LongInt; Dx: PInteger): Boolean;
{$ifdef WindowsUnicodeSupport}
var
s: AnsiString;
w: WideString;
{$ENDIF}
begin
{$ifdef WindowsUnicodeSupport}
// use temp buffer, if count is set, there might be no null terminator
if count = -1 then
s := str
@ -1449,9 +1402,6 @@ begin
S := Utf8ToAnsi(S);
Result := Windows.ExtTextOut(DC, X, Y, Options, LPRECT(Rect), PChar(S), Length(S), Dx);
end;
{$else}
Result := Windows.ExtTextOut(DC, X, Y, Options, LPRECT(Rect), Str, Count, Dx);
{$endif}
end;
{------------------------------------------------------------------------------
@ -1928,12 +1878,9 @@ begin
end;
function TWin32WidgetSet.GetMonitorInfo(hMonitor: HMONITOR; lpmi: LCLType.PMonitorInfo): Boolean;
{$IFDEF WindowsUnicodeSupport}
var
LocalInfo: TMonitorInfoExW;
{$ENDIF}
begin
{$IFDEF WindowsUnicodeSupport}
if (lpmi <> nil) and (lpmi^.cbSize >= SizeOf(TMonitorInfoEx)) then
begin
if UnicodeEnabledOS then
@ -1951,7 +1898,6 @@ begin
end;
end
else
{$ENDIF}
Result := MultiMon.GetMonitorInfo(hMonitor, LPMonitorInfo(lpmi));
end;
@ -1965,13 +1911,10 @@ end;
Gets information about a specified graphics object.
------------------------------------------------------------------------------}
function TWin32WidgetSet.GetObject(GDIObj: HGDIOBJ; BufSize: Integer; Buf: Pointer): Integer;
{$ifdef WindowsUnicodeSupport}
var
LF: PLogFontA absolute Buf;
LFW: TLogFontW;
{$endif}
begin
{$ifdef WindowsUnicodeSupport}
if GetObjectType(GDIObj) = OBJ_FONT then
begin
if (UnicodeEnabledOS) and (BufSize = Sizeof(LOGFONTA)) then
@ -1989,7 +1932,6 @@ begin
end;
end
else
{$endif}
Result := Windows.GetObject(GDIObj, BufSize, Buf);
end;
@ -2181,13 +2123,10 @@ end;
Computes the width and height of the specified string of text.
------------------------------------------------------------------------------}
function TWin32WidgetSet.GetTextExtentPoint(DC: HDC; Str: PChar; Count: Integer; var Size: TSize): Boolean;
{$ifdef WindowsUnicodeSupport}
var
s: AnsiString;
w: WideString;
{$ENDIF}
begin
{$ifdef WindowsUnicodeSupport}
// use temp buffer, if count is set, there might be no null terminator
if count = -1 then
s := str
@ -2210,9 +2149,6 @@ begin
s := Utf8ToAnsi(s);
Result := Windows.GetTextExtentPoint32(DC, pchar(s), length(s), @Size);
end;
{$else}
Result := Windows.GetTextExtentPoint32(DC, Str, Count, @Size);
{$endif}
end;
{------------------------------------------------------------------------------
@ -2636,20 +2572,14 @@ end;
and includes buttons.
------------------------------------------------------------------------------}
function TWin32WidgetSet.MessageBox(HWnd: HWND; LPText, LPCaption: PChar; UType: Cardinal): Integer;
{$ifdef WindowsUnicodeSupport}
var
WideLPText, WideLPCaption: widestring;
{$endif}
begin
{$ifdef WindowsUnicodeSupport}
WideLPText := UTF8ToUTF16(string(LPText));
WideLPCaption := UTF8ToUTF16(string(LPCaption));
Result := Windows.MessageBoxW(HWnd, PWideChar(WideLPText),
PWideChar(WideLPCaption), UType);
{$else}
Result := Windows.MessageBox(HWnd, LPText, LPCaption, UType);
{$endif}
end;
function TWin32WidgetSet.MonitorFromPoint(ptScreenCoords: TPoint; dwFlags: DWord): HMONITOR;
@ -2714,14 +2644,10 @@ end;
function TWin32WidgetSet.PeekMessage(var LPMsg: TMsg; Handle: HWND;
WMsgFilterMin, WMsgFilterMax, WRemoveMsg: UINT): Boolean;
begin
{$IFDEF WindowsUnicodeSupport}
if UnicodeEnabledOS then
Result := Boolean(Windows.PeekMessageW(@LPMsg, Handle, WMsgFilterMin, WMsgFilterMax, WRemoveMsg))
else
Result := Boolean(Windows.PeekMessage(@LPMsg, Handle, WMsgFilterMin, WMsgFilterMax, WRemoveMsg));
{$ELSE}
Result := Boolean(Windows.PeekMessage(@LPMsg, Handle, WMsgFilterMin, WMsgFilterMax, WRemoveMsg));
{$ENDIF}
end;
function TWin32WidgetSet.Pie(DC: HDC; EllipseX1, EllipseY1, EllipseX2,
@ -3762,17 +3688,11 @@ end;
selected font.
------------------------------------------------------------------------------}
function TWin32WidgetSet.TextOut(DC: HDC; X, Y: Integer; Str: PChar; Count: Integer): Boolean;
{$ifdef WindowsUnicodeSupport}
var
ws: widestring;
{$endif}
begin
{$ifdef WindowsUnicodeSupport}
ws := UTF8ToUTF16(copy(str,1,Count));
Result := Boolean(Windows.TextOutW(DC, X, Y, PWideChar(ws), length(ws)));
{$else}
Result := Boolean(Windows.TextOut(DC, X, Y, Str, Count));
{$endif}
end;
function TWin32WidgetSet.UpdateWindow(Handle: HWND): Boolean;

View File

@ -133,10 +133,8 @@ var
BitmapRect: Windows.RECT;
ButtonImageList: BUTTON_IMAGELIST;
I: integer;
{$IFDEF WindowsUnicodeSupport}
ButtonCaptionA: string;
ButtonCaptionW: widestring;
{$ENDIF}
procedure DrawBitmap(AState: TButtonState; UseThemes, AlphaDraw: Boolean);
const
@ -253,7 +251,6 @@ var
SetBkMode(TmpDC, TRANSPARENT);
if BitBtn.UseRightToLeftReading then
SetTextAlign(TmpDC, OldTextAlign or TA_RTLREADING);
{$IFDEF WindowsUnicodeSupport}
if UnicodeEnabledOS then
begin
ButtonCaptionW := UTF8ToUTF16(ButtonCaption);
@ -263,9 +260,6 @@ var
ButtonCaptionA := Utf8ToAnsi(ButtonCaption);
DrawState(TmpDC, 0, nil, LPARAM(ButtonCaptionA), 0, XDestText, YDestText, 0, 0, TextFlags);
end;
{$ELSE}
DrawState(TmpDC, 0, nil, LPARAM(ButtonCaption), 0, XDestText, YDestText, 0, 0, TextFlags);
{$ENDIF}
end
else
begin

View File

@ -184,10 +184,8 @@ class procedure TWin32WSCustomCheckListBox.DefaultWndHandler(
OldColor: COLORREF;
OldBkMode: Integer;
sz: TSize;
{$ifdef WindowsUnicodeSupport}
AnsiBuffer: string;
WideBuffer: widestring;
{$endif}
begin
Selected := (Data^.itemState and ODS_SELECTED) > 0;
Enabled := CheckListBox.Enabled and CheckListBox.ItemEnabled[Data^.itemID];
@ -243,7 +241,6 @@ class procedure TWin32WSCustomCheckListBox.DefaultWndHandler(
OldColor := TColorRef(CheckListBox.GetDefaultColor(dctFont));
OldColor := Windows.SetTextColor(Data^._HDC, ColorToRGB(TColor(OldColor)));
end;
{$ifdef WindowsUnicodeSupport}
if UnicodeEnabledOS then
begin
WideBuffer := UTF8ToUTF16(CheckListBox.Items[Data^.ItemID]);
@ -256,10 +253,6 @@ class procedure TWin32WSCustomCheckListBox.DefaultWndHandler(
Windows.DrawText(Data^._HDC, PChar(AnsiBuffer), -1,
TextRect, TextFlags);
end;
{$else}
Windows.DrawText(Data^._HDC, PChar(CheckListBox.Items[Data^.ItemID]), -1,
TextRect, TextFlags);
{$endif}
// restore old colors
Windows.SetTextColor(Data^._HDC, OldColor);
Windows.SetBkMode(Data^._HDC, OldBkMode);

View File

@ -294,7 +294,6 @@ var
begin
Flags := WS_CHILD or WS_CLIPSIBLINGS or WS_CLIPCHILDREN;
Parent := TWin32WidgetSet(WidgetSet).AppHandle;
{$ifdef WindowsUnicodeSupport}
if UnicodeEnabledOS then
PreferredSizeStatusBar := CreateWindowExW(0, STATUSCLASSNAMEW,
nil, Flags,
@ -302,10 +301,6 @@ begin
else
PreferredSizeStatusBar := CreateWindowEx(0, STATUSCLASSNAME, nil,
Flags, 0, 0, 0, 0, Parent,0 , HInstance, nil);
{$else}
PreferredSizeStatusBar := CreateWindowEx(0, STATUSCLASSNAME, nil,
Flags, 0, 0, 0, 0, Parent, 0, HInstance, nil);
{$endif}
GetWindowRect(PreferredSizeStatusBar, R);
PreferredStatusBarHeight := R.Bottom - R.Top;
DestroyWindow(PreferredSizeStatusBar);
@ -348,14 +343,10 @@ begin
else
WParam := WParam or StatusPanel.Index;
if StatusPanel.StatusBar.UseRightToLeftReading then WParam := WParam or SBT_RTLREADING;
{$ifdef WindowsUnicodeSupport}
if UnicodeEnabledOS then
Windows.SendMessageW(StatusPanel.StatusBar.Handle, SB_SETTEXTW, WParam, LPARAM(PWideChar(UTF8ToUTF16(Text))))
else
Windows.SendMessage(StatusPanel.StatusBar.Handle, SB_SETTEXT, WParam, LPARAM(PChar(Utf8ToAnsi(Text))));
{$else}
Windows.SendMessage(StatusPanel.StatusBar.Handle, SB_SETTEXT, WParam, LPARAM(PChar(Text)));
{$endif}
end;
procedure UpdateStatusBarPanelWidths(const StatusBar: TStatusBar);
@ -558,14 +549,10 @@ begin
WParam := SB_SIMPLEID or SBT_RTLREADING
else
WParam := SB_SIMPLEID;
{$ifdef WindowsUnicodeSupport}
if UnicodeEnabledOS then
Windows.SendMessageW(AStatusBar.Handle, SB_SETTEXTW, WParam, LPARAM(PWideChar(UTF8ToUTF16(AStatusBar.SimpleText))))
else
Windows.SendMessage(AStatusBar.Handle, SB_SETTEXT, WParam, LPARAM(PChar(Utf8ToAnsi(AStatusBar.SimpleText))))
{$else}
Windows.SendMessage(AStatusBar.Handle, SB_SETTEXT, WParam, LPARAM(PChar(AStatusBar.SimpleText)))
{$endif}
end
else
UpdateStatusBarPanel(AStatusBar.Panels[PanelIndex]);

View File

@ -177,9 +177,7 @@ var
AErrorCode: Cardinal;
NCCreateParams: TNCCreateParams;
WindowClass, DummyClass: WndClass;
{$ifdef WindowsUnicodeSupport}
WindowClassW, DummyClassW: WndClassW;
{$endif}
begin
NCCreateParams.DefWndProc := nil;
NCCreateParams.WinControl := AWinControl;
@ -191,7 +189,6 @@ begin
begin
if SubClass then
begin
{$ifdef WindowsUnicodeSupport}
if UnicodeEnabledOS then
begin
if GetClassInfoW(System.HInstance, PWideChar(WideString(pClassName)), @WindowClassW) then
@ -211,7 +208,6 @@ begin
end;
end
else
{$endif}
begin
if GetClassInfo(System.HInstance, pClassName, @WindowClass) then
begin
@ -231,7 +227,6 @@ begin
end;
end;
{$ifdef WindowsUnicodeSupport}
if UnicodeEnabledOS then
Window := CreateWindowExW(FlagsEx, PWideChar(WideString(pClassName)),
PWideChar(UTF8ToUTF16(WindowTitle)), Flags,
@ -240,11 +235,6 @@ begin
Window := CreateWindowEx(FlagsEx, pClassName,
PChar(Utf8ToAnsi(WindowTitle)), Flags,
Left, Top, Width, Height, Parent, 0, HInstance, @NCCreateParams);
{$else}
Window := CreateWindowEx(FlagsEx, pClassName,
PChar(WindowTitle), Flags,
Left, Top, Width, Height, Parent, 0, HInstance, @NCCreateParams);
{$endif}
if Window = 0 then
begin
@ -504,14 +494,10 @@ end;
class procedure TWin32WSWinControl.SetText(const AWinControl: TWinControl; const AText: string);
begin
if not WSCheckHandleAllocated(AWincontrol, 'SetText') then Exit;
{$ifdef WindowsUnicodeSupport}
if UnicodeEnabledOS then
SendMessageW(AWinControl.Handle, WM_SETTEXT, 0, LPARAM(PWideChar(UTF8ToUTF16(AText))))
else
SendMessage(AWinControl.Handle, WM_SETTEXT, 0, LPARAM(PChar(Utf8ToAnsi(AText))));
{$else}
SendMessage(AWinControl.Handle, WM_SETTEXT, 0, LPARAM(PChar(AText)));
{$endif}
end;
class procedure TWin32WSWinControl.SetCursor(const AWinControl: TWinControl; const ACursor: HCursor);

View File

@ -309,21 +309,16 @@ begin
lvc.Mask := LVCF_TEXT;
{$ifdef WindowsUnicodeSupport}
if UnicodeEnabledOS then
begin
lvc.pszText := PChar(PWideChar(UTF8ToUTF16(AColumn.Caption)));
SendMessage(ALV.Handle, LVM_INSERTCOLUMNW, WPARAM(AIndex), LPARAM(@lvc));
end
else
begin
lvc.pszText := PChar(Utf8ToAnsi(AColumn.Caption));
ListView_InsertColumn(ALV.Handle, AIndex, lvc);
end;
{$else}
lvc.pszText := PChar(AColumn.Caption);
if UnicodeEnabledOS then
begin
lvc.pszText := PChar(PWideChar(UTF8ToUTF16(AColumn.Caption)));
SendMessage(ALV.Handle, LVM_INSERTCOLUMNW, WPARAM(AIndex), LPARAM(@lvc));
end
else
begin
lvc.pszText := PChar(Utf8ToAnsi(AColumn.Caption));
ListView_InsertColumn(ALV.Handle, AIndex, lvc);
{$endif}
end;
end;
class procedure TWin32WSCustomListView.ColumnMove(const ALV: TCustomListView; const AOldIndex, ANewIndex: Integer; const AColumn: TListColumn);
@ -405,21 +400,16 @@ begin
lvc.Mask := LVCF_TEXT;
{$ifdef WindowsUnicodeSupport}
if UnicodeEnabledOS then
begin
lvc.pszText := PChar(PWideChar(UTF8ToUTF16(AColumn.Caption)));
SendMessage(ALV.Handle, LVM_SETCOLUMNW, WPARAM(AIndex), LPARAM(@lvc));
end
else
begin
lvc.pszText := PChar(Utf8ToAnsi(ACaption));
ListView_SetColumn(ALV.Handle, AIndex, lvc);
end;
{$else}
lvc.pszText := PChar(ACaption);
if UnicodeEnabledOS then
begin
lvc.pszText := PChar(PWideChar(UTF8ToUTF16(AColumn.Caption)));
SendMessage(ALV.Handle, LVM_SETCOLUMNW, WPARAM(AIndex), LPARAM(@lvc));
end
else
begin
lvc.pszText := PChar(Utf8ToAnsi(ACaption));
ListView_SetColumn(ALV.Handle, AIndex, lvc);
{$endif}
end;
end;
class procedure TWin32WSCustomListView.ColumnSetImage(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn; const AImageIndex: Integer);
@ -633,21 +623,16 @@ begin
lvi.iSubItem := 0;
lvi.lParam := LPARAM(AItem);
{$ifdef WindowsUnicodeSupport}
if UnicodeEnabledOS then
begin
lvi.pszText := PChar(PWideChar(UTF8ToUTF16(AItem.Caption)));
SendMessage(ALV.Handle, LVM_INSERTITEMW, 0, LPARAM(@lvi));
end
else
begin
lvi.pszText := PChar(Utf8ToAnsi(AItem.Caption));
ListView_InsertItem(ALV.Handle, lvi);
end;
{$else}
lvi.pszText := PChar(AItem.Caption);
if UnicodeEnabledOS then
begin
lvi.pszText := PChar(PWideChar(UTF8ToUTF16(AItem.Caption)));
SendMessage(ALV.Handle, LVM_INSERTITEMW, 0, LPARAM(@lvi));
end
else
begin
lvi.pszText := PChar(Utf8ToAnsi(AItem.Caption));
ListView_InsertItem(ALV.Handle, lvi);
{$endif}
end;
end;
class procedure TWin32WSCustomListView.ItemSetChecked(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem; const AChecked: Boolean);
@ -709,15 +694,12 @@ begin
end;
class procedure TWin32WSCustomListView.ItemSetText(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem; const ASubIndex: Integer; const AText: String);
{$ifdef WindowsUnicodeSupport}
var
_gnu_lvi : LV_ITEM;
{$endif}
begin
if not WSCheckHandleAllocated(ALV, 'ItemSetText')
then Exit;
{$ifdef WindowsUnicodeSupport}
if UnicodeEnabledOS then
begin
_gnu_lvi.iSubItem := ASubIndex;
@ -727,9 +709,6 @@ begin
end
else
ListView_SetItemText(ALV.Handle, AIndex, ASubIndex, PChar(Utf8ToAnsi(AText)));
{$else}
ListView_SetItemText(ALV.Handle, AIndex, ASubIndex, PChar(AText));
{$endif}
// autosize is an *exteme* performance bottleneck, even if WM_SETREDRAW
// was set to false it will ignore this and still redraw all columns.
// We will therefore postpone all autosizing until EndUpdate where we do

View File

@ -224,7 +224,6 @@ var
FolderName: string;
FileNames: string;
begin
{$ifdef WindowsUnicodeSupport}
if UnicodeEnabledOS then
begin
FolderName := UTF16ToUTF8(DialogRec^.UnicodeFolderName);
@ -253,10 +252,6 @@ var
FolderName := AnsiToUtf8(DialogRec^.AnsiFolderName);
FileNames := AnsiToUtf8(DialogRec^.AnsiFileNames);
end;
{$else}
FolderName:= DialogRec^.AnsiFolderName;
FileNames := DialogRec^.AnsiFileNames;
{$endif}
FolderName := AppendPathDelim(FolderName);
len := Length(FileNames);
if (len > 0) and (FileNames[1] = '"') then
@ -283,14 +278,10 @@ var
FolderName: string;
I,Start: integer;
begin
{$ifdef WindowsUnicodeSupport}
if UnicodeEnabledOS then
SelectedStr:=UTF16ToUTF8(widestring(PWideChar(OpenFile^.lpStrFile)))
else
SelectedStr:=AnsiToUtf8(OpenFile^.lpStrFile);
{$else}
SelectedStr:=OpenFile^.lpStrFile;
{$endif}
if not (ofAllowMultiSelect in AOpenDialog.Options) then
AFiles.Add(SelectedStr)
else begin
@ -437,7 +428,6 @@ var
DialogRec: POpenFileDialogRec;
begin
DialogRec := POpenFileDialogRec(OpenFile^.lCustData);
{$ifdef WindowsUnicodeSupport}
if UnicodeEnabledOS then
begin
FolderSize := SendMessageW(GetParent(Wnd), CDM_GETFOLDERPATH, 0, LPARAM(nil));
@ -450,7 +440,6 @@ begin
SendMessageW(GetParent(Wnd), CDM_GETSPEC, FilesSize,
LPARAM(PWideChar(DialogRec^.UnicodeFileNames)));
end else
{$endif}
begin
FolderSize := CommDlg_OpenSave_GetFolderPath(GetParent(Wnd), nil, 0);
FilesSize := CommDlg_OpenSave_GetSpec(GetParent(Wnd), nil, 0);
@ -630,11 +619,9 @@ var
OpenFile: LPOPENFILENAME;
Filter, FileName, InitialDir, DefaultExt: String;
FileNameBuffer: PChar;
{$ifdef WindowsUnicodeSupport}
FileNameWide: WideString;
FileNameWideBuffer: PWideChar;
FileNameBufferSize: Integer;
{$endif WindowsUnicodeSupport}
begin
FileName := AOpenDialog.FileName;
InitialDir := AOpenDialog.InitialDir;
@ -648,27 +635,22 @@ begin
DefaultExt := GetDefaultExt;
{$ifdef WindowsUnicodeSupport}
if UnicodeEnabledOS then
begin
FileNameWideBuffer := AllocMem(FileNameBufferLen * 2 + 2);
FileNameWide := UTF8ToUTF16(FileName);
if UnicodeEnabledOS then
begin
FileNameWideBuffer := AllocMem(FileNameBufferLen * 2 + 2);
FileNameWide := UTF8ToUTF16(FileName);
if Length(FileNameWide) > FileNameBufferLen then
FileNameBufferSize := FileNameBufferLen
else
FileNameBufferSize := Length(FileNameWide);
if Length(FileNameWide) > FileNameBufferLen then
FileNameBufferSize := FileNameBufferLen
else
FileNameBufferSize := Length(FileNameWide);
Move(PWideChar(FileNameWide)^, FileNameWideBuffer^, FileNameBufferSize * 2);
end
else begin
FileNameBuffer := AllocMem(FileNameBufferLen + 1);
StrLCopy(FileNameBuffer, PChar(UTF8ToAnsi(FileName)), FileNameBufferLen);
end;
{$else}
Move(PWideChar(FileNameWide)^, FileNameWideBuffer^, FileNameBufferSize * 2);
end
else begin
FileNameBuffer := AllocMem(FileNameBufferLen + 1);
StrLCopy(FileNameBuffer, PChar(FileName), FileNameBufferLen);
{$endif}
StrLCopy(FileNameBuffer, PChar(UTF8ToAnsi(FileName)), FileNameBufferLen);
end;
if AOpenDialog.Filter <> '' then
begin
@ -687,7 +669,6 @@ begin
nFilterIndex := AOpenDialog.FilterIndex;
{$ifdef WindowsUnicodeSupport}
if UnicodeEnabledOS then
begin
lpStrFile := PChar(FileNameWideBuffer);
@ -704,21 +685,6 @@ begin
lpstrInitialDir := UTF8StringToPAnsiChar(InitialDir);
lpstrDefExt := UTF8StringToPAnsiChar(DefaultExt);
end;
{$else}
lpStrFile := FileNameBuffer;
lpStrFilter := GetMem(Length(Filter)+1);
StrPCopy(lpStrFilter, Filter);
lpStrTitle := GetMem(Length(AOpenDialog.Title)+1);
StrPCopy(lpStrTitle, AOpenDialog.Title);
lpStrInitialDir := GetMem(Length(InitialDir)+1);
StrPCopy(lpstrInitialDir, InitialDir);
lpstrDefExt := GetMem(Length(DefaultExt)+1);
StrPCopy(lpstrDefExt, DefaultExt);
{$endif}
nMaxFile := FileNameBufferLen + 1; // Size in TCHARs
lpfnHook := Windows.LPOFNHOOKPROC(@OpenFileDialogCallBack);
@ -1036,17 +1002,12 @@ begin
else
{$endif}
begin
{$ifdef WindowsUnicodeSupport}
if UnicodeEnabledOS then
ProcessFileDialogResult(TOpenDialog(ACommonDialog),
GetOpenFileNameW(LPOPENFILENAME(ACommonDialog.Handle)))
else
ProcessFileDialogResult(TOpenDialog(ACommonDialog),
GetOpenFileName(LPOPENFILENAME(ACommonDialog.Handle)));
{$else}
if UnicodeEnabledOS then
ProcessFileDialogResult(TOpenDialog(ACommonDialog),
GetOpenFileNameW(LPOPENFILENAME(ACommonDialog.Handle)))
else
ProcessFileDialogResult(TOpenDialog(ACommonDialog),
GetOpenFileName(LPOPENFILENAME(ACommonDialog.Handle)));
{$endif}
end;
finally
SetCurrentDirUTF8(lOldWorkingDir);
@ -1127,17 +1088,12 @@ begin
else
{$endif}
begin
{$ifdef WindowsUnicodeSupport}
if UnicodeEnabledOS then
ProcessFileDialogResult(TOpenDialog(ACommonDialog),
GetSaveFileNameW(LPOPENFILENAME(ACommonDialog.Handle)))
else
ProcessFileDialogResult(TOpenDialog(ACommonDialog),
GetSaveFileName(LPOPENFILENAME(ACommonDialog.Handle)));
{$else}
if UnicodeEnabledOS then
ProcessFileDialogResult(TOpenDialog(ACommonDialog),
GetSaveFileNameW(LPOPENFILENAME(ACommonDialog.Handle)))
else
ProcessFileDialogResult(TOpenDialog(ACommonDialog),
GetSaveFileName(LPOPENFILENAME(ACommonDialog.Handle)));
{$endif}
end;
finally
SetCurrentDirUTF8(lOldWorkingDir);
@ -1172,20 +1128,14 @@ class function TWin32WSFontDialog.CreateHandle(const ACommonDialog: TCommonDialo
end;
var
{$ifdef WindowsUnicodeSupport}
CFW: TChooseFontW;
LFW: LogFontW;
CF: TChooseFontA absolute CFW;
LF: LogFontA absolute LFW;
{$else}
CF: TChooseFont;
LF: LogFont;
{$endif}
UserResult: WINBOOL;
begin
with TFontDialog(ACommonDialog) do
begin
{$ifdef WindowsUnicodeSupport}
ZeroMemory(@CFW, sizeof(TChooseFontW));
ZeroMemory(@LFW, sizeof(LogFontW));
if UnicodeEnabledOS then
@ -1236,30 +1186,6 @@ begin
end;
UserResult := ChooseFontA(@CF);
end
{$else}
ZeroMemory(@CF, sizeof(TChooseFont));
ZeroMemory(@LF, sizeof(LogFont));
with LF do
begin
LFHeight := Font.Height;
LFFaceName := TFontDataName(Font.Name);
if (fsBold in Font.Style) then LFWeight:= FW_BOLD;
LFItalic := byte(fsItalic in Font.Style);
LFStrikeOut := byte(fsStrikeOut in Font.Style);
LFUnderline := byte(fsUnderline in Font.Style);
LFCharSet := Font.CharSet;
end;
with CF do
begin
LStructSize := sizeof(TChooseFont);
HWndOwner := GetOwnerHandle(ACommonDialog);
LPLogFont := commdlg.PLOGFONT(@LF);
Flags := GetFlagsFromOptions(Options);
Flags := Flags or CF_INITTOLOGFONTSTRUCT or CF_BOTH;
RGBColors := DWORD(Font.Color);
end;
UserResult := ChooseFont(@CF);
{$endif}
end;
SetDialogResult(ACommonDialog, UserResult);
@ -1306,11 +1232,9 @@ begin
case uMsg of
BFFM_INITIALIZED:
// Setting root dir
{$ifdef WindowsUnicodeSupport}
if UnicodeEnabledOS then
SendMessageW(hwnd, BFFM_SETSELECTIONW, WPARAM(True), lpData)
else
{$endif}
SendMessage(hwnd, BFFM_SETSELECTION, WPARAM(True), lpData);
//BFFM_SELCHANGED
// : begin
@ -1327,12 +1251,10 @@ var
Buffer : PChar;
bi : TBrowseInfo;
iidl : PItemIDList;
{$ifdef WindowsUnicodeSupport}
biw : TBROWSEINFOW;
Bufferw : PWideChar absolute Buffer;
InitialDirW: widestring;
Title: widestring;
{$endif}
DirName: string;
begin
DirName := '';
@ -1349,7 +1271,6 @@ begin
if Copy(InitialDir,length(InitialDir),1)=DriveDelim then
InitialDir := InitialDir + PathDelim;
end;
{$ifdef WindowsUnicodeSupport}
if UnicodeEnabledOS then
begin
Buffer := CoTaskMemAlloc(MAX_PATH*2);
@ -1404,31 +1325,6 @@ begin
DirName := AnsiToUtf8(Buffer);
end;
end;
{$else}
Buffer := CoTaskMemAlloc(MAX_PATH);
with bi do
begin
hwndOwner := GetOwnerHandle(ACommonDialog);
pidlRoot := nil;
pszDisplayName := Buffer;
lpszTitle := PChar(ACommonDialog.Title);
ulFlags := BIF_RETURNONLYFSDIRS;
if not (ofOldStyleDialog in Options) then
ulFlags := ulFlags + BIF_NEWDIALOGSTYLE;
lpfn := @BrowseForFolderCallback;
// this value will be passed to callback proc as lpData
lParam := LclType.LParam(PChar(InitialDir));
end;
iidl := SHBrowseForFolder(@bi);
if Assigned(iidl) then
begin
SHGetPathFromIDList(iidl, Buffer);
CoTaskMemFree(iidl);
DirName := Buffer;
end;
{$endif}
if Assigned(iidl) then
begin

View File

@ -143,14 +143,12 @@ begin
not (ofOldStyleDialog in TPreviewFileDialog(ACommonDialog).Options) then
with OFN^ do
begin
{$ifdef WindowsUnicodeSupport}
if UnicodeEnabledOS then
begin
lpTemplateName := AllocMem(Length(ResName) * 2 + 2);
Move(PChar(ResName)^, lpTemplateName^, Length(ResName) * 2);
end
else
{$endif}
begin
lpTemplateName := AllocMem(Length(ResName) + 1);
Move(PChar(AnsiString(ResName))^, lpTemplateName^, Length(ResName));

View File

@ -52,7 +52,6 @@ var
WChar: WPARAM;
begin
WChar:=WPARAM(Ord(Ch[1]));
{$ifdef WindowsUnicodeSupport}
if UnicodeEnabledOS then begin
if Length(Ch)>1 then begin
S := UTF8ToUTF16(Ch);
@ -63,7 +62,6 @@ begin
exit;
end else
WChar := WPARAM(Ord(UTF8ToAnsi(Ch)[1]));
{$endif}
PostMessage(AEditor.Handle, WM_CHAR, WChar, 0);
end;

View File

@ -172,7 +172,6 @@ begin
else
ItemInfo.cbSize := sizeof(TMenuItemInfo);
ItemInfo.fMask := MIIM_DATA;
{$ifdef WindowsUnicodeSupport}
if UnicodeEnabledOS then
begin
if not GetMenuItemInfoW(AMenuHandle, 0, true, @ItemInfo) then Exit;
@ -181,9 +180,6 @@ begin
begin
if not GetMenuItemInfoA(AMenuHandle, 0, true, @ItemInfo) then Exit;
end;
{$else}
if not GetMenuItemInfo(AMenuHandle, 0, true, @ItemInfo) then Exit;
{$endif}
FirstMenuItem := TMenuItem(ItemInfo.dwItemData);
if FirstMenuItem = nil then exit;
i := 0;
@ -250,13 +246,10 @@ end;
function StringSize(const aCaption: String; const aHDC: HDC): TSize;
var
tmpRect: Windows.RECT;
{$ifdef WindowsUnicodeSupport}
AnsiBuffer: ansistring;
WideBuffer: widestring;
{$endif WindowsUnicodeSupport}
begin
FillChar(tmpRect, SizeOf(tmpRect), 0);
{$ifdef WindowsUnicodeSupport}
if UnicodeEnabledOS then
begin
WideBuffer := UTF8ToUTF16(aCaption);
@ -267,9 +260,6 @@ begin
AnsiBuffer := Utf8ToAnsi(aCaption);
DrawText(aHDC, pChar(AnsiBuffer), length(AnsiBuffer), @TmpRect, DT_CALCRECT);
end;
{$else}
DrawText(aHDC, pChar(aCaption), length(aCaption), @TmpRect, DT_CALCRECT);
{$endif}
Result.cx := TmpRect.right - TmpRect.left;
Result.cy := TmpRect.Bottom - TmpRect.Top;
end;
@ -997,10 +987,8 @@ var
IsRightToLeft: Boolean;
etoFlags: Cardinal;
dtFlags: DWord;
{$ifdef WindowsUnicodeSupport}
AnsiBuffer: ansistring;
WideBuffer: widestring;
{$endif WindowsUnicodeSupport}
LeftSpace, RightSpace: Integer;
begin
crText := TextColorMenu(ItemState, AMenuItem.IsInMenuBar, AMenuItem.Enabled);
@ -1056,7 +1044,6 @@ begin
oldBkMode := SetBkMode(AHDC, TRANSPARENT);
{$ifdef WindowsUnicodeSupport}
if UnicodeEnabledOS then
begin
WideBuffer := UTF8ToUTF16(AMenuItem.Caption);
@ -1067,9 +1054,6 @@ begin
AnsiBuffer := Utf8ToAnsi(AMenuItem.Caption);
DrawText(AHDC, PChar(AnsiBuffer), Length(AnsiBuffer), @ARect, dtFlags);
end;
{$else}
DrawText(AHDC, PChar(AMenuItem.Caption), Length(AMenuItem.Caption), @ARect, dtFlags);
{$endif}
if AMenuItem.ShortCut <> scNone then
begin
@ -1080,20 +1064,16 @@ begin
else
dtFlags := dtFlags or DT_RIGHT;
{$ifdef WindowsUnicodeSupport}
if UnicodeEnabledOS then
begin
WideBuffer := UTF8ToUTF16(shortCutText);
DrawTextW(AHDC, PWideChar(WideBuffer), Length(WideBuffer), @ARect, dtFlags);
end
else
begin
AnsiBuffer := Utf8ToAnsi(shortCutText);
DrawText(AHDC, PChar(AnsiBuffer), Length(AnsiBuffer), @ARect, dtFlags);
end;
{$else}
DrawText(AHDC, PChar(shortCutText), Length(shortCutText), @ARect, dtFlags);
{$endif}
if UnicodeEnabledOS then
begin
WideBuffer := UTF8ToUTF16(shortCutText);
DrawTextW(AHDC, PWideChar(WideBuffer), Length(WideBuffer), @ARect, dtFlags);
end
else
begin
AnsiBuffer := Utf8ToAnsi(shortCutText);
DrawText(AHDC, PChar(AnsiBuffer), Length(AnsiBuffer), @ARect, dtFlags);
end;
end;
SetBkMode(AHDC, oldBkMode);
@ -1262,28 +1242,20 @@ begin
MenuInfo.cbSize := sizeof(TMenuItemInfo);
MenuInfo.fMask := MIIM_FTYPE; // don't retrieve caption (MIIM_STRING not included)
end;
{$ifdef WindowsUnicodeSupport}
if UnicodeEnabledOS then
GetMenuItemInfoW(AMenuItem.Parent.Handle, AMenuItem.Command, False, @MenuInfo)
else
GetMenuItemInfoA(AMenuItem.Parent.Handle, AMenuItem.Command, False, @MenuInfo);
{$else}
GetMenuItemInfo(AMenuItem.Parent.Handle, AMenuItem.Command, False, @MenuInfo);
{$endif}
if Value then
MenuInfo.fType := MenuInfo.fType or Flag
else
MenuInfo.fType := MenuInfo.fType and (not Flag);
if OldMenuWin95 then // MIIM_TYPE = MIIM_FTYPE + MIIM_STRING for Windows 95
MenuInfo.dwTypeData := PChar(UTF8ToAnsi(CompleteMenuItemCaption(AMenuItem, #9))); // Windows 95 only Ansi
{$ifdef WindowsUnicodeSupport}
if UnicodeEnabledOS then
Result := SetMenuItemInfoW(AMenuItem.Parent.Handle, AMenuItem.Command, False, @MenuInfo)
else
Result := SetMenuItemInfoA(AMenuItem.Parent.Handle, AMenuItem.Command, False, @MenuInfo);
{$else}
Result := SetMenuItemInfo(AMenuItem.Parent.Handle, AMenuItem.Command, False, @MenuInfo);
{$endif}
TriggerFormUpdate(AMenuItem);
end;
@ -1304,26 +1276,18 @@ begin
else
MenuInfo.cbSize := sizeof(TMenuItemInfo);
MenuInfo.fMask := MIIM_TYPE; //MIIM_FTYPE not work here please use only MIIM_TYPE, caption not retrieved (dwTypeData = nil)
{$ifdef WindowsUnicodeSupport}
if UnicodeEnabledOS then
GetMenuItemInfoW(Menu, 0, True, @MenuInfo)
else
GetMenuItemInfoA(Menu, 0, True, @MenuInfo);
{$else}
GetMenuItemInfo(Menu, 0, True, @MenuInfo);
{$endif}
if Value then
MenuInfo.fType := MenuInfo.fType or Flag
else
MenuInfo.fType := MenuInfo.fType and not Flag;
{$ifdef WindowsUnicodeSupport}
if UnicodeEnabledOS then
SetMenuItemInfoW(Menu, 0, True, @MenuInfo)
else
SetMenuItemInfoA(Menu, 0, True, @MenuInfo);
{$else}
SetMenuItemInfo(Menu, 0, True, @MenuInfo);
{$endif}
end;
{ TWin32WSMenuItem }
@ -1331,10 +1295,8 @@ end;
procedure UpdateCaption(const AMenuItem: TMenuItem; ACaption: String);
var
MenuInfo: MENUITEMINFO; // TMenuItemInfoA and TMenuItemInfoW have same size and same structure type
{$ifdef WindowsUnicodeSupport}
AnsiBuffer: ansistring;
WideBuffer: widestring;
{$endif WindowsUnicodeSupport}
begin
if (AMenuItem.Parent = nil) or not AMenuItem.Parent.HandleAllocated then
Exit;
@ -1353,14 +1315,10 @@ begin
fMask := MIIM_FTYPE or MIIM_STATE; // don't retrieve current caption
end;
end;
{$ifdef WindowsUnicodeSupport}
if UnicodeEnabledOS then
GetMenuItemInfoW(AMenuItem.Parent.Handle, AMenuItem.Command, False, @MenuInfo)
else
GetMenuItemInfoA(AMenuItem.Parent.Handle, AMenuItem.Command, False, @MenuInfo);
{$else}
GetMenuItemInfo(AMenuItem.Parent.Handle, AMenuItem.Command, False, @MenuInfo);
{$endif}
with MenuInfo do
begin
// change enabled too since we can change from '-' to normal caption and vice versa
@ -1375,7 +1333,6 @@ begin
if AMenuItem.Checked then
fState := fState or MFS_CHECKED;
// AMenuItem.Caption := ACaption; // Already set
{$ifdef WindowsUnicodeSupport}
if UnicodeEnabledOS then
begin
WideBuffer := UTF8ToUTF16(CompleteMenuItemStringCaption(AMenuItem, ACaption, #9));
@ -1388,11 +1345,6 @@ begin
dwTypeData := PChar(AnsiBuffer);
cch := length(AnsiBuffer);
end;
{$else}
AnsiBuffer := UTF8ToAnsi(CompleteMenuItemStringCaption(AMenuItem, ACaption, #9));
dwTypeData := PChar(AnsiBuffer);
cch := length(AnsiBuffer);
{$endif}
if not OldMenuWin95 then
fMask := fMask or MIIM_STRING; // caption updated too
end
@ -1406,14 +1358,10 @@ begin
fState := MFS_DISABLED;
end;
end;
{$ifdef WindowsUnicodeSupport}
if UnicodeEnabledOS then
SetMenuItemInfoW(AMenuItem.Parent.Handle, AMenuItem.Command, False, @MenuInfo)
else
SetMenuItemInfoA(AMenuItem.Parent.Handle, AMenuItem.Command, False, @MenuInfo);
{$else}
SetMenuItemInfo(AMenuItem.Parent.Handle, AMenuItem.Command, False, @MenuInfo);
{$endif}
// MIIM_BITMAP is needed to request new measure item call
with MenuInfo do
@ -1424,14 +1372,10 @@ begin
fMask := MIIM_BITMAP;
dwTypeData := nil;
end;
{$ifdef WindowsUnicodeSupport}
if UnicodeEnabledOS then
SetMenuItemInfoW(AMenuItem.Parent.Handle, AMenuItem.Command, False, @MenuInfo)
else
SetMenuItemInfoA(AMenuItem.Parent.Handle, AMenuItem.Command, False, @MenuInfo);
{$else}
SetMenuItemInfo(AMenuItem.Parent.Handle, AMenuItem.Command, False, @MenuInfo);
{$endif}
// set owner drawn
with MenuInfo do
@ -1448,14 +1392,10 @@ begin
fType := (fType or MFT_OWNERDRAW) and not (MIIM_STRING or MFT_SEPARATOR);
end;
end;
{$ifdef WindowsUnicodeSupport}
if UnicodeEnabledOS then
SetMenuItemInfoW(AMenuItem.Parent.Handle, AMenuItem.Command, False, @MenuInfo)
else
SetMenuItemInfoA(AMenuItem.Parent.Handle, AMenuItem.Command, False, @MenuInfo);
{$else}
SetMenuItemInfo(AMenuItem.Parent.Handle, AMenuItem.Command, False, @MenuInfo);
{$endif}
TriggerFormUpdate(AMenuItem);
end;
@ -1465,10 +1405,8 @@ var
ParentMenuHandle: HMenu;
ParentOfParent: HMenu;
CallMenuRes: Boolean;
{$ifdef WindowsUnicodeSupport}
AnsiBuffer: ansistring;
WideBuffer: widestring;
{$endif WindowsUnicodeSupport}
begin
ParentMenuHandle := AMenuItem.Parent.Handle;
FillChar(MenuInfo, SizeOf(MenuInfo), 0);
@ -1483,14 +1421,10 @@ begin
begin
ParentOfParent := AMenuItem.Parent.Parent.Handle;
MenuInfo.fMask := MIIM_SUBMENU;
{$ifdef WindowsUnicodeSupport}
if UnicodeEnabledOS then
CallMenuRes := GetMenuItemInfoW(ParentOfParent, AMenuItem.Parent.Command, False, @MenuInfo)
else
CallMenuRes:= GetMenuItemInfoA(ParentOfParent, AMenuItem.Parent.Command, False, @MenuInfo);
{$else}
CallMenuRes := GetMenuItemInfo(ParentOfParent, AMenuItem.Parent.Command, False, @MenuInfo) ;
{$endif}
if CallMenuRes then
begin
// the parent menu item is not defined with submenu flag
@ -1498,14 +1432,10 @@ begin
if MenuInfo.hSubmenu = 0 then
begin
MenuInfo.hSubmenu := ParentMenuHandle;
{$ifdef WindowsUnicodeSupport}
if UnicodeEnabledOS then
CallMenuRes := SetMenuItemInfoW(ParentOfParent, AMenuItem.Parent.Command, False, @MenuInfo)
else
CallMenuRes := SetMenuItemInfoA(ParentOfParent, AMenuItem.Parent.Command, False, @MenuInfo);
{$else}
CallMenuRes := SetMenuItemInfo(ParentOfParent, AMenuItem.Parent.Command, False, @MenuInfo);
{$endif}
if not CallMenuRes then
DebugLn(['SetMenuItemInfo failed: ', GetLastErrorReport]);
end;
@ -1538,7 +1468,6 @@ begin
fType := fType or MFT_SEPARATOR;
fState := fState or MFS_DISABLED;
end;
{$ifdef WindowsUnicodeSupport}
if UnicodeEnabledOS then
begin
WideBuffer := UTF8ToUTF16(CompleteMenuItemCaption(AMenuItem, #9));
@ -1551,11 +1480,6 @@ begin
dwTypeData := PChar(AnsiBuffer);
cch := length(AnsiBuffer);
end;
{$else}
AnsiBuffer := UTF8ToAnsi(CompleteMenuItemCaption(AMenuItem, #9));
dwTypeData := PChar(AnsiBuffer);
cch := length(AnsiBuffer);
{$endif}
if AMenuItem.RadioItem then
fType := fType or MFT_RADIOCHECK;
if (AMenuItem.GetIsRightToLeft) then
@ -1569,14 +1493,10 @@ begin
if AMenuItem.RightJustify then
fType := fType or MFT_RIGHTJUSTIFY;
end;
{$ifdef WindowsUnicodeSupport}
if UnicodeEnabledOS then
CallMenuRes := InsertMenuItemW(ParentMenuHandle, AMenuItem.Parent.VisibleIndexOf(AMenuItem), True, @MenuInfo)
else
CallMenuRes := InsertMenuItemA(ParentMenuHandle, AMenuItem.Parent.VisibleIndexOf(AMenuItem), True, @MenuInfo);
{$else}
CallMenuRes := InsertMenuItem(ParentMenuHandle, AMenuItem.Parent.VisibleIndexOf(AMenuItem), True, @MenuInfo);
{$endif}
if not CallMenuRes then
DebugLn(['InsertMenuItem failed with error: ', GetLastErrorReport]);
TriggerFormUpdate(AMenuItem);
@ -1611,26 +1531,18 @@ begin
cbSize := sizeof(TMenuItemInfo);
fMask := MIIM_SUBMENU;
end;
{$ifdef WindowsUnicodeSupport}
if UnicodeEnabledOS then
GetMenuItemInfoW(ParentOfParentHandle, AMenuItem.Parent.Command, False, @MenuInfo)
else
GetMenuItemInfoA(ParentOfParentHandle, AMenuItem.Parent.Command, False, @MenuInfo);
{$else}
GetMenuItemInfo(ParentOfParentHandle, AMenuItem.Parent.Command, False, @MenuInfo) ;
{$endif}
// the parent menu item is defined with submenu flag then reset it
if MenuInfo.hSubmenu <> 0 then
begin
MenuInfo.hSubmenu := 0;
{$ifdef WindowsUnicodeSupport}
if UnicodeEnabledOS then
CallMenuRes := SetMenuItemInfoW(ParentOfParentHandle, AMenuItem.Parent.Command, False, @MenuInfo)
else
CallMenuRes := SetMenuItemInfoA(ParentOfParentHandle, AMenuItem.Parent.Command, False, @MenuInfo);
{$else}
CallMenuRes := SetMenuItemInfo(ParentOfParentHandle, AMenuItem.Parent.Command, False, @MenuInfo);
{$endif}
if not CallMenuRes then
DebugLn(['SetMenuItemInfo failed: ', GetLastErrorReport]);
// Set menu item info destroys/corrupts our internal popup menu for the

View File

@ -165,7 +165,6 @@ begin
SystemParametersInfo(SPI_GETHOTTRACKING, 0, @HotTracking, 0);
UpDownFlags := WS_CHILD or WS_CLIPSIBLINGS or UDS_ALIGNRIGHT or UDS_ARROWKEYS or
UpDownHotStyle[HotTracking] or ((WS_VISIBLE or WS_DISABLED) and Flags);
{$IFDEF WindowsUnicodeSupport}
if UnicodeEnabledOS then
begin
Window := CreateWindowExW(FlagsEx, PWideChar(WideString(EditClsName)),
@ -182,12 +181,6 @@ begin
UpDown := CreateWindowEx(0, UPDOWN_CLASSA, nil, UpDownFlags,
0, 0, 8, Height, Parent, HMENU(nil), HInstance, nil);
end;
{$ELSE}
Window := CreateWindowEx(FlagsEx, @EditClsName[0], PChar(StrCaption),
Flags, Left, Top, Width, Height, Parent, HMENU(nil), HInstance, nil);
UpDown := CreateWindowEx(0, UPDOWN_CLASSW, nil, UpDownFlags,
0, 0, 8, Height, Parent, HMENU(nil), HInstance, nil);
{$ENDIF}
Windows.SendMessage(UpDown, UDM_SETBUDDY, WPARAM(Window), 0);
end;
// create window
@ -198,11 +191,9 @@ begin
// init updown control
Info := AllocWindowInfo(UpDown);
Info^.AWinControl := AWinControl;
{$IFDEF WindowsUnicodeSupport}
if UnicodeEnabledOS then
Info^.DefWndProc := Windows.WNDPROC(SetWindowLongPtrW(UpDown, GWL_WNDPROC, PtrInt(@SpinUpDownWndProc)))
else
{$ENDIF}
Info^.DefWndProc := Windows.WNDPROC(SetWindowLongPtr(UpDown, GWL_WNDPROC, PtrInt(@SpinUpDownWndProc)));
SetProp(UpDown, 'WinControl', PtrUInt(AWinControl));
Result := Params.Window;

View File

@ -1102,42 +1102,25 @@ end;
function EditGetSelStart(WinHandle: HWND): integer;
begin
{$ifdef WindowsUnicodeSupport}
if UnicodeEnabledOS then
begin
Windows.SendMessageW(WinHandle, EM_GETSEL, Windows.WPARAM(@Result), 0);
end
Windows.SendMessageW(WinHandle, EM_GETSEL, Windows.WPARAM(@Result), 0)
else
begin
Windows.SendMessage(WinHandle, EM_GETSEL, Windows.WPARAM(@Result), 0);
end;
{$else}
Windows.SendMessage(WinHandle, EM_GETSEL, Windows.WPARAM(@Result), 0);
{$endif}
end;
function EditGetSelLength(WinHandle: HWND): integer;
var
startpos, endpos: integer;
begin
{$ifdef WindowsUnicodeSupport}
if UnicodeEnabledOS then
begin
Windows.SendMessageW(WinHandle, EM_GETSEL, Windows.WPARAM(@startpos), Windows.LPARAM(@endpos));
end
Windows.SendMessageW(WinHandle, EM_GETSEL, Windows.WPARAM(@startpos), Windows.LPARAM(@endpos))
else
begin
Windows.SendMessage(WinHandle, EM_GETSEL, Windows.WPARAM(@startpos), Windows.LPARAM(@endpos));
end;
{$else}
Windows.SendMessage(WinHandle, EM_GETSEL, Windows.WPARAM(@startpos), Windows.LPARAM(@endpos));
{$endif}
Result := endpos - startpos;
end;
procedure EditSetSelStart(WinHandle: HWND; NewStart: integer);
begin
{$ifdef WindowsUnicodeSupport}
if UnicodeEnabledOS then
begin
Windows.SendMessageW(WinHandle, EM_SETSEL, Windows.WParam(NewStart), Windows.LParam(NewStart));
@ -1150,35 +1133,24 @@ begin
// scroll caret into view
Windows.SendMessage(WinHandle, EM_SCROLLCARET, 0, 0);
end;
{$else}
Windows.SendMessage(WinHandle, EM_SETSEL, Windows.WParam(NewStart), Windows.LParam(NewStart));
// scroll caret into view
Windows.SendMessage(WinHandle, EM_SCROLLCARET, 0, 0);
{$endif}
end;
procedure EditSetSelLength(WinHandle: HWND; NewLength: integer);
var
startpos, endpos: integer;
begin
{$ifdef WindowsUnicodeSupport}
if UnicodeEnabledOS then
begin
Windows.SendMessageW(WinHandle, EM_GETSEL, Windows.WParam(@startpos), Windows.LParam(@endpos));
endpos := startpos + NewLength;
Windows.SendMessageW(WinHandle, EM_SETSEL, Windows.WParam(startpos), Windows.LParam(endpos));
end
else
begin
Windows.SendMessage(WinHandle, EM_GETSEL, Windows.WParam(@startpos), Windows.LParam(@endpos));
endpos := startpos + NewLength;
Windows.SendMessage(WinHandle, EM_SETSEL, Windows.WParam(startpos), Windows.LParam(endpos));
end;
{$else}
if UnicodeEnabledOS then
begin
Windows.SendMessageW(WinHandle, EM_GETSEL, Windows.WParam(@startpos), Windows.LParam(@endpos));
endpos := startpos + NewLength;
Windows.SendMessageW(WinHandle, EM_SETSEL, Windows.WParam(startpos), Windows.LParam(endpos));
end
else
begin
Windows.SendMessage(WinHandle, EM_GETSEL, Windows.WParam(@startpos), Windows.LParam(@endpos));
endpos := startpos + NewLength;
Windows.SendMessage(WinHandle, EM_SETSEL, Windows.WParam(startpos), Windows.LParam(endpos));
{$endif}
end;
end;
{ TWin32WSCustomEdit }