Lazarus
Home
Help
TinyPortal
Search
Login
Register
Lazarus
»
Forum
»
Programming
»
General
»
How to use GetWindowText() correctly?
Free Pascal
Website
Downloads
Wiki
Bugtracker
Mailing List
Lazarus
Website
Downloads (Laz+FPC)
Packages (OPM)
FAQ
Wiki
Bugtracker
CCR Bugs
IRC channel
GIT
Mailing List
Other languages
Foundation
Website
Useful Wiki Links
Project Roadmap
Getting the Source
Screenshots
How to use the forum
About donations (wiki)
Bookstore
Computer Math and Games in Pascal
(preview)
Lazarus Handbook
Search
Advanced search
Recent
Parsing Long string to sp...
by
JLWest
[
Today
at 07:13:52 am]
Can FreePascal be used to...
by
Wysardry
[
Today
at 07:04:32 am]
TPageControl tabs visible...
by
NightSky
[
Today
at 05:40:58 am]
Using the Mouse Wheel to ...
by
derek.john.evans
[
Today
at 05:06:19 am]
Free Pascal Standards
by
jamie
[
Today
at 03:48:05 am]
How can one optimise inse...
by
y.ivanov
[
Today
at 01:13:27 am]
Advanced Records Initiali...
by
ASerge
[
Today
at 12:42:49 am]
My confession - I am a Pa...
by
Ten_Mile_Hike
[August 13, 2022, 11:24:35 pm]
Forest and lumber jack to...
by
JuhaManninen
[August 13, 2022, 11:09:23 pm]
How to Add a MenuItem to ...
by
HeavyUser
[August 13, 2022, 09:28:25 pm]
« previous
next »
Print
Pages: [
1
]
Author
Topic: How to use GetWindowText() correctly? (Read 230 times)
was
New member
Posts: 5
How to use GetWindowText() correctly?
«
on:
June 27, 2022, 12:56:52 pm »
Hello, I use GetWindowText() to get Application's title, but Non English characters cannot be displayed.
Logged
paweld
Sr. Member
Posts: 404
Re: How to use GetWindowText() correctly?
«
Reply #1 on:
June 27, 2022, 01:17:43 pm »
Code: Pascal
[Select]
[+]
[-]
procedure
TForm1
.
Button1Click
(
Sender
:
TObject
)
;
var
szText
:
WideString
;
begin
Edit1
.
Text
:
=
Caption
;
if
GetWindowTextW
(
GetForegroundWindow
,
PWideChar
(
szText
)
,
GetWindowTextLengthW
(
GetForegroundWindow
)
)
>
0
then
Edit2
.
Text
:
=
szText
;
end
;
Logged
Best regards
paweld
---
Lazarus trunk / FPC stable
PascalDragon
Hero Member
Posts: 4301
Compiler Developer
Re: How to use GetWindowText() correctly?
«
Reply #2 on:
June 27, 2022, 01:20:58 pm »
@paweld: you should not mix
PWideChar
and
WideString
like this, cause
GetWindowTextW
won't allocate the buffer for you. So you should do (not tested):
Code: Pascal
[Select]
[+]
[-]
SetLength
(
szText
,
GetWindowTextLengthW
(
GetForegroundWindow
)
)
;
if
GetWindowTextW
(
GetForegroundWindow
,
PWideChar
(
szText
)
,
Length
(
szText
)
)
>
0
then
«
Last Edit: June 28, 2022, 01:30:09 pm by PascalDragon
»
Logged
paweld
Sr. Member
Posts: 404
Re: How to use GetWindowText() correctly?
«
Reply #3 on:
June 27, 2022, 02:10:03 pm »
@PascalDragon: thank you very much for the explanation
Logged
Best regards
paweld
---
Lazarus trunk / FPC stable
was
New member
Posts: 5
Re: How to use GetWindowText() correctly?
«
Reply #4 on:
June 27, 2022, 03:27:42 pm »
@paweld, @PascalDragon: thank you very much.
Logged
Print
Pages: [
1
]
« previous
next »
Lazarus
»
Forum
»
Programming
»
General
»
How to use GetWindowText() correctly?
TinyPortal
© 2005-2018