mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-04 20:20:23 +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;
|
ComboboxClsName: array[0..8] of char = 'ComboBox'#0;
|
||||||
TabControlClsName: array[0..15] of char = 'SysTabControl32'#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}
|
{$ifdef DEBUG_DOUBLEBUFFER}
|
||||||
var
|
var
|
||||||
CopyBitmapToClipboard: boolean = true;
|
CopyBitmapToClipboard: boolean = true;
|
||||||
|
@ -111,12 +111,28 @@ begin
|
|||||||
if InitCommonControlsEx <> nil then
|
if InitCommonControlsEx <> nil then
|
||||||
InitCommonControlsEx(@ICC);
|
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
|
FAppHandle := CreateWindow(@ClsName, PChar(Application.Title), WS_POPUP or
|
||||||
WS_CLIPSIBLINGS or WS_SYSMENU or WS_MINIMIZEBOX,
|
WS_CLIPSIBLINGS or WS_SYSMENU or WS_MINIMIZEBOX,
|
||||||
0, {Windows.GetSystemMetrics(SM_CXSCREEN) div 2,}
|
0, {Windows.GetSystemMetrics(SM_CXSCREEN) div 2,}
|
||||||
0, {Windows.GetSystemMetrics(SM_CYSCREEN) div 2,}
|
0, {Windows.GetSystemMetrics(SM_CYSCREEN) div 2,}
|
||||||
0, 0, HWND(nil), HMENU(nil), HInstance, nil);
|
0, 0, HWND(nil), HMENU(nil), HInstance, nil);
|
||||||
|
{$endif}
|
||||||
AllocWindowInfo(FAppHandle);
|
AllocWindowInfo(FAppHandle);
|
||||||
|
|
||||||
// set nice main icon
|
// set nice main icon
|
||||||
@ -369,9 +385,10 @@ End;
|
|||||||
procedure TWin32WidgetSet.AppSetTitle(const ATitle: string);
|
procedure TWin32WidgetSet.AppSetTitle(const ATitle: string);
|
||||||
begin
|
begin
|
||||||
{$ifdef WindowsUnicodeSupport}
|
{$ifdef WindowsUnicodeSupport}
|
||||||
if UnicodeEnabledOS
|
if UnicodeEnabledOS then
|
||||||
then Windows.SetWindowTextW(FAppHandle, PWideChar(Utf8Decode(ATitle)))
|
begin
|
||||||
else Windows.SetWindowText(FAppHandle, PChar(Utf8ToAnsi(ATitle)));
|
Windows.SetWindowTextW(FAppHandle, PWideChar(Utf8Decode(ATitle)));
|
||||||
|
end else Windows.SetWindowText(FAppHandle, PChar(Utf8ToAnsi(ATitle)));
|
||||||
{$else}
|
{$else}
|
||||||
Windows.SetWindowText(FAppHandle, PChar(ATitle));
|
Windows.SetWindowText(FAppHandle, PChar(ATitle));
|
||||||
{$endif}
|
{$endif}
|
||||||
@ -489,7 +506,7 @@ Begin
|
|||||||
hCursor := Windows.LoadCursor(0, IDC_ARROW);
|
hCursor := Windows.LoadCursor(0, IDC_ARROW);
|
||||||
hbrBackground := 0; {GetSysColorBrush(Color_BtnFace);}
|
hbrBackground := 0; {GetSysColorBrush(Color_BtnFace);}
|
||||||
LPSzMenuName := Nil;
|
LPSzMenuName := Nil;
|
||||||
LPSzClassName := PWideChar(WideString(ClsName));
|
LPSzClassName := @ClsNameW;
|
||||||
end;
|
end;
|
||||||
Result := Windows.RegisterClassW(@WindowClassW) <> 0;
|
Result := Windows.RegisterClassW(@WindowClassW) <> 0;
|
||||||
end
|
end
|
||||||
|
@ -2380,8 +2380,8 @@ begin
|
|||||||
UTF8ToDoubleByte(PChar(s),length(s),PByte(Result));
|
UTF8ToDoubleByte(PChar(s),length(s),PByte(Result));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ returns number of double bytes }
|
||||||
function UTF8ToDoubleByte(UTF8Str: PChar; Len: integer; DBStr: PByte): integer;
|
function UTF8ToDoubleByte(UTF8Str: PChar; Len: integer; DBStr: PByte): integer;
|
||||||
// returns number of double bytes
|
|
||||||
var
|
var
|
||||||
SrcPos: PChar;
|
SrcPos: PChar;
|
||||||
CharLen: LongInt;
|
CharLen: LongInt;
|
||||||
@ -2421,6 +2421,11 @@ begin
|
|||||||
end;
|
end;
|
||||||
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;
|
function UTF8CharStart(UTF8Str: PChar; Len, Index: integer): PChar;
|
||||||
var
|
var
|
||||||
CharLen: LongInt;
|
CharLen: LongInt;
|
||||||
@ -2438,8 +2443,8 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ fix any broken UTF8 sequences with spaces }
|
||||||
procedure UTF8FixBroken(P: PChar);
|
procedure UTF8FixBroken(P: PChar);
|
||||||
// fix any broken UTF8 sequences with spaces
|
|
||||||
begin
|
begin
|
||||||
if p=nil then exit;
|
if p=nil then exit;
|
||||||
while p^<>#0 do begin
|
while p^<>#0 do begin
|
||||||
|
Loading…
Reference in New Issue
Block a user