VC technology insider note

Source: Internet
Author: User

1. When the user changes the window size or restores the previously masked part of the window (ondraw is automatically called ). Or when the application changes the window data, the window needs to be re-drawn (invalidate or invalidaterect ).
2. By convention, the names of non-static data members in the MFC Library start with M.
3. A csize object is the difference between two cpoint objects, and we can use a cpoint object for offset to get the crect object.
4. Ensure that the device environment objects can be deleted in a timely manner (and the corresponding Windows Device environment is released ). The simplest way is
Construct the object in the stack: cclientdc DC (this); his shampoo function is automatically called when the function returns
You can also getdc and realeasedc.
5. If we need to rewrite the onpaint function, we need to use the cpaintdc class.
6. When the SelectObject member function family of the CDC class selects the GDI object into the device environment, it also returns the forward request.
Pointer of the selected object (in this process it has actually been separated ). A simple method is to select your own GDI object and
Save the task and restore it.
7. dodataexchange, DDX _ (Exchange), and DDV _ (validation) functions are bidirectional. If the parameter passed to updatedata is false
The value in the data member is passed to the dialog control; otherwise, if the parameter is true, the value is transmitted in turn.
8. The getdlgitem function of the window object corresponding to the access control, which can be used to convert the ID into a cwnd pointer
Example: cscrollbar * PSB = (cscrollbar *) getdlgitem (idc_loyal); note that these pointers are temporary
Therefore, it cannot be stored for future use.
To convert the cwnd pointer to a control ID, you can use the getctrlid function.
9. Each control immediately sends the wm_ctlcolor message to its parent dialog box before it is displayed. the dialog box itself also sends the message.
If you map the message in the derived class dialog box, you can set the foreground color and background color of the text, as well as the control or
In the dialog box, select a brush in the non-partition area.
10. If we only want to display some text, we can use the dialog box editor to create a static control with a special ID
And then call the setdlgitemtext function in the member functions (such as oninitdialog) of the dialog box.
11. We need to draw in the control window and Prevent Windows from repeating the painting. We can use
The invalidate/updatewindow Call Sequence achieves this effect.

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.