Solved

Disabling Caps Lock key in Powerbuilder Application

Posted on 2004-04-20
7
1,388 Views
Last Modified: 2013-12-26
I have several datawindows in which users enter data such as names.  I want to prevent them from using the Caps Lock key completely.  I attempted coding for a pbm_dwnkey event.  However, this only works when the user presses the Caps Lock key, not when it is "on".  I have considered annoying them by offering a correction using WordCap() every time a field is entered in all caps.  However, this would likely make some people pretty upset.  So, is this possible?
0
Comment
Question by:QueenKretee
  • 3
  • 3
7 Comments
 
LVL 15

Expert Comment

by:namasi_navaretnam
ID: 10871301
See links below:
Disabling a Keystroke in A DataWindow Control
http://www.sybase.com/detail?id=44465

Triggering the Print Screen Key and Other Keys Dynamically
http://www.sybase.com/detail?id=47760

regards-
0
 
LVL 18

Expert Comment

by:diasroshan
ID: 10875419
hi,

why do u want to disable caps lock...
...as i understand u want the user to enter only in lowercase...
...in that case why don't u set the edit properties of all ur column to lowercase (Case option)
Properties---> Edit----> Case .... to 'lower'

Cheers,
Rosh
0
 

Author Comment

by:QueenKretee
ID: 10877000
Rosh-
My users enter a lot of proper names.  Say we had Bob Smith.  I would want it just like this: Bob Smith.  Not bob smith or BOB SMITH.  I have considered using the WordCap() function.  However, then I may run into another problem...I get incorrect results with a name like McDonald.  Any other suggestions Rosh?
Cheers!
0
ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

 

Author Comment

by:QueenKretee
ID: 10877026
Namasi-
I see where we're going with the two suggestions that you made.  However, how can I tell when the user has the caps lock key "on"?  The dwnkey event only triggers when the key is pressed, not when the key is already "on".  Is there some other way of determining if caps lock is on or off?
Thank you in advance!
Kristi
0
 
LVL 15

Accepted Solution

by:
namasi_navaretnam earned 500 total points
ID: 10877665
Kristi, Try these functions:

http://www.sybase.com/detail?id=44545

GetKeyboardState( ) & SetKeyboardState( )
The first function returns the present state of every key on the keyboard into an array of 256 integers based on the characters ASCII representation.  The second function sets the keyboard to the state given in the array.  A zero value represents that the key is not pressed.  There is no PowerBuilder equivalent.

Global External Function:
FUNCTION boolean GetKeyboardState(ref integer kbarray[256])  LIBRARY "USER32.DLL"
FUNCTION boolean SetKeyboardState(ref integer kbarray[256]) LIBRARY "USER32.DLL"
Function ulong GetDC(ulong hwnd) library "user32.dll"

Script:
//GetKeyboardState( )
boolean rtn
integer ipkey[256]
rtn = GetKeyboardState(ipkey)

//SetKeyboardState( )
rtn = SetKeyboardState(ipkey)
if rtn = false then
 Messagebox("Failed","Something went wrong when loading into array")
else
 Messagebox("Successful","Keyboard state is loaded back into buffer")
end if
 

GetKeyState( )
This function returns the present state of a specific key on the keyboard based on that key's ASCII representation.  A zero value represents that the key is not pressed.  There is no PowerBuilder equivalent.

Global External Function:
Function int GetKeyState(integer VirtualKeycode) Library "User32.dll"

Script:
int rtn
rtn = GetKeyState(65)  // 65 = A
if rtn = 0 then
 MessageBox("Key State","Letter 'A' not pressed!")
else
 MessageBox("Key State","Letter 'A'  is pressed!")
end if


regards-
0
 

Author Comment

by:QueenKretee
ID: 10877981
Thank you very much Namasi.  Great information! Very Helpful.
0
 
LVL 15

Expert Comment

by:namasi_navaretnam
ID: 10878263
Glad to help!!!

Namasi Navaretnam
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deletiā€¦
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question