hal9k
Junior Member
Posts: 87
|
Post by hal9k on Sept 17, 2022 13:57:03 GMT -5
Another dumb question... Is there a way to get the contents of a statictext? I couldn't find one. If there is a way, it would save me some time and work and I'm basically lazy...
|
|
|
Post by Walt Decker on Sept 17, 2022 15:06:03 GMT -5
Yep. CtlHndl = HWND(#STATCTRL) WinTxt$ = SPACE(256)
CALLDLL #user32, "GetWindowTextA", CtlHndl AS ULONG, WinTxt$ AS STRUCT, 256 AS LONG,
NumChrs AS LONG
WinTxt$ = LEFT$(WinTxt$, NumChrs)
|
|
|
Post by Walt Decker on Sept 17, 2022 17:12:20 GMT -5
Mr. Pryor, a re-useable method for any window text (form or control):
FUNCTION FN.GetText$(WinHndl) LenTxt = 0 TxtIn$ = ""
CALLDLL #user32, "GetWindowTextLengthA", WinHndl AS ULONG, TxtLen AS LONG TxtLen = TxtLen + 1
TxtIn$ = SPACE$(TxtLen) CALLDLL #user32, "GetWindowTextA", WinHndl AS ULONG, TxtIn$ AS STRUCT, TxtLen AS LONG, TxtLen AS LONG
TxtIn$ = LEFT$(TxtIn$, TxtLen)
FN.GetText$ = TxtIn$ END FUNCTION
|
|
hal9k
Junior Member
Posts: 87
|
Post by hal9k on Sept 17, 2022 17:22:41 GMT -5
Thank you! Once again, I appreciate your help!
|
|
|
Post by Walt Decker on Sept 17, 2022 17:34:32 GMT -5
You are welcome. You might like to take a look at BINARY RA found HERE
|
|
honky
Junior Member
Posts: 63
|
Post by honky on Sept 18, 2022 6:30:40 GMT -5
Without going through "DLL" Just put the content in a string before the statictext.
static$=" The statictext contents" STATICTEXT #handle, static$, xpos, ypos, wide, high
The statictext contents is in static$.
|
|
hal9k
Junior Member
Posts: 87
|
Post by hal9k on Sept 21, 2022 13:58:57 GMT -5
Thanks again!!! Mr. Decker, I've downloaded you zip file and will study it.
Mr. honky, this occurred to me after I posted my question. I frequently make things more difficult than they deserve...
|
|
|
Post by Walt Decker on Sept 22, 2022 16:41:19 GMT -5
Although doable, using variables to retain the contents of static controls is a waste of resources especially if there is more than one or two and the contents will change. It also becomes a nightmare to manage and the code itself becomes more difficult to maintain and/or change.
A companion function for the one I posted above is:
FUNCTION FN.SetWindowTxt(WinHndl, WinTxt$)
RetVal = 0 CALLDLL #user32, "SetWindowTextA", WinHndl AS ULONG, WinTxt$ AS PTR, RetVal AS VOID
END FUNCTION
The above will set the caption of form windows and dialogs along with the title of any control on a form window or form dialog.
|
|
|
Post by Brandon Parker on Sept 22, 2022 19:45:15 GMT -5
This is how I would set up the SetWindowTextA function call. In my opinion, one should utilize the appropriate parameter types even if the return value is not always necessarily used.
Function SetWindowText(hWnd, newWindowText$) newWindowText$ = newWindowText$ + chr$(0) CallDLL #user32, "SetWindowTextA", hWnd As ulong, _ newWindowText$ As ptr, _ SetWindowText As long End Function
{:0)
Brandon Parker
|
|