Problems with TPageControl, TCustomControl descendant and Accelerrators

When I put my own Controls (TCustomControl descendants) on a pagecontrol and type some text in my control (Keypress method is overriden) all works good - till I define key accelerators for the tabsheets. Then even if I don't press the ALT key, the accelerator keys are sent to the pagecontrol and dont reach anymore my control.
This happens here:

procedure TCustomTabControl.CMDialogChar(var Message: TCMDialogChar);
var
  I: Integer;
begin
  for I := 0 to FTabs.Count - 1 do
    if IsAccel(Message.CharCode, FTabs[I]) and CanShowTab(I) and CanFocus then
    begin
      Message.Result := 1;
      if CanChange then
      begin
        TabIndex := I;
        Change;
      end;
      Exit;
    end;
  inherited;
end;

Why is a CM_DialogChar message sent to the pagecontol even if I dont press the ALT key??? What can I do to change that behaviour? (Without editing the VCL code or subclass pagecontrol)
aacrgAsked:
Who is Participating?
 
LischkeConnect With a Mentor Commented:
Try capturing the WM_GETDLGCODE in your self made controls and return DLGC_WANTALLKEYS in Message.Result. This should do the job...

Ciao, Mike
0
 
aacrgAuthor Commented:
I only returned DLGC_WANTARROWS... - I'll test your suggestion.
0
 
aacrgAuthor Commented:
I must have been blind there was a flag in my component that controlled that behaviour... It's several months ago that I wrote it and it's quite big so I didn't remember that there was a such flag...
Thanks, aacrg.
0
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
aacrgAuthor Commented:
I give you just a "C" because the question wasn't really hard - but I was blind...
0
 
LischkeCommented:
aacrg, that's not fair. The grade you give is not for how hard the question is (this is expressed by the points you are assigning), but shows how good the provided answer is and how good it solved your problem. I reacted very fast with a proper answer and tried to understand your problem (your's, not mine!) just to earn a C...

Ciao, Mike
0
 
aacrgAuthor Commented:
That's true but I really hit the false button normally I increase the points afterwards. It's true that you reacted very fast and gave the right answer. So it was perhaps fairer to give you an A.
0
 
LischkeCommented:
. yes indeed and once you have accepted an answer it doesn't make any difference for you which grade you give, but of course for the one who answered...
0
 
aacrgAuthor Commented:
That's true but I actually can't change your grading. What can I do to make you happy?
0
 
LischkeCommented:
:-) nothing specific :-) Just let's close this discussion and I hope next time you think more careful about which grade you give...

Ciao, Mike
0
 
aacrgAuthor Commented:
Shure.
0
All Courses

From novice to tech pro — start learning today.