Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Code works in object on form but not as class
Message
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Miscellaneous
Thread ID:
00158755
Message ID:
00160103
Views:
16
>I came up with the following code for a combobox to allow UPARROW and DNARROW to exit the control instead of scrolling the choices when set to .Style=2. The code works fine if put in a combobox used on a form. I then created a combobox class with this code and when used in a form the UPARROW works fine but the DNARROW blanks out the .Value before moving. The code is as follows:
>
>
>In the Combobox.KeyPress I put the following
>IF nKeyCode=5 OR nKeyCode=24     &&UPARROW or DNARROW
>	This.Style=0                                 &&Set Style to Dropdown Combo
>	DODEFAULT()
>ENDIF
>
>In the Combobox.Valid I put
>This.Style=2           &&Set Style to Dropdown List
>
>
>I did a Trace Events and discovered the following:
>
>**Code directly in combobox on form
>myform.KeyPress(24,0)
>myform.mycombo.KeyPress(24,0)
>myform.mycombo.text1.KeyPress(24,0)
>myform.Paint()
>myform.KeyPress(24,0)
>myform.mycombo.Valid()
>myform.mycombo..text1.Destroy()
>myform.mycombo.LostFocus()
>
>**Code in class/ class used on form
>myform.KeyPress(24,0)
>myform.mycombo.KeyPress(24,0)
><strong>myform.mycombo.text1.KeyPress(0,8)
>myform.Paint()
>myform.mycombo.InteractiveChange()</strong>
>myform.mycombo.text1.KeyPress(24,0)
>myform.Paint()
>myform.KeyPress(24,0)
>myform.mycombo.Valid()
>myform.mycombo..text1.Destroy()
>myform.mycombo.LostFocus()
>
>
>3 extra events, shown in bold, are occurring when used as a class. I know these are the cause of the problem but I have no idea why they are occurring. Any help greatly appreciated, I'm going bald pulling my hair out over this one. TIA

Hi there,

I think you have dropped combo on a Container Class because as you said above
it goes to myform.mycombo..text1.Destroy(). Since Combo is not a container object, there should not be any .text1 reference.

If you want to create a pure combo box class, recreate it and base it on ComboBox not on any Container Class.
- Jayesh
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform