Doug Lindauer
Programmer
I'm running VFP9 SP2 on a Windows 7 system.
I'm adding text boxes and check boxes to a container on a form at run time. I'm doing it this way, instead of hard coding the boxes because these boxes will be based on items in a table. The table can be edited by the user to accommodate future changes. The form and the container are created visually at design time using the Form Designer.
But I would like to utilize GotFocus and LostFocus methods on the check boxes. The reason I want to do this is that at runtime there is no indication that the check box has the focus. I know the first question that comes to mind is why doesn't the user just click the box with the mouse? Well the user requested a data entry screen where she doesn't have to take her hands off the keyboard and click around with a mouse.
But then I realized that, other than creating a custom class with predefined methods, I don't know how to add method code when you add check boxes like I'm doing. Seems like there should be a way but after reading Microsoft's programmer's guide on addobject, I'm not sure. So I'm hoping the VFP gurus here can help me out. If it can't be done without creating a class ... well that's just one more thing I'll have learned about VFP.
If people are curious, I'm including a little snippet from the code I'm using in the form's Init to create the check boxes. vCEACTS is a view which I step through:
I'm adding text boxes and check boxes to a container on a form at run time. I'm doing it this way, instead of hard coding the boxes because these boxes will be based on items in a table. The table can be edited by the user to accommodate future changes. The form and the container are created visually at design time using the Form Designer.
But I would like to utilize GotFocus and LostFocus methods on the check boxes. The reason I want to do this is that at runtime there is no indication that the check box has the focus. I know the first question that comes to mind is why doesn't the user just click the box with the mouse? Well the user requested a data entry screen where she doesn't have to take her hands off the keyboard and click around with a mouse.
But then I realized that, other than creating a custom class with predefined methods, I don't know how to add method code when you add check boxes like I'm doing. Seems like there should be a way but after reading Microsoft's programmer's guide on addobject, I'm not sure. So I'm hoping the VFP gurus here can help me out. If it can't be done without creating a class ... well that's just one more thing I'll have learned about VFP.
If people are curious, I'm including a little snippet from the code I'm using in the form's Init to create the check boxes. vCEACTS is a view which I step through:
Code:
thisform.cntACTIVITIES.Height = max(150, 30 +30 * mCOUNT)
mTOP = 25
mLEFT = 40
for mCTR = 1 to mCOUNT
mCONTROL= alltrim(vceacts.CONTROLNAME)
mENABLED= empty(vceacts.PAIDAMOUNT)
mNAME = "chkPerm"+mCONTROL && e.g. ' Paintball' becomes chkPermPAINT
thisform.cntACTIVITIES.AddObject(mNAME,"CheckBox")
with thisform.cntACTIVITIES.&mNAME
.backcolor= thisform.cntACTIVITIES.BackColor
.Visible = .t.
.height = 25
.width = 25
.Caption = ""
.top = mTOP
.left = mLEFT
.FontBold = .t.
.Alignment= 2
.Value = iif( empty(vceacts.PAIDAMOUNT), 0, 1)
.Enabled = mENABLED
.DisabledForeColor = 0
.DisabledBackColor = rgb(210,210,210)
endwith
mTOP = mTOP +25
skip
next