|
YOUR FEEDBACK
|
TOP MICROSOFT .NET LINKS Feature PBDJ Feature — Working with Windows Messages in PowerBuilder
Solving practical problems
By: Ludwin Feiten
Mar. 28, 2006 12:00 PM
PowerBuilder provides the send() function to send messages to the Windows objects. The information about its usage is fragmentary and widely dispersed throughout the help and manuals. Since searching for this information was quite tedious, I decided to write down what information I could gather.
In addition to using the Windows functions to call the windows API, we can also send messages to Windows controls. Sometimes it's helpful to send messages to the controls since they're triggered by the operating system, for example, an emulated mouse click, a keystroke, or any other event. In Windows, messages are sent with the Windows function: SendMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam ); And PowerBuilder script provides the same functionality in the send function. The syntax is: Send ( handle, message#, lowword, long ) With:
Here are same examples from the PowerBuilder helpfile:
This statement scrolls the window w_emp up one page: We see that it's quite easy to send Windows messages if you know the message numbers and parameters, but how do you know them? This seemed (to me) to be the most difficult part. I've looked through all the help files but couldn't find a place that contains all the information about the numbers and parameters. So I started searching. What I found: it's not too difficult to find the information you need about messages when you know where to search. You need access to the Windows API help, which can be found at http://msdn.microsoft.com/library/. Here you have a description of all the messages you can send. You'll also need the winuser.h file. On most installations it can be found at: C:\Program Files\Sybase\Shared\PowerBuilder\cgen\h\nt\winuser.h. (A more complete version is the winuser.h that comes with MS Visual Studio.) While the API help uses constants like WM_KEYDOWN in its description, there are numerical equivalents in the winuser.h. I could go on by just placing a table with the event IDs and parameters for you. However, as the saying goes: Give a man a fish, and you have fed him for today. Teach a man to fish, and he will sit in a boat and drink beer all day (or teach a man to fish, and you have fed him for a lifetime.) So get your fishing rod (the "fish" will be at the end of the article ;-)) and go for the beer (or let us solve some practical problems).
How to Do It We have to look in the Windows API help. This is a challenge and you need luck as well as a keen understanding of the Windows API help. I've found that it's not that well structured and intuitive. However, if you know that we are looking for a Notification (see Figure 1), searching with "Key pressed notification" brings us near enough to find "WM_KEYDOWN" at: Win32 and COM Development > User Interface > Windows User Interface > User Input > Keyboard Input > Notification This is the adequate system message, which is described as follows:
#define WM_KEYDOWN 0x0100 This is the definition of the Windows constant WM_KEYDOWN as hex 0x0100, which is dec 256. (I use the windows Calculator in the scientific view for conversion.) wParam has to be the ASCII-Code for the Tab-Key which is 9. lParam is set to Zero. Our call is: send(Handle(this), 256,9, long(0,0))
Scroll a Window Win32 and COM Development > User Interface > Windows Shell > Windows Controls > Individual Control Information > Scroll Bars > YOUR FEEDBACK
MICROSOFT .NET LATEST STORIES
SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS SUBSCRIBE TO OUR RSS FEEDS & GET YOUR SYS-CON NEWS LIVE!
|
SYS-CON FEATURED WHITEPAPERS MOST READ THIS WEEK BREAKING NEWS FROM THE WIRES
|
||||||||||||||||||||||||||||||||||||