|
Post by Walt Decker on Apr 18, 2023 13:48:29 GMT -5
WINSTRING() : With a struct With a return from a DLL
|
|
|
Post by Walt Decker on Apr 20, 2023 8:58:48 GMT -5
Well, looks like no one wants to tackle this, so here goes. Everything in memory has an address including compiled code. WINSTRING() returns a string only and is parially attached to LB's STRUCT concept and the address obtained from an element of the structure. However, WINSTRING() does not have to use a STRUCT element as long as the memory address is valid. I imagine it could use the address returned from the CALLBACK instruction but, unless one used the string in a hex editor, it would be meaningless. That being said, let's take a look at a short structure. STRUCT tDmy, _ TxtIn$ AS PTR, _ TxtLne AS LONG tDmy.TxtIn$.struct does not contain ANSI characters, it contains the the beginning address of an ANSI string. For example, if you do PRINT tDmy.TxtIn$.struct you will get zero. However, if you do: Ansi$ = "this is a string" tDmy.TxtIn$.struct = Ansi$ PRINT tDmy.TxtIn$.struct you will get the beginning address(some number) of Ansi$, not the contents of Ansi$. To illustrate the above I put together this little demo. ' STRUCT tDmy, _ TxtIn$ AS PTR, _ TxtLen AS LONG
PRINT "The value of tDmy.TxtIn$.struct is "; tDmy.TxtIn$.struct RetVal = 0 RetVal = FN.AddText()
PRINT "The value of tDmy.TxtIn$.struct is "; tDmy.TxtIn$.struct
PRINT "WINSTRING(tDmy.TxtIn$.struct) is "; WINSTRING(tDmy.TxtIn$.struct) PRINT "The string is "; tDmy.TxtLen.struct; " characters long"
END
'------------------------------------ '------------------------------------
FUNCTION FN.AddText()
TxtIn$ = "Hello world!" tDmy.TxtIn$.struct = TxtIn$ tDmy.TxtLen.struct = LEN(TxtIn$)
END FUNCTION '
Above I mentioned that WINSTRING() is partially tied to LB's STRUCT but can use any valid memory address. To illustrate this I created a little 7 Kb dll and the following code. The Dll has three little ditties that it ranomly selects and returns the memory address of the text. ' OPEN "DEMO.DLL" FOR DLL AS #DMO
FOR I = 1 TO 10 CALLDLL #DMO, "FN_Demo", Addr AS ULONG PRINT "Memory address is "; Addr PRINT "WINSTRING() = "; WINSTRING(Addr) TIMER 200, [NXT.I] WAIT [NXT.I] TIMER 0 NEXT I
CLOSE #DMO END '
By using WINSTRING() in combination with API function GetObject() (Gdi32.dll) one should be able to blit the bgr bits of a memory bitmap into a string and then manipulate those bits any way one chooses.
|
|