[VC experience] even small experience

zhaozj2021-02-16  65

Note: These are some of my questions and experience I have encountered and handled in programming. This is the first one (look at the effect, first).

First, PostMessage and SendMessage

1. PostMessage only puts the message into the queue, whether or not other programs are processed, then continue, this is an asynchronous message launch function. SendMessage must wait for other programs to handle the message, then return, continue to execute, this is a synchronous message launch function. Moreover, the return value of PostMessage indicates whether the postMessage function is correct; and the return value of SendMessage represents the return value after another program processing the message. Everyone should understand.

2. If you send a message in the same thread, the message should first place the message queue of the thread and then pass the message loop DISPATCH to the target window. SendMessage When sending a message, the system calls the message handler of the target window and returns the result. SendMessage Send a message in the same thread and does not enter the thread message queue.

If you are in different threads. It is best to use PostthreadMessage to replace PostMessage, he works very well. SendMessage Send a message to the thread of the target window, and then send a message to the thread waiting (in fact, he should still do some monitoring, such as monitoring the QS_sendMessage flag) until the target window is processed and the result is returned, send a message The thread continues to run. This is the general situation of SendMessage. In fact, the processing process is more complicated. For example, when a message is sent to a message coming to a message coming, he directly calls the window processing (rein) and returns the processing result (this process does not require support for GetMessage in the message loop).

3, msdn: If you send a message in the range below WM_USER to the asynchronous message functions (PostMessage, SendNotifyMessage, and SendMessageCallback), its message parameters can not include pointers Otherwise, the operation will fail..

If the message is sent under WM_USER (non-custom message) and the message parameter is with a pointer, these asynchronous messaging functions will call these asynchronous messages.

It is best not to use PostMessage to send messages with pointer parameters.

Second, set the view (customer area) size

In the main window (you can also change to the view, get the main window pointer with getParentFrame):

CRECT RECT (100, 100, 400, 400); // The location and size of the view to be set

// AdjustWindowRectex calculates the main window size through the view size. When the // function is executed, the RECT is incorporated into the location and size of the new view. // The third parameter indicates that the size of the menu is not required, otherwise the menu size calculation window size is added. After the function is executed, the RECT returns a new window location and size. :: AdjustWindowRectex (& Rect, getStyle (), false, getExStyle ());

MoveWindow (& Re); // Mobile window

Note: Use this method to dynamically change the size of the view. The problem that should be paid is that the third parameter of AdjustWindower is true, the joining the calculated menu is the height of the row, if there is a multi-line (can be high or not required by the customer area size), you need: int DH = getSystemMetrics SM_CYMENU); get the menu height, then add it to the window height. Third, ADO database operation

1. Get the table name in the database, the field name of a table. Use RS = M_PCONNECTION -> OpenSchema (Schemaenum QueryType, _variant_t param2); you can get it.

For example, RS = M_CurConnection.Openschema (Adschemacolumns, VtMissing, VTMissing); a recordset obtained. His fields include: table_schema, table_name, column_name and so on. The effect is as follows (part):

You can use this RS to move the record, get the table name (under the field "table_name", the field name of a table ("column_name"). It should be noted that it is necessary to determine whether the obtained table name is repeated when the table name is obtained (it can be pulled with the last table name); when the same is the same, his field name ("column_name") is Different, this can get all the field names of a table.

2, use the Supports (CursorOptionNum CursorOptions) method for the Recordset object. Sometimes used to determine if the database supports a type of operation. such as:

// If you can read and set the property IF (m_currs.supports) {// ...} (AdapproPosition)) {// ...}

With regard to the value of Cursoroptionenum, many ADO manuals have.

Enoloo,

6.4,2004

转载请注明原文地址:https://www.9cbs.com/read-25203.html

New Post(0)