|
Post by turtleman on Jul 17, 2024 3:17:05 GMT -5
Yes, the code runs fine! I need to modify it for the textbox to default to white upon ENTER and incorporate additional color change as determined by the W and L results, but it does what I want. Thanks!
As has happened a few times, the overall code has been modified so many times, and so much has been learned along the way that a major redo is in order.
|
|
|
Post by turtleman on Jul 23, 2024 6:03:16 GMT -5
Another strange textbox observation:
I just noticed that none of the textboxes in the jpeg previously shared display the cursor when clicked. The textboxes permit entering data and function correctly – just no cursor and I don't have a clue why. Textboxes in other windows display the blinking cursor as normal. Any suggestions what could be behind this?
UPDATE: the textboxes that display the curser properly are on what I call the Main Control Window. The textboxes I'm asking about are in another window that's opened from the other. Maybe that has something to do with this?
NEVER MIND – I finally read the fine print: "Dead Textbox Problem
If it appears that no text can be typed into a textbox, it may be that the textbox is not high enough to display the current font. Try making the textbox higher, or giving it a font command for a smaller font. Textboxes can also appear to be dead if too many controls are placed on a window."
Merely increasing the height from 20 to 21 solved the problem. However, I'd rather keep the textbox spacing and reduce the font size … if I can figure out how.
|
|
|
Post by turtleman on Jul 29, 2024 5:42:05 GMT -5
Another textbox color-related question:
I have a dozen textboxes textboxes with the same coordinates having 2 different background colors. The textboxes usually have white backgrounds, but any one (and only one at a time) can switch to a yellow background. !hide and !show commands select which one turns yellow, while resetting the others to white. That much works, as does being able to enter and store new data into the white textboxes!
However, I've so far been unsuccessful trying to enter and save data entered into the selected (yellow) textbox. In other words, I'm trying to enter and save data in white OR yellow textboxes.
Any hints would probably save me hundreds of lines of code and another week of frustration. Thanks!
|
|
|
Post by Rod on Jul 29, 2024 8:25:43 GMT -5
If you are using hide and show you will need to use the correct handle, you have two textboxes. The contents will need copied and moved between the two boxes.
|
|
|
Post by Walt Decker on Jul 29, 2024 10:19:54 GMT -5
Pick a box with mouse. enter data. press ENTER to move to next box
' [DECLARE.GLOBALS]
GLOBAL BnClicked, _ Hilited
GLOBAL ForeClr$, _ BackClr$
DIM NormCtrl$(2, 1) DIM HideCtrl$(2, 1) DIM Win$(2, 1) DIM Loss$(2, 1)
[INIT.GLOBALS] ForeClr$ = "TEXTCLR" BackClr$ = "BKGND"
BnClicked = 0 Hilited = 0
[VARBS] SS.CENTER = 1 'static SS.RIGHT = 2 SS.SUNKEN = HEXDEC("&H00001000")
VK.RETURN = HEXDEC("&H0D") 'virtual key code
RetVal = 0 AryElm = 0 Wager = 0 Lost = 0 TotalW = 0 TotalL = 0 CtlHnd = 0
Bet$ = "" CtlTag$ = ""
[DEF.CONTROLS] STYLEBITS #DMO.STABET, SS.CENTER, 0, 0, 0 STYLEBITS #DMO.STA1, SS.RIGHT, 0, 0, 0 STYLEBITS #DMO.STA2, SS.RIGHT, 0, 0, 0 STYLEBITS #DMO.STA3, SS.RIGHT, 0, 0, 0 STYLEBITS #DMO.STAW, SS.CENTER, 0, 0, 0 STYLEBITS #DMO.STAL, SS.CENTER, 0, 0, 0 STYLEBITS #DMO.STAW1, SS.CENTER OR SS.SUNKEN, 0, 0, 0 STYLEBITS #DMO.STAW2, SS.CENTER OR SS.SUNKEN , 0, 0, 0 STYLEBITS #DMO.STAW3, SS.CENTER OR SS.SUNKEN, 0, 0, 0 STYLEBITS #DMO.STAL1, SS.CENTER OR SS.SUNKEN, 0, 0, 0 STYLEBITS #DMO.STAL2, SS.CENTER OR SS.SUNKEN, 0, 0, 0 STYLEBITS #DMO.STAL3, SS.CENTER OR SS.SUNKEN, 0, 0, 0
STATICTEXT #DMO.STABET, "BET", 25, 5, 35, 18 STATICTEXT #DMO.STA1, "1", 5, 30, 10, 18 STATICTEXT #DMO.STA2, "2", 5, 55, 10, 18 STATICTEXT #DMO.STA3, "3", 5, 85, 10, 18 STATICTEXT #DMO.STAW, "W", 70, 5, 35, 18 STATICTEXT #DMO.STAL, "L", 110, 5, 35, 18 STATICTEXT #DMO.STAW1, "", 70, 30, 35, 18 STATICTEXT #DMO.STAW2, "", 70, 55, 35, 18 STATICTEXT #DMO.STAW3, "", 70, 85, 35, 18 STATICTEXT #DMO.STAL1, "", 110, 30, 35, 18 STATICTEXT #DMO.STAL2, "", 110, 55, 35, 18 STATICTEXT #DMO.STAL3, "", 110, 85, 35, 18
TextboxColor$ = "yellow" TEXTBOX #DMO.TXBH1, 25, 26, 35, 20 TextboxColor$ = "white" TEXTBOX #DMO.TXBN1, 25, 26, 35, 20 TextboxColor$ = "yellow" TEXTBOX #DMO.TXBH2, 25, 52, 35, 20 TextboxColor$ = "white" TEXTBOX #DMO.TXBN2, 25, 52, 35, 20 TextboxColor$ = "yellow" TEXTBOX #DMO.TXBH3, 25, 82, 35, 20 TextboxColor$ = "white" TEXTBOX #DMO.TXBN3, 25, 82, 35, 20
[DEF.WINDOWS] WindowWidth = 230 WindowHeight = 200 UpperLeftX = 200 UpperLeftY = 200
OPEN "TEXT DEMO" FOR WINDOW AS #DMO
[SAVE.CONTROL.HANDLES] FOR I = 0 TO 2 CtlTag$ = "#DMO.TXBN" + STR$(I + 1) NormCtrl$(I, 0) = STR$(HWND(#CtlTag$)) NormCtrl$(I, 1) = CtlTag$
CtlTag$ = "#DMO.TXBH" + STR$(I + 1) HideCtrl$(I, 0) = STR$(HWND(#CtlTag$)) HideCtrl$(I, 1) = CtlTag$ #CtlTag$, "!HIDE" NEXT I
FOR I = 0 TO 2 Win$(I, 0) = "#DMO.STAW" + STR$(I + 1) Win$(I, 1) = "0" Loss$(I, 0) = "#DMO.STAL" + STR$(I + 1) Loss$(I, 1) = "0" NEXT I
[SET.NORMAL.CONTROL.COLORS]
[INITIALIZE.WINDOW] #DMO, "TRAPCLOSE END.DMO"
[SCAN.LOOP] CALLDLL #kernel32, "Sleep", 120 AS LONG, RetVal AS VOID
Wager = FN.CheckFocus(Wager)
IF Wager THEN AryElm = Hilited - 1 Lost = RND(0)
IF Lost > 0.49 THEN CtlTag$ = Win$(AryElm, 0) TotalW = VAL(Win$(AryElm, 1)) + 1 Win$(AryElm, 1) = STR$(TotalW) #CtlTag$, STR$(TotalW) ELSE CtlTag$ = Loss$(AryElm, 0) TotalL = VAL(Loss$(AryElm, 1)) + 1 Loss$(AryElm, 1) = STR$(TotalL) #CtlTag$, STR$(TotalW) END IF
AryElm = Hilited
IF AryElm > 2 THEN AryElm = 0 END IF
CtlTag$ = NormCtrl$(AryElm, 1) #CtlTag$, "!SETFOCUS" BnClicked = 0 END IF
SCAN
GOTO [SCAN.LOOP]
WAIT
'-------------------------------- '--------------------------------
SUB END.DMO Win$
CLOSE #DMO END END SUB
'-------------------------------- '--------------------------------
FUNCTION FN.CheckFocus(Wager)
VK.RETURN = HEXDEC("&H0D") 'virtual key code
Bet$ = ""
I = 0
CtlHndl = 0 RetVal = 0 CtlElm = 0
Sctl$ = "" Hctl$ = "" TxtIn$ = ""
CALLDLL #user32, "GetFocus", CtlHndl AS ULONG
IF Hilited THEN CtlElm = Hilited - 1 Ctl$ = HideCtrl$(CtlElm, 1) #Ctl$, "!CONTENTS? Bet$" RetVal = FN.KeyState(VK.RETURN)
IF RetVal = VK.RETURN THEN #Ctl$, Bet$ Ctl$ = NormCtrl$(CtlElm, 1) #Ctl$, Bet$ FN.CheckFocus = VAL(Bet$) EXIT FUNCTION END IF END IF
FOR I = 0 TO 2
IF CtlHndl = VAL(NormCtrl$(I, 0)) THEN IF Hilited > 0 THEN Hctl$ = HideCtrl$(Hilited - 1, 1) Sctl$ = NormCtrl$(Hilited - 1, 1) #Hctl$, "!CONTENTS? TxtIn$" #Sctl$, TxtIn$ #Hctl$, "!HIDE" #Sctl$, "!SHOW" #Sctl$, TxtIn$ END IF
IF BnClicked THEN EXIT FUNCTION
Sctl$ = HideCtrl$(I, 1) Hctl$ = NormCtrl$(I, 1) #Hctl$, "!HIDE" #Sctl$, "!SHOW" #Sctl$, "!SETFOCUS" BnClicked = VAL(HideCtrl$(I, 0)) Hilited = I + 1 END IF NEXT I
END FUNCTION
'-------------------------------- '--------------------------------
FUNCTION FN.KeyState(Key)
VK.RETURN = HEXDEC("&H0D") VK.CONTROL = HEXDEC("&H11")
Mask = HEXDEC("&H8000")
Pressed = 0
CALLDLL #user32, "GetAsyncKeyState", Key AS ULONG, Pressed AS USHORT
IF (Pressed AND Mask) THEN FN.KeyState = Key EXIT FUNCTION END IF
CALLDLL #user32, "GetAsyncKeyState", VK.CONTROL AS ULONG, Pressed AS USHORT
IF (Pressed AND Mask) THEN CALLDLL #user32, "GetAsyncKeyState", Key AS ULONG, Pressed AS USHORT
IF (Pressed AND Mask) THEN FN.KeyState = Key END IF END IF
END FUNCTION
'-------------------------------- '--------------------------------
'
|
|