Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Disabling Caps Lock key in Powerbuilder Application

Posted on 2004-04-20
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?
Question by:QueenKretee
  • 3
  • 3
LVL 15

Expert Comment

ID: 10871301
See links below:
Disabling a Keystroke in A DataWindow Control

Triggering the Print Screen Key and Other Keys Dynamically

LVL 18

Expert Comment

ID: 10875419

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'


Author Comment

ID: 10877000
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?
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.


Author Comment

ID: 10877026
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!
LVL 15

Accepted Solution

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


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"

//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")
 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"

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


Author Comment

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

Expert Comment

ID: 10878263
Glad to help!!!

Namasi Navaretnam

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
error when compiling my project in eclipse luna 30 448
Netbeans Open project initial dir 5 46
eclipse apache tomcat admin console 52 121
JavaFX TableView not displaying correctly 3 54
Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
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.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…

789 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