Posts: 2,164
Threads: 222
Joined: Apr 2022
Reputation:
103
I'd like to put CHR$(240), three small horizontal lines, in my title bar, but the _TITLE function cannot convert extended ASCII characters. Is there another method that wold print the 3 horizontal bars into the title bar so it doesn't look like this: ð
Pete
Posts: 2,698
Threads: 327
Joined: Apr 2022
Reputation:
217
CHR$(240) is a mapped unicode character, so it's going to display, by default, whatever code page your OS is configured for. (In this case, you're getting the o with the accent over it.)
As far as I can guess, the only way you'd work around this is to use wide characters and call the windows call to set the title yourself.
https://learn.microsoft.com/en-us/window...indowtextw <-- use this for the windows API call to the unicode characters.
Code: (Select All) _TITLE CHR$(240) + "Foo"
i% = _MAPUNICODE(240)
t$ = MKI$(i%)
title$ = t$ + "F o o "
^ And I'm thinking the above should give you the actual unicode characters that you'd bee looking for.
I'm lazy (and running back and forth to the kitchen cooking breakfst), so I haven't tested putting the pieces together yet, but it seems as if they should do what you want.
Posts: 2,164
Threads: 222
Joined: Apr 2022
Reputation:
103
11-15-2022, 05:42 PM
(This post was last modified: 11-15-2022, 05:58 PM by Pete.)
I also tried using unicode, but no success either. Your code displayed an a with two small vertical '' above it.
I'm using CHR$(4) + "Foo" in the _TITLE function to display a transparent box for now. That's right, box, not a diamond.
Maybe we are missing something with the _MAPUNICODE function, I don't know. I haven't worked with it in QB64 before and it maybe especially difficult trying to get the _TITLE function to accept it.
I'm busy running back and forth the Arby's eating breakfast. Dammit I wish they'd stop forgetting to put the horsey sauce in the take out bag!
Pete
Posts: 2,698
Threads: 327
Joined: Apr 2022
Reputation:
217
I've played with it a little as well. I think I've got it working, more or less, but there's still no printing of the "menu" icon in the title bar. Instead, it does a substitution as shown below:
Code: (Select All) DECLARE DYNAMIC LIBRARY "user32"
FUNCTION SetWindowTextW (BYVAL Handle AS _OFFSET, title$)
END DECLARE
'_TITLE CHR$(240) + "Foo"
i% = _MAPUNICODE(240)
t$ = MKI$(i%)
PRINT t$ 'this is chr$(34) and "a", but they need to be reversed to do anything. Endianness issue, I guess?
SLEEP 'so we have time to make certain that the _WINDOWHANDLE is properly assigned to this window
title$ = "a" + CHR$(34) + "F" + CHR$(0) + "o" + CHR$(0) + "o" + CHR$(0) + CHR$(0)
result = SetWindowTextW(_WINDOWHANDLE, title$) 'IF the line with _TITLE is uncommented above, this does nothing.
SLEEP
All that effort just to get "=Foo" to display!
Posts: 2,164
Threads: 222
Joined: Apr 2022
Reputation:
103
11-15-2022, 06:39 PM
(This post was last modified: 11-15-2022, 06:41 PM by Pete.)
Strange. It doesn't print the three horizontal marks in the title bar, only 2. More like an equals sign instead of CHR$(240).
Pete
Posts: 2,698
Threads: 327
Joined: Apr 2022
Reputation:
217
(11-15-2022, 06:39 PM)Pete Wrote: Strange. It doesn't print the three horizontal marks in the title bar, only 2. More like an equals sign instead of CHR$(240).
What is also weird is it didn't work with another method using MID$() to extract the "a"... It beeps, so the two strings, title1$ and title2$, are the same, but only the later one creates a title.
Pete
That's why I mentioned, "all that effort just to get "=Foo" as the title." I don't know if it's some windows specific replacement routine going on with the title, or what the heck it is, but the triple line ends up only becoming a double line. IF anyone else has any ideas over what's wrong here, I'd love to hear them, as it seems to me that it should be working as written.
I've also noticed the glitch with not building the string character by character. You can't RIGHT$ + LEFT$ to reverse the letters, and make it work either. ANd, let you tested, one string is equal to the other string, but windows works with one and not the other... Now, explain that to me! ???
Maybe you should just go with "|||Foo" and tell people your bars toppled over sideways in the wind.
Posts: 2,164
Threads: 222
Joined: Apr 2022
Reputation:
103
Right. I edited the other stuff out to avoid confusing others. One rabbit hole at a time.
Weird that _MAPUNICODE correctly equals 8801 but only shows up as 2 bars. Maybe its poor tower reception and we need to upgrade to QB64-PE 5G?
https://www.codetable.net/decimal/8801
See folks, Steve and I aren't crazy, three bars!
Maybe I should try the QB64 "Official" version, but every time I walk over there, I come back with cricket juice on my shoes.
Pete
Posts: 2,164
Threads: 222
Joined: Apr 2022
Reputation:
103
Ah, maybe it has something to do with the configuration. It seems to be that = sign is something Windows throws in. Also "?" marks and a few other symbols with different values, but we are actually not seeing the UNICODE character here. It's a red herring.
Code: (Select All) DECLARE DYNAMIC LIBRARY "user32"
FUNCTION SetWindowTextW (BYVAL Handle AS _OFFSET, title$)
END DECLARE
_CONTROLCHR OFF
DO
j = j + 1
i% = _MAPUNICODE(126 + j)
t$ = MKI$(i%)
PRINT 126 + j, i%, MID$(t$, 1, 1), t$
_DELAY .1
title$ = CHR$(64 + j) + CHR$(34) + "F" + CHR$(0) + "o" + CHR$(0) + "o"
result = SetWindowTextW(_WINDOWHANDLE, title$)
SLEEP
LOOP
Watch the title bar change to ?Foo to =Foo at 159.
Pete
Posts: 732
Threads: 30
Joined: Apr 2022
Reputation:
43
11-15-2022, 07:39 PM
(This post was last modified: 11-15-2022, 07:40 PM by SpriggsySpriggs.)
Give this a try, @Pete. This is a function set I use to convert to and from Unicode:
Code: (Select All) $If UNICODETOANSI = UNDEFINED Then
$Let UNICODETOANSI = DEFINED
Declare CustomType Library
Function WideCharToMultiByte& (ByVal CodePage As _Unsigned Long, Byval dwFlags As Long, Byval lpWideCharStr As _Offset, Byval cchWideChar As Integer, Byval lpMultiByteStr As _Offset, Byval cbMultiByte As Integer, Byval lpDefaultChar As _Offset, Byval lpUsedDefaultChar As _Offset)
Function MultiByteToWideChar& (ByVal CodePage As _Unsigned Long, Byval dwFlags As Long, Byval lpMultiByteStr As _Offset, Byval cbMultiByte As Integer, Byval lpWideCharStr As _Offset, Byval cchWideChar As Integer)
End Declare
Function UnicodeToANSI$ (buffer As String)
Dim As String ansibuffer: ansibuffer = Space$(Len(buffer))
Dim As Long a: a = WideCharToMultiByte(437, 0, _Offset(buffer), Len(buffer), _Offset(ansibuffer), Len(ansibuffer), 0, 0)
UnicodeToANSI = Mid$(ansibuffer, 1, InStr(ansibuffer, Chr$(0)) - 1)
End Function
Sub UnicodeToANSI (buffer As String, __dest As String)
Dim As String ansibuffer: ansibuffer = Space$(Len(buffer))
Dim As Long a: a = WideCharToMultiByte(437, 0, _Offset(buffer), Len(buffer), _Offset(ansibuffer), Len(ansibuffer), 0, 0)
__dest = Mid$(ansibuffer, 1, InStr(ansibuffer, Chr$(0)) - 1)
End Sub
Function ANSIToUnicode$ (buffer As String)
Dim As String unicodebuffer: unicodebuffer = Space$(Len(buffer) * 2)
Dim As Long a: a = MultiByteToWideChar(65001, 0, _Offset(buffer), Len(buffer), _Offset(unicodebuffer), Len(unicodebuffer))
ANSIToUnicode = unicodebuffer
End Function
Sub ANSIToUnicode (buffer As String, __dest As String)
Dim As String unicodebuffer: unicodebuffer = Space$(Len(buffer) * 2)
Dim As Long a: a = MultiByteToWideChar(65001, 0, _Offset(buffer), Len(buffer), _Offset(unicodebuffer), Len(unicodebuffer))
__dest = unicodebuffer
End Sub
$End If
Tread on those who tread on you
Posts: 2,164
Threads: 222
Joined: Apr 2022
Reputation:
103
11-15-2022, 07:43 PM
(This post was last modified: 11-15-2022, 07:43 PM by Pete.)
I'm going to post this, and try Spriggsy's solution and post back.
This just shows _MAPUNICODE gets the right number, but converting it to a string fails to create the correct character...
Code: (Select All) t$ = MID$(MKI$(_MAPUNICODE(240)), 1, 1)
PRINT t$
Pete
Shoot first and shoot people who ask questions, later.
|