?
Solved

BCPP 3.1 - Trapping the Enter key

Posted on 1997-06-06
12
Medium Priority
?
5,889 Views
Last Modified: 2013-12-26
I am attempting to treat the Enter key as a Tab key in BCPP 3.1.  The PreProcessMsg is not available in this version.

I think the answer lies in overriding the DispatchAMessage routine but I can't figure out how to call the TWindowsObject::DispatchAMessage routine from my routine.

The declaration is:

virtual void DispatchAMessage(WORD AMsg, RTMessage AMessage, void (TWindowsObject::* _FAR) (RTMessage));

I cannot figure out how to pass the third argument to the standard TWindowsObject routine.

Maybe I'm on the wrong track anyway.  My goal is catching the Enter key in a modal dialog.

Many thanks!

-Keith

0
Comment
Question by:keith_mc
[X]
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
  • 5
  • 2
  • 2
  • +3
12 Comments
 
LVL 3

Expert Comment

by:gaohong
ID: 1299258
Hi, I could not recall the exact name of Key Down message in BC++
3.1. Anyway, you have to handle WM_KEYDOWN message and check
if it is VK_RETURN in your window callback, then call the same
function to handle tab key.  Check out the RTMessage structure and SDI, same semantics for WPARAM and LPARAM.

BTW, better to move to OWL2.0, and it is only cost 50$ in most
of stores to get BC++4.52, which is pretty good.

Hope this helps
gary xie
0
 

Author Comment

by:keith_mc
ID: 1299259
I certainly do appreciate the response.  However, I don't think that the answer is valid.  I've tried overriding the wm_keydown routine in order to grab the Enter key.  However, wm_keydown is never called in response to the Enter key in a dialog.  The actual winsight message trace upon pressing the Enter key is:

31D0 "Enhancement"  WM_USER+0x0000  Sent  wp=0000  lp=0000:0000
31D0 "Enhancement"  WM_USER+0x0000  Returns 1397424129 (534B:0001)
31D0 "Enhancement"  WM_COMMAND  Sent  Notify BN_CLICKED  from hwnd 3634  id 1

Perhaps the key is in catching the second WM_USER message.


0
 
LVL 3

Expert Comment

by:gaohong
ID: 1299260
As I said I do not have bc3.1 here. Check your comments, WM_USER
gives me a little hint. If memory serves me, you should have
these in .h file.

  virtual void  WMKeyDown(RTMessage Msg)
                = [WM_FIRST + WM_KEYDOWN];

In case you are not using WM_FIRST.

If you write in SDK Window API, in your window procedure, you have to catch WM_KEYDOWN message, I see no reason, BC3.1 would alter that.
 
If it still does not do what you want, reject me again

good luck

0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:keith_mc
ID: 1299261
Hello,

My declaration is as you proposed, WM_FIRST included.

virtual void WMKeyDown(RTMessage Msg)= [WM_FIRST + WM_KEYDOWN];

In a derived TWindow, this function catches all key presses.  In a dialog however, the keypresses are directed to the child elements of the dialog or they are translated into button commands.  If I run Winsight and watch the message flow starting from the moment before the Enter key is pressed, I will never see a WM_KEYDOWN message.  This leads me to believe that I am not failing to catch the WM_KEYDOWN message.  Rather, I think that is not being sent.  Something is translating the Enter key into a BN_CLICKED message before I get a shot at it.  I can show you the entire Winsight log if it might help.

I do appreciate you thoughts on this!

-Keith

0
 
LVL 6

Expert Comment

by:jpk041897
ID: 1299262
I haven't used OWL in over 6 months and 3.1 in over 3 years:-)

But, from what I recall,  the WM_KeyDown message could not be proccesed at all. What you had to do was to use Borland controls and process BBN_SETFOCUS messages, these messages indicate that a given control gained focus by an action that was not generated by a mouse. You could then trap the standard behaviour of the Default push button to send a WM_KEYDOWN message if a given flag, controlled by the BBN_SETFOCUS message, has been set.

As I said erlier, I'm rather rusty with OWL, so I'm not even sure if I'm mixing OWL versions here so I'm posting as a comment.

Please let me know if I remembered correctly.
0
 

Author Comment

by:keith_mc
ID: 1299263
Thanks for the BBN_SETFOCUS suggestion.

However, I think that we're talking different versions of OWL.  You can trap the WM_KEYDOWN message.  In fact, I rely on this to accomplish other tasks.  And, there is no BBN_SETFOCUS message.  The message flow is WM_USER, WM_USER and BN_CLICKED.  Perhaps there is a way to examine the WM_USER messages for a clue as to whether the BN_CLICKED message was generated by Enter or the mouse.  Why are these WM_USER messages sent anyway?  And why is there no WM_KEYDOWN message generated?  It appears that Windows is translating the Enter key into a BN_CLICKED message without giving me a change to intercept it.  Again, the messages generated upon pressing the Enter key are:

WM_USER+0x0000 Sent wp=0000 lp=0000:0000
WM_USER+0x0000 Returns 1397424129 (534B:0001)
WM_COMMAND Sent Notify BN_CLICKED from hwnd 3634 id 1

I know that an upgrade will solve this problem.  However, I've been working on this application for 5 months and I don't relish the idea of changing tools when I am so close to finishing.  

Besides, I'm curious.  I've found that you learn a lot of peripheral things while pursuing a problem like this.

Sincere thanks for the help!


0
 
LVL 6

Expert Comment

by:jpk041897
ID: 1299264
I seem to recall that not all Windows messages that should have were processed by OWL 1. You sometimes had to process messages in an alternate method.

I belive it had to do with overriding WMCooman, setting up a message loop to test for WM_KEYDOWN and calling deafult proccesing if it was any other message.

I belive it was the same technique as used to change the background color of dialog box.

Hope this helps.
0
 

Author Comment

by:keith_mc
ID: 1299265
I think you may have given me a good clue here.  I'll work with the WMCommand routine and see what I can do.  I'll let you know.

Thanks
0
 
LVL 2

Expert Comment

by:JensUniweb
ID: 1299266
The reason that you don't get the WM_KEYDOWN for VK_RETURN in your dialog box is because the default Dialog message handler is intercepting it. You can make your messagehandler the one recieving the messages first. Then send the once you don't handle to the default dialog message handler. I don't remember how this is done in OWL 1.0. But there is a standard windows function for it.I can check my old manualls for you. It will take untill tomorrow.
0
 

Accepted Solution

by:
ocurance earned 210 total points
ID: 1299267
I remember trapping the Enter key in a very tricky fashion in BC++3.1.  I would create an OK button, enable it but hide it.  Pressing enter on this dialog always activates it's handler, so in a sense you've just trapped the enter key.  Not as complex as you were looking for, but it always worked for me!

Good luck,
Roger.
0
 

Author Comment

by:keith_mc
ID: 1299268
Thanks.  Using a hidden Ok button would work from a functional standpoint.  However, I would much rather figure out how to allow my dialogs to intercept the keypresses.  This would also be useful in other cases, such as responding to function keys in a dialog.  

There was a comment from JensUniweb about this.  Any followup?
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

770 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