coda
Junior Member
Posts: 74
|
Post by coda on Nov 30, 2021 8:42:53 GMT -5
Thankyou, Walt. No translation. I'm an experienced programmer but am not as familiar with API calls and dll usage as I probably should be. I have used both before quite a number of times but might need the old grey matter jogging in relation to the following part of what you have said: I have got as far as getting a functional RTF edit control in my app using the dll provided by Alyce's site and all appears to be working but the window still displays predictable nonsense when I send it a unicode string. All I need is a hint from you (if and when you have time) on how to use what you have said above to make the edit control respond appropriately to the unicode I print to it. Thankyou, Metro Guru. I shall have to go onto the Linux machine to retrieve that too. It appears I'm just not allowed to download files from the internet anymore these days. Not sure what the true issue is but I can't get yours either. I'm sure it's there. Will try Linux. Probably the Australian government messing with me... lol
|
|
|
Post by Walt Decker on Nov 30, 2021 12:49:15 GMT -5
Here you go using a multi-line edit control. RT is just a hybrid of the edit class, so most of the edit messages will work with rich text. If you are using a language other than english, be sure to load the appropriate font.
EDIT: I do not have Mrs. Watson's rich text dll; however, I can probably provide you with some api functions that will accomplish just about everything you want to do with it.
' [EDIT.CTRL.STYLE] ES.MULTILINE = HEXDEC("&H0004") ES.AUTOHSCROLL = HEXDEC("&H0080") ES.AUTOVSCROLL = HEXDEC("&H0040") ES.NOHIDESEL = HEXDEC("&H0100") ES.WANTRETURN = HEXDEC("&H1000") WS.VSCROLL = HEXDEC("&H00200000")
GLOBAL CRLF$ GLOBAL UNICODE
CRLF$ = CHR$(13) + CHR$(10)
UNICODE = 1
OutTxt$ = "Peter Piper picked a peck of pickled peppers" + CRLF$
OPEN "USER32.DLL" FOR DLL AS #USER
WindowWidth = DisplayWidth / 2 WindowHeight = DisplayHeight / 2
Style = WS.VSCROLL OR ES.MULTILINE OR ES.WANTRETURN OR ES.NOHIDESEL OR _ ES.AUTOVSCROLL STYLEBITS #DMO.EDT, Style, ES.AUTOHSCROLL, 0, 0 TEXTBOX #DMO.EDT, 5, 5, WindowWidth - 28, WindowHeight - 85
OPEN "UNICODE TEXT" FOR WINDOW AS #DMO PRINT #DMO, "TRAPCLOSE END.DMO"
TxtHndl = FN.GetHandle("DMO.EDT") RetVal = FN.SetText(TxtHndl, OutTxt$)
TIMER 4000, [WIDE.STRING]
WAIT [WIDE.STRING] TIMER 0 OutTxt$ = FN.WideString$(OutTxt$) PRINT OutTxt$ RetVal = FN.SetText(TxtHndl, OutTxt$) PRINT "LEN OUTTXT$ = "; LEN(OutTxt$)
[END.WAIT] WAIT
'--------------------------------------------------------- '---------------------------------------------------------
SUB END.DMO Hndl$
CLOSE #USER CLOSE #DMO END
END SUB FUNCTION FN.GetHandle(HndlStr$)
Hndl = 0
IF LEFT$(HndlStr$, 1) <> "#" THEN HndlStr$ = "#" + HndlStr$
Hndl = HWND(#HndlStr$)
FN.GetHandle = Hndl END FUNCTION
'--------------------------------------------------------- '---------------------------------------------------------
FUNCTION FN.SetText(TxtHndl, InTxt$)
TxtFunc$ = "SetWindowTextA" IF UNICODE THEN TxtFunc$ = "SetWindowTextW" END IF
CALLDLL #USER, TxtFunc$, TxtHndl AS ULONG, InTxt$ AS PTR, NumChrs AS LONG
END FUNCTION
'--------------------------------------------------------- '---------------------------------------------------------
FUNCTION FN.WideString$(TxtIn$)
[CODE.PAGES] CP.ACP = 0 ' default to ANSI code page CP.OEMCP = 1 ' default to OEM code page CP.MACCP = 2 ' default to MAC code page CP.THREAD.ACP = 3 ' current thread's ANSI code page CP.SYMBOL = 42 ' SYMBOL translations
CP.UTF7 = 65000 ' UTF-7 translation CP.UTF8 = 65001 ' UTF-8 translation
[COMPOSITING.FLAGS] MB.PRECOMPOSED = 01 ' use precomposed chars MB.COMPOSITE = 02 ' use composite chars MB.USEGLYPHCHARS = 04 ' use glyph chars, not ctrl chars MB.ERR.INVALID.CHARS = 08 ' error for invalid chars
TxtLen = 0 ChrsIn = 0 ChrsOut = 0 NumChrs = 0
StrIn$ = ""
TxtLen = LEN(TxtIn$) ChrsIn = TxtLen + 1 ChrsOut = TxtLen * 2 + 1
StrIn$ = SPACE$(TxtLen * 2 + 1)
dwFlags = MB.PRECOMPOSED OR MB.USEGLYPHCHARS CALLDLL #kernel32, "MultiByteToWideChar", _ CP.ACP AS ULONG, _ '<--- CodePage dwFlags AS ULONG, _ '<--- translation flags TxtIn$ AS PTR, _ '<--- Original text ChrsIn AS LONG, _ '<--- # bytes in original text StrIn$ AS PTR, _ '<--- string to receive translation ChrsOut AS LONG, _ '<--- # of chrs for wide string NumChrs AS LONG '<--- RETURN: # of chrs written
FN.WideString$ = StrIn$ END FUNCTION
'--------------------------------------------------------- '--------------------------------------------------------- '
|
|
coda
Junior Member
Posts: 74
|
Post by coda on Dec 2, 2021 12:17:50 GMT -5
Wow. Thanks so much, Walt! I'll check it out tomorrow!
|
|
|
Post by Walt Decker on Dec 2, 2021 14:04:21 GMT -5
You are welcome. However, I am curious. If you are using a file, why do you not just stream it directly to word pad, ms word, open office or some other word processor? They are all unicode and usually UTF8 aware.
Also, what are your requirements? If Mrs. Watson's RT dll does not meet your needs, perhaps I can come up with something that will.
|
|