|
PowerBASIC Forums
![]() PowerBASIC for Windows
![]() Catching keypress in listbox
|
| next newest topic | next oldest topic |
| Author | Topic: Catching keypress in listbox |
|
Oliver Copp Member |
After extensive research of previous messages posted in this forum, I think I'm more confused than before looking for a pointer as to how to solve my problem *g* The problem seems trivial: I have a listbox and want to catch the DEL key so I can delete an item. This is a lot more natural than having to click a "Delete Item" button, at least to me. Looking for %WM_KEYUP messages, the listbox doesn't seem to be given any. My question now is: do I need to subclass the listbox control (I hope not... never really understood the concept) or is there an easier route to take here? Thanks in advance... again :-) Oliver ------------------ IP: Logged |
|
Raymond King Member |
Hi Oliver, In you callback procedure add:
------------------ rayking@csdsoft.com http://www.csdsoft.com [This message has been edited by Raymond King (edited August 16, 2003).] IP: Logged |
|
Oliver Copp Member |
Thanks, Raymond, but this isn't do the trick for me. CBMSG should be %WM_KEYDOWN, right? I'm not even checking for the proper keycode - just checking for CBMSG %WM_KEYDOWN and no such messages seem to be arriving, regardless of the control, in the callback.
Am I not seeing the forest for the trees :-) ? I thought that when pressing any key anywhere on the form, I should be getting a message box. TIA ! Oliver ------------------ IP: Logged |
|
Raymond King Member |
Sorry Oliver that one is for SDK here is how to do it in DDT.
Enjoy ------------------ rayking@csdsoft.com http://www.csdsoft.com IP: Logged |
|
Edwin Knoppert Member |
I see no other way than a hook on the control. Simpliest version:
------------------ IP: Logged |
|
Kev Peel Member |
quote:
------------------ IP: Logged |
|
Dave Biggs Member |
quote: As Kev shows you don't need to subclass the listbox. Attaching accelerator key definitions to your dialog can get the job done with little fuss. Sometimes subclassing can be very usefull though, so it's worth 'sussing out'. I'm by no means expert here - mine is more a "Monkey see - Monkey do" kind of understanding Subclassing means using the 'SetWindowLong' API function, which changes attributes of a specified
gOldSubClassProc is returned - it's the address of the original procedure for this control. In the SubClassProc those 'missing' messages are available for processing.
Note: Avoid problems by destroying diversion at Dialog End.
Hope that helps! ------------------ [This message has been edited by Dave Biggs (edited August 17, 2003).] IP: Logged |
|
Oliver Copp Member |
Thank you very much Raymond, Edwin and Kev, I really appreciate your helpful advice. But Dave, I have to tell you - I would kiss your feet now if I could ;-) You've managed to explain to me in a few paragraphs what I've been tryíng to find out for a few years now and (maybe due to the language barrier) never got a grip of. Thank you, thank you, thank you! Only one quick question: wouldn't it be more sensible processing the WM_KEYUP message instead of WM_KEYDOWN? I want to use the DEL key to delete entries from a listbox and I fear that if the user keeps his finger on the key just a bit too long, he'll delete multiple entries with WM_KEYDOWN. Thanks again, you guys are great. ------------------ IP: Logged |
|
Dave Biggs Member |
Stop that Oliver! I'm realy glad to help, but the kudos more rightly belongs to Semen, Lance, Tom et al - not forgetting a certain ageless hippie somewhere on a farm in Sweden!! All I've learned so far is through osmosis, lurking here and benefitting from their posts ![]() That said there are probably holes in my explanation and I would like to know if there is a list of the BTW I think you are right, %WM_KEYUP does look like a better choice. Regards Dave ------------------ [This message has been edited by Dave Biggs (edited August 17, 2003).] IP: Logged |
All times are EasternTime (US) | next newest topic | next oldest topic |
![]() |
|
Copyright © 1999-2007 PowerBASIC, Inc. All Rights Reserved.