Solved

Disabling Caps Lock key in Powerbuilder Application

Posted on 2004-04-20
7
1,355 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 

Author Comment

by:QueenKretee
Comment Utility
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
Comment Utility
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
Comment Utility
Thank you very much Namasi.  Great information! Very Helpful.
0
 
LVL 15

Expert Comment

by:namasi_navaretnam
Comment Utility
Glad to help!!!

Namasi Navaretnam
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

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…
Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.

771 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now