線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:1374
推到 Plurk!
推到 Facebook!

關於自定消息中常數定義的問題?

尚未結案
0908
一般會員


發表:10
回覆:4
積分:2
註冊:2002-12-31

發送簡訊給我
#1 引用回覆 回覆 發表時間:2004-03-30 20:49:47 IP:218.165.xxx.xxx 未訂閱
請問我要自定一個消息那麼常數定義如下 const SX_MYMESSAGE=WM_USER 100; 與 SX_MYMESSAGE=WM_USER; 請問WM_USER他後面的範圍100~$7FFF(WINDOWS為自定消息所保留的範圍)是不是可以省略,另外調用SendMessage及PostMessage這二個API有什麼不一樣的地方用那個比較適合! suen
------
孫鍾銳
seaturn99
版主


發表:69
回覆:427
積分:214
註冊:2003-08-25

發送簡訊給我
#2 引用回覆 回覆 發表時間:2004-03-31 10:42:41 IP:203.66.xxx.xxx 未訂閱
0908 您好 : 1. 關於 WM_USER 的問題 : 0 ~ WM_USER - 1 Messages reserved for use by Windows. WM_USER ~ 0x7FFF Integer messages for use by private window classes. 0x8000 ~ 0xBFFF Messages reserved for future use by Windows. 0xC000 ~ 0xFFFF String messages for use by applications. Greater than 0xFFFF Reserved by Windows for future use. WM_USER 代表的是一個識別數字, 其後至 0x7FFF 範圍都是您可以自行 定義使用的範圍 .. 如果您 SendMessage => WM_USER 100 ,那接收端(Ex: WndProc)收到 WM_USER 100 Message 後,便會接下來執行您函式內的 code.. 2. 以下節錄 MSDN 的一段,希望對您有所幫助.. Posting and Sending Messages Any application can post and send messages. Like the system, an application posts a message by copying it to a message queue and sends a message by passing the message data as arguments to a window procedure. To post messages, an application uses the PostMessage function. An application can send a message by calling the SendMessage, BroadcastSystemMessage, SendMessageCallback, SendMessageTimeout, SendNotifyMessage, or SendDlgItemMessage function. Posting Messages An application typically posts a message to notify a specific window to perform a task. PostMessage creates an MSG structure for the message and copies the message to the message queue. The application's message loop eventually retrieves the message and dispatches it to the appropriate window procedure. An application can post a message without specifying a window. If the application supplies a NULL window handle when calling PostMessage, the message is posted to the queue associated with the current thread. Because no window handle is specified, the application must process the message in the message loop. This is one way to create a message that applies to the entire application, instead of to a specific window. Occasionally, you may want to post a message to all top-level windows in the system. An application can post a message to all top-level windows by calling PostMessage and specifying HWND_TOPMOST in the hwnd parameter. A common programming error is to assume that the PostMessage function always posts a message. This is not true when the message queue is full. An application should check the return value of the PostMessage function to determine whether the message has been posted and, if it has not been, repost it. Sending Messages An application typically sends a message to notify a window procedure to perform a task immediately. The SendMessage function sends the message to the window procedure corresponding to the given window. The function waits until the window procedure completes processing and then returns the message result. Parent and child windows often communicate by sending messages to each other. For example, a parent window that has an edit control as its child window can set the text of the control by sending a message to it. The control can notify the parent window of changes to the text that are carried out by the user by sending messages back to the parent. The SendMessageCallback function also sends a message to the window procedure corresponding to the given window. However, this function returns immediately. After the window procedure processes the message, the system calls the specified callback function. For more information about the callback function, see the SendAsyncProc function. Occasionally, you may want to send a message to all top-level windows in the system. For example, if the application changes the system time, it must notify all top-level windows about the change by sending a WM_TIMECHANGE message. An application can send a message to all top-level windows by calling SendMessage and specifying HWND_TOPMOST in the hwnd parameter. You can also broadcast a message to all applications by calling the BroadcastSystemMessage function and specifying BSM_APPLICATIONS in the lpdwRecipients parameter. By using the InSendMessage or InSendMessageEx function, a window procedure can determine whether it is processing a message sent by another thread. This capability is useful when message processing depends on the origin of the message. ---- 我只會兩件事,這也不會,那也不會 眼見不一定為真 ----
系統時間:2024-05-15 0:56:23
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!