MarkShark 27 Posted September 29, 2020 The specific case is that I'm using a TComboBox as an editor in a VirtualStringTree. Unfortunately I can't seem to capture VK_TAB on the KeyDown event of the control. I've used code very similar to the "Properties" tree demo included in the Advanced Demo. Running that demo I get the same affect, pressing Tab while a combobox is active goes to the next focus control. I'd like to handle it much like the enter key and move to the next cell after accepting the edit. Apparently the tab handling is happening at the form level and the TCombobox never seems to get it. Any suggestions on how to handle this? Thanks! Share this post Link to post
Lars Fosdal 1792 Posted September 29, 2020 What if you test it on the Form/Frame OnKeyDown and check if the Sender is that Combo? Would you then be able to instruct the Combo to do the "Enter thing"? Share this post Link to post
MarkShark 27 Posted September 29, 2020 Lars, thanks. This is code I'm writing for a VirtualStringTree that allows editing. I'm sure you're correct that the actions could be handled at the form level, but obviously I'd prefer to keep the handling internal to the control if possible. I was hoping this was just something I'm thinking incorrectly about, maybe there's another way to handle it. Although the fact that the VST demo app shows the same behavior makes me think it's not an easy fix. I did some code searching and it looks like Delphi's TInplaceEditList (part of the Grids Unit) is what they use instead of just using a TComboBox, I assume that's to give more control and to handle this issue. It's a bit complex for a transplant, so I'm hoping someone can suggest an alternative. It's one of those things where it seems like I'm so close to getting it to work the way I want. Share this post Link to post
FPiette 383 Posted September 30, 2020 Have a look at this answer on StackOverflow. It is about a TEdit, but IMO the same concept applies to a TComboBox. 1 Share this post Link to post
Lars Fosdal 1792 Posted September 30, 2020 I see that the second option in the answer is the same as mine. Share this post Link to post
MarkShark 27 Posted September 30, 2020 2 hours ago, FPiette said: Have a look at this answer on StackOverflow. It is about a TEdit, but IMO the same concept applies to a TComboBox. Thank you François! I ended up creating my own TEmbeddedComboBox and used the handling suggested in Remy's answer to your linked SO question.. and SCORE! procedure TEmbeddedComboBox.WndProc(var Msg: TMessage); begin inherited; if Msg.Msg = WM_GETDLGCODE then Msg.Result := Msg.Result or DLGC_WANTTAB; end; 1 Share this post Link to post
limelect 48 Posted October 12, 2020 I just did something similar for my project 1.put TRxWindowHook 2. associate with your control . in my case it was a memo. catch Cnt C put this KeyCount boolean procedure TForm2.RxWindowHook1BeforeMessage(Sender: TObject; var Msg: TMessage; var Handled: Boolean); begin if msg.msg = WM_KEYDOWN then begin if (msg.wparam = 17) then KeyCount := true else if (msg.wparam = 67) and (KeyCount = true) then begin KeyCount := false; DoNotCopy := True; << i needed that on cont C end else KeyCount := false; end; end; Share this post Link to post