mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-24 19:39:17 +02:00
Fixes setting the application title on windows unicode.
git-svn-id: trunk@13735 -
This commit is contained in:
parent
993bf3680e
commit
123be10231
@ -230,6 +230,8 @@ const
|
||||
ComboboxClsName: array[0..8] of char = 'ComboBox'#0;
|
||||
TabControlClsName: array[0..15] of char = 'SysTabControl32'#0;
|
||||
|
||||
ClsNameW: array[0..6] of WideChar = ('W', 'i', 'n', 'd', 'o', 'w', #0);
|
||||
|
||||
{$ifdef DEBUG_DOUBLEBUFFER}
|
||||
var
|
||||
CopyBitmapToClipboard: boolean = true;
|
||||
|
@ -111,12 +111,28 @@ begin
|
||||
if InitCommonControlsEx <> nil then
|
||||
InitCommonControlsEx(@ICC);
|
||||
|
||||
// Create parent of all windows, `button on taskbar'
|
||||
// Create parent of all windows, 'button on taskbar'
|
||||
{$ifdef WindowsUnicodeSupport}
|
||||
if UnicodeEnabledOS then
|
||||
FAppHandle := CreateWindowW(@ClsNameW,
|
||||
PWideChar(Utf8Decode(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)
|
||||
else
|
||||
FAppHandle := CreateWindow(@ClsName, PChar(Utf8ToAnsi(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);
|
||||
{$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);
|
||||
|
||||
// set nice main icon
|
||||
@ -369,9 +385,10 @@ End;
|
||||
procedure TWin32WidgetSet.AppSetTitle(const ATitle: string);
|
||||
begin
|
||||
{$ifdef WindowsUnicodeSupport}
|
||||
if UnicodeEnabledOS
|
||||
then Windows.SetWindowTextW(FAppHandle, PWideChar(Utf8Decode(ATitle)))
|
||||
else Windows.SetWindowText(FAppHandle, PChar(Utf8ToAnsi(ATitle)));
|
||||
if UnicodeEnabledOS then
|
||||
begin
|
||||
Windows.SetWindowTextW(FAppHandle, PWideChar(Utf8Decode(ATitle)));
|
||||
end else Windows.SetWindowText(FAppHandle, PChar(Utf8ToAnsi(ATitle)));
|
||||
{$else}
|
||||
Windows.SetWindowText(FAppHandle, PChar(ATitle));
|
||||
{$endif}
|
||||
@ -489,7 +506,7 @@ Begin
|
||||
hCursor := Windows.LoadCursor(0, IDC_ARROW);
|
||||
hbrBackground := 0; {GetSysColorBrush(Color_BtnFace);}
|
||||
LPSzMenuName := Nil;
|
||||
LPSzClassName := PWideChar(WideString(ClsName));
|
||||
LPSzClassName := @ClsNameW;
|
||||
end;
|
||||
Result := Windows.RegisterClassW(@WindowClassW) <> 0;
|
||||
end
|
||||
|
@ -2380,8 +2380,8 @@ begin
|
||||
UTF8ToDoubleByte(PChar(s),length(s),PByte(Result));
|
||||
end;
|
||||
|
||||
{ returns number of double bytes }
|
||||
function UTF8ToDoubleByte(UTF8Str: PChar; Len: integer; DBStr: PByte): integer;
|
||||
// returns number of double bytes
|
||||
var
|
||||
SrcPos: PChar;
|
||||
CharLen: LongInt;
|
||||
@ -2421,6 +2421,11 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
{ Len is the length in bytes of UTF8Str
|
||||
Index is the position of the desired char, in chars
|
||||
|
||||
This function is similar to UTF8FindNearestCharStart
|
||||
}
|
||||
function UTF8CharStart(UTF8Str: PChar; Len, Index: integer): PChar;
|
||||
var
|
||||
CharLen: LongInt;
|
||||
@ -2438,8 +2443,8 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
{ fix any broken UTF8 sequences with spaces }
|
||||
procedure UTF8FixBroken(P: PChar);
|
||||
// fix any broken UTF8 sequences with spaces
|
||||
begin
|
||||
if p=nil then exit;
|
||||
while p^<>#0 do begin
|
||||
|
Loading…
Reference in New Issue
Block a user