Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Locking Controls

Status
Not open for further replies.

cpaige

Programmer
Jun 19, 2000
86
CA
&nbsp;&nbsp;&nbsp;&nbsp;Microsoft has done something good and created 2 controls The Date Time Picker and the Mask Edit control.&nbsp;&nbsp;Both do they'er job farely well, but just one thing.&nbsp;&nbsp;They don't have a locked feature. On most of the VB controls there is a setting that allows a control to get focus, but is read only.<br><br>I wish to have this for any control.&nbsp;&nbsp;Deos anyone have any ideas?&nbsp;&nbsp;I have tried changing the style through API calls, but that didn't work all the time. Right now I replace the DTP with a combo box that is locked.&nbsp;&nbsp;<br><br>Does anyone have a better solution? <p>Clayton T. Paige<br><a href=mailto:cpaige@home.com>cpaige@home.com</a><br><a href= Snail</a><br>Clayton T. Paige<br>
Programmer Extraordinaire <br>
========================================================<br>
"Who General Failure? and Why is he reading my disk drive?"
 
I believe that is '&lt;control&gt;_<b>Got</b>Focus' (an event). To prevent a user from making an entry using that control, say when the system clock says they should be on a break, I'd use...<br><br>Sub Control1_GotFocus()<br><br>&nbsp;if ItsAwfullyCloseToBreakTime then<br>&nbsp;&nbsp;&nbsp;&nbsp;Control2.SetFocus<br>&nbsp;End If<br><br>End Sub<br><br>They'll never enter anything in Control1 when they're supposed to be at the snack machine ! <p>Amiel<br><a href=mailto:amielzz@netscape.net>amielzz@netscape.net</a><br><a href= > </a><br>
 
What control is control2?<br>I have thought of this solution and the problem I have is determining what was the last control to get focus.&nbsp;&nbsp;It did for awhile have every control on the form set it self to an object variable.&nbsp;&nbsp;Then I would just set focus to that when the DTP gotfocus, but that takes alot of extra work and does many strange things. <p>Clayton T. Paige<br><a href=mailto:cpaige@home.com>cpaige@home.com</a><br><a href= Snail</a><br>Clayton T. Paige<br>
Programmer Extraordinaire <br>
========================================================<br>
"Who General Failure? and Why is he reading my disk drive?
 
No, here, were only concerned that the conditions, (<i>what ever they may be</i>), have been met <b><u>prior</u></b> to the Date Time control getting the focus&nbsp;&nbsp;(control_GotFocus), and taking user input.<br><br>If the condition has not been met when the GotFocus event for that control occours; then set the Focus to the next control, the previous control, a list box, the Exit button, the Cancel button or whatever else will do no harm and is appropriate during user input,... maby even a <b></i>set&nbsp;&nbsp;focus to a Help button</b></i> that will provide the user with instructions on how they should proceed after failing to do whatever is required.<br><br>Sub ControThatlIWishToProtect_GotFocus()<br>&nbsp;if ConditionThatNeedsToBeMet = False then<br>&nbsp;&nbsp;&nbsp;&nbsp;AnyOtherControl.SetFocus<br>&nbsp;End If<br>End Sub<br><br>The effect is that the control is 'locked' (cannot accept input) until the condition is met.<br> <p>Amiel<br><a href=mailto:amielzz@netscape.net>amielzz@netscape.net</a><br><a href= > </a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top