Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Friday, November 22, 2024 
 
slxdeveloper.com Community Forums  
   
The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
 Architect Forums - Controls
Forum to discuss usage & tips for SalesLogix controls and other 3rd party ActiveX controls. View the code of conduct for posting guidelines.
Forums RSS Feed


 Back to Forum List | Back to Controls | New ThreadView:  Search:  
 Author  Thread: Disable F2 key
Bill
Posts: 71
 
Disable F2 key Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 12 Sep 06 4:42 PM
fiogf49gjkf0d
I have a date/time edit that I have set the ButtonVisble property to false, the FormatString property to dddddd, and the kind property to dtk2Date. This works fine, my issue is when that field has focus and the user presses the F2 key, the calendar is still able to be used to populate the field. Is there any way of disabling the F2 key for individual screens or individual fields?
[Reply][Quote]
Jeremy Brayton
Posts: 491
Top 10 forum poster: 491 posts
 
Re: Disable F2 key Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 13 Sep 06 3:13 PM
fiogf49gjkf0d
You can use the OnKeyPress event for that control and have it disable based on the Key value. Something like this would work:

Sub OnKeyPress(Sender, ByRef Key)
if (Key = 137) then
Key = 0
end if
End Sub

This checks to make sure they key pressed is F2 (ordinal 137) and by replacing it with 0, the key doesn't register with the control.

You can use this technique for editboxes where you don't want certain keys pressed. For instance, if the FormatType is set to ftInteger and you only want integers to register when typed you would use this:

if (not IsNumeric(Chr(Key))) then
Key = 0
end if
[Reply][Quote]
Bill
Posts: 71
 
Re: Disable F2 key Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 13 Sep 06 4:14 PM
fiogf49gjkf0d
Based on what I have read, the OnKeyPress triggers while no controls have focus and can fire multiple times if the user holds the key.
[Reply][Quote]
Jeremy Brayton
Posts: 491
Top 10 forum poster: 491 posts
 
Re: Disable F2 key Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 13 Sep 06 5:53 PM
fiogf49gjkf0d
There's OnKeyPress for the FORM and OnKeyPress for the CONTROL. You want to define the OnKeyPress event of the control you wish to restrict. They can hold F2 down all they want and the control won't respond to it, though the event will be raised repeatedly. As long as you keep the algorithm simple, performance shouldn't be a problem even if people hold down restricted keys. My algorithms do way more than what I gave you and I've yet to notice a performance hit when I hold keys down.
[Reply][Quote]
Bill
Posts: 71
 
Re: Disable F2 key Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 25 Sep 06 1:53 PM
fiogf49gjkf0d
I added the code to disable the F2 key in the OnKeyPress routine and I was still able to access the control after adding the code. I wanted to see if the sub routine was getting called so I also added a message box so it would display when the control was accessed through the F2 key. It appears as if the OnKeyPress sub routine isn't even being called because the message box isn't getting displayed when I access the control by pressing F2. Below is the code for the sub routine:

Sub dtecontractKeyPress(Sender, ByRef Key)
msgbox "here" & key
if (Key = 137) then
Key = 0
end if
End Sub
[Reply][Quote]
Jeremy Brayton
Posts: 491
Top 10 forum poster: 491 posts
 
Re: Disable F2 key Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 25 Sep 06 9:21 PM
fiogf49gjkf0d
What version of SalesLogix?

This is definitely not "functioning as designed" because the control's OnKeyPress event should trap all keypresses, including ones that modify the control's behavior. This may be outside of SLX's control though as I believe their controls are thin wrappers around Microsoft's.

What about hooking the Form's OnKeyPress event and only disabling F2 for the controls you wish to block? It probably won't work due to the limitations you mentioned (a control can't be in focus) but it's the only thing I can think of barring a service pack or hotfix that addresses the issue specifically.
[Reply][Quote]
Timmus Agersea
Posts: 328
 
Re: Disable F2 key Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 25 Sep 06 9:49 PM
fiogf49gjkf0d
I believe there are keys that are not captured by the keypress event. I also believe this applies to all 6.x versions (possibly earlier versions too).

The following are examples of keys that do not raise the event: delete, tab, arrow keys, function keys, pageup, home, etc.

Timmus
[Reply][Quote]
Timmus Agersea
Posts: 328
 
Re: Disable F2 key Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 25 Sep 06 10:05 PM
fiogf49gjkf0d
Bill,

I forgot to mention that you probably just need to set the ReadOnly property to true for the DateTimeEdit. That will prevent the user from launching the popup calendar. Along with the HideButtonIfReadOnly property you should get the behavior you want.

Timmus
[Reply][Quote]
 Page 1 of 1 
  You can subscribe to receive a daily forum digest in your user profile. View the site code of conduct for posting guidelines.

   Forum RSS Feed - Subscribe to the forum RSS feed to keep on top of the latest forum activity!
 

 
 slxdeveloper.com is brought to you courtesy of Ryan Farley & Customer FX Corporation.
 This site, and all contents herein, are Copyright © 2024 Customer FX Corporation. The information and opinions expressed here are not endorsed by Sage Software.

code of conduct | Subscribe to the slxdeveloper.com Latest Article RSS feed
   
 
page cache (param): 11/22/2024 11:44:15 PM