flat assembler
Message board for the users of flat assembler.

Index > Windows > Question about window text setting.

Author
Thread Post new topic Reply to topic
KostX



Joined: 19 Sep 2012
Posts: 41
KostX 16 Feb 2015, 04:56
Hi all! How to set a text to a window with string length limit.
SetWindoText and WM_SETTEXT doesn't work how I need, they require null-terminated string. I want to know are there alternative functions to work with ACSII strings which sometimes may not to be terminated by zero-byte?
Post 16 Feb 2015, 04:56
View user's profile Send private message Reply with quote
Mikl___



Joined: 30 Dec 2014
Posts: 129
Location: Russian Federation, Irkutsk
Mikl___ 16 Feb 2015, 08:17
Hi, KostX !
See alternative lessons of Iczelion --> Lesson #4B
Post 16 Feb 2015, 08:17
View user's profile Send private message Visit poster's website Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr 16 Feb 2015, 09:40
KostX,

Had you meant 'counted' (AKA Pascal/Delphi) strings, like db 13, "Hello, world!"? You may simply poke zero byte right behind the last used byte (provided there is spare byte there) and pass appropriate address to WinAPI (it may not work if that string contains zero byte).

AFAIK Delphi ANSIString and WideString types are made specifically to be compatible with WinAPI (they have length and refcount fields at negative offsets and ensure NUL termination).
Post 16 Feb 2015, 09:40
View user's profile Send private message Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1627
Location: Toronto, Canada
AsmGuru62 16 Feb 2015, 12:50
The way to do it is dynamically allocate room for the characters you want to set and a terminating null character.
Then copy text, terminate it and then use SetWindowText().
Post 16 Feb 2015, 12:50
View user's profile Send private message Send e-mail Reply with quote
Force



Joined: 12 Jun 2012
Posts: 29
Force 18 Feb 2015, 17:17
Post 18 Feb 2015, 17:17
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.