The source of the CN message-The parent window does not know how to handle it, so add the message cn_base in the distribution to the actual subform

Source: Internet
Author: User

VCL has some non-API messages for internal use, why do you do this? From the WM_COMMAND & wm_notify message, we say that the WM_COMMAND message is not sent directly to the form that actually generated the message, but rather to its parent form. However, it is almost impossible for a parent form to handle these messages that do not know how to handle them in the usual way, so the parent form adds the message to the cn_base in the actual subform, which is then processed by the actual subform (the sentence is clear enough).

For example, the TBITBTN element, in order to draw an image on the button surface, processing the Cn_drawitem message, this message handler function is written like this:

FCanvas.Handle := DrawItemStruct.hDC;
  R := ClientRect;

… //省略一部分
  if IsDown then
   OffsetRect(R, 1, 1);
  TButtonGlyph(FGlyph).Draw(FCanvas, R, Point(0,0), Caption, FLayout, FMargin,
   FSpacing, State, False, DrawTextBiDiModeFlags(0));

  if IsFocused and IsDefault then
  begin
   R := ClientRect;
   InflateRect(R, -4, -4);
   FCanvas.Pen.Color := clWindowFrame;
   FCanvas.Brush.Color := clBtnFace;
   DrawFocusRect(FCanvas.Handle, R);
  end;

  FCanvas.Handle := 0;

It can be seen that this is similar to the usual method of handling paint, which is actually plotted on HDC. If you have studied the SDK, we can actually process the WM_NOTIFY message to handle the messages generated by the control, but the VCL encapsulates it for us.

Reference: http://www.rrzxw.net/biancheng/VC/2012/0304/7615.html

------------------------------------------------------------------------------

But there is also a lack of a cn_ message detailed description of the example and run the process, there is time to fill in

The source of the CN message-The parent window does not know how to handle it, so add the message cn_base in the distribution to the actual subform

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.