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
TStringList Assigments
by
derek.john.evans
[
Today
at 04:47:23 am]
Never code like this
by
Fred vS
[
Today
at 01:02:09 am]
Simple https download to ...
by
HeavyUser
[
Today
at 12:23:28 am]
Disabling a Scroll Box [S...
by
Badger
[August 19, 2022, 11:49:32 pm]
Is possible to add custom...
by
LeoBruno
[August 19, 2022, 11:36:47 pm]
John Carmack talks about ...
by
Leledumbo
[August 19, 2022, 11:06:51 pm]
install fail Lazarus 2.2....
by
tetrastes
[August 19, 2022, 10:46:05 pm]
rx e powerpdf license
by
kkuba
[August 19, 2022, 09:07:34 pm]
pi PICO controlling ws281...
by
jb007
[August 19, 2022, 08:28:21 pm]
[solved] RichMemo and CHA...
by
rick2691
[August 19, 2022, 08:26:25 pm]
« previous
next »
Print
Pages: [
1
]
Author
Topic: How to use GetWindowText() correctly? (Read 236 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: 422
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: 4327
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: 422
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