Browse Wiki & Semantic Web

Jump to: navigation, search
Http://dbpedia.org/resource/Message loop in Microsoft Windows
  This page has no properties.
hide properties that link here 
  No properties link to this page.
 
http://dbpedia.org/resource/Message_loop_in_Microsoft_Windows
http://dbpedia.org/ontology/abstract The message loop is an obligatory section The message loop is an obligatory section of code in every program that uses a graphical user interface under Microsoft Windows.Windows programs that have a GUI are event-driven. Windows maintains an individual message queue for each thread that has created a window. Usually only the first thread creates windows. Windows places messages into that queue whenever mouse activity occurs on that thread's window, whenever keyboard activity occurs while that window has focus, and at other times. A process can also add messages to its own queue. To accept user input, and for other reasons, each thread with a window must continuously retrieve messages from its queue, and act on them. A programmer makes the process do that by writing a loop that calls GetMessage (which blocks for a message and retrieves it), and then calls DispatchMessage (which dispatches the message), and repeats indefinitely. This is the message loop. There usually is a message loop in the main program, which runs on the main thread, and additional message loop in each created modal dialog. Messages for every window of the process pass through its message queue, and are handled by its message loop. A message loop is one kind of event loop. A basic message loop appears as follows: int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow){ MSG msg; BOOL bRet; while (1) { bRet = GetMessage(&msg, NULL, 0, 0); if (bRet > 0) // (bRet > 0 indicates a message that must be processed.) { TranslateMessage(&msg); DispatchMessage(&msg); } else if (bRet < 0) // (bRet == -1 indicates an error.) { // Handle or log the error; possibly exit. // ... } else // (bRet == 0 indicates "exit program".) { break; } } return msg.wParam;} It is conventional for the event loop to call TranslateMessage on each message which can translate virtual keystrokes into strings. Calling TranslateMessage is not technically required, but problems can result if it is not called. The message loop must call DispatchMessage. The message loop does not directly act on the messages that it handles. It dispatches them by calling DispatchMessage, which transfers the message to the "window procedure" for the window that the message was addressed to. (The "window procedure" is a callback procedure, which got associated with the window class when it was registered.) (More than one window can use the same window procedure.) Code can also send messages directly to a window procedure. These are called nonqueued messages. A strict message loop is not the only option. Code elsewhere in the program can also accept and dispatch messages. PeekMessage is a non-blocking call that returns immediately, with a message if any are waiting, or no message if none is waiting. WaitMessage allows a thread to sleep until a message is in the queue. Modern graphical interface frameworks, such as Windows Forms, Windows Presentation Foundation, MFC, Delphi, Qt, and others do not require applications to code a Windows message loop, because they automatically route events such as key presses and mouse clicks to their appropriate handlers as defined within the framework. However, each framework implements a message loop somewhere, and the message loop can usually be accessed or replaced when more direct control is required.aced when more direct control is required. , 메시지 루프(message loop)는 윈도우 프로그램에서 메시지를 받아들이메시지 루프(message loop)는 윈도우 프로그램에서 메시지를 받아들이는 부분을 뜻하며, 윈도우 기반의 모든 GUI 프로그램에 반드시 포함되는 루틴이다. 윈도우의 GUI 프로그램은 기본적으로 으로 동작한다. 윈도우 시스템은 각각 프로세스에 대해서 개별적인 메시지 큐를 할당한다. 어떤 프로세스가 실행되었을 때 해당 프로세스는 메시지 큐를 부여 받으며, 프로세스에 대해서 사용자의 마우스 입력이나 키보드 입력 등 메시지가 발생했을 때 운영체제가 해당 프로세스의 메시지 큐에 메시지를 넣는다. 또는 프로세스가 이런 메시지들을 스스로 자신의 큐에 추가할 수도 있다. 사용자의 입력이나 기타 여러 가지 행동을 받아서 처리하기 위해서 각각의 프로세스는 자신의 큐에서 메시지들을 지속적으로 읽어들이면서 각 메시지에 대응하는 행동을 수행한다. 이를 위해 프로그래머는 프로그램 내부에 메시지를 받아들이는 GetMessage와 받은 메시지를 메시지 처리 함수로 디스패치(전달; 전파)하는 DispatchMessage를 무한정 호출하는 루프를 작성함으로써 프로세스가 메시지를 처리할 수 있게 한다. 이를 메시지 루프라고 한다. 이는 일반적으로 메인 프로그램(메인 함수)의 일부로서 메인 스레드에서 동작한다. 프로세스가 소유한 모든 창(윈도우) 각각에 대한 메시지는 메시지 큐를 통해 전달되며, 해당 프로세스의 메시지 루프에 의해 처리(핸들링)된다. 메시지 루프는 이벤트 루프의 일종이기도 하다. 메시지 루프는 기본적으로 다음과 같이 구성된다. int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow){ MSG msg; BOOL bRet; while(1) { bRet = GetMessage(&msg, NULL, 0, 0); if (bRet > 0) // (bRet > 0 이면 메시지가 처리되어야 한다.) { TranslateMessage(&msg); DispatchMessage(&msg); } else if (bRet < 0) // (bRet == -1 은 에러를 뜻한다.) { // 에러에 대한 처리나 로그 남김이나 프로그램 종료 등의 구문. // ... } else // (bRet == 0 은 프로그램 종료를 의미한다.) { break; } } return msg.wParam;} 전형적으로 이벤트 루프는 가상 키 입력을 문자열로 변환하기 위한 TranslateMessage를 각 메시지에 대해 호출한다. TranslateMessage 호출은 필수는 아니지만 호출되지 않는 경우 문제가 발생할 소지가 있다. 메시지 루프는 DispatchMessage는 반드시 호출해야 한다. 메시지 루프는 핸들링하고 있는 메시지 자체에 대해서 직접적으로 처리하지는 않는다. 메시지 루프는 DispatchMessage를 통해서 메시지들을 해당 메시지가 전달되어야 하는 윈도우의 "윈도우 프로시저"에 전달함으로써 메시지를 전파(Dispatch; 디스패치)시킨다. ("윈도우 프로시저"는 윈도우 클래스가 등록될 때 함께 등록되는 콜백 프로시저를 뜻한다. 여러 개의 창이 하나의 윈도우 프로시저를 공유하는 것도 가능하다.) 프로그램 코드를 통해서 윈도우 프로시저에 직접 메시지를 보낼 수도 있으며, 시스템 큐를 거치지 않고 바로 전달되는 이런 메시지들을 가리켜 비큐 메시지(Nonqueued Messages)라고 부른다. 메시지 루프는 윈도우 GUI 프로그램에 반드시 필요한 부분이지만 엄격한 규칙이나 요구사항은 없다. 메시지를 받아들이고 디스패치하는 부분은 프로그램 코드의 어느 부분에라도 구현될 수 있으며 다양한 옵션이 있다. 예를 들어 GetMessage는 메시지가 들어올 때까지 스레드를 블록시키지만, GetMessage 대신 PeekMessage와 같이 메시지가 있을 때는 읽어들이지만 메시지가 없을 경우에는 즉시 반환하는 논블록킹(Non-blocking) 함수를 이용하는 수도 있다. 또한 WaitMessage를 이용하면 큐에 메시지가 있을 때까지 스레드를 슬립시키는 것도 가능하다. 한편 윈도우 폼, 윈도우 프레젠테이션 파운데이션, MFC, 델파이, Qt와 같은 최근의 GUI 프레임워크로 프로그램을 개발할 때에는 프로그래머가 메시지 루프를 별도로 구현할 필요가 없다. 하지만 프레임워크가 내부적으로 메시지 루프와 같은 형태로 사용자 입력을 처리하는 부분을 구현하고 있으며, 깊이 있는 프로그래밍이 필요한 경우 프로그래머에 의해 수정될 여지가 있다. 깊이 있는 프로그래밍이 필요한 경우 프로그래머에 의해 수정될 여지가 있다. , 微軟視窗操作系统是以事件驅動做為程式設計的基礎。程式的執行緒会从作業系統获取訊息。應微軟視窗操作系统是以事件驅動做為程式設計的基礎。程式的執行緒会从作業系統获取訊息。應用程式會不斷循环呼叫GetMessage函式(或是PeekMessage函式)來接收這些訊息,這個循环稱之為“事件迴圈”。基本上事件迴圈的程式碼如下所示(C語言 / C++程式語言): MSG msg; //用于存储一条消息BOOL bRet;//从UI线程消息队列中取出一条消息while( (bRet = GetMessage( &msg, NULL, 0, 0 )) != 0){ if (bRet == -1) { //错误处理代码,通常是直接退出程序 } else { TranslateMessage(&msg); //按键消息转换为字符消息 DispatchMessage(&msg); //分发消息给相应的窗体 }} 雖然在程序上並沒有很嚴格的規定與要求,但是一般來說,它的事件迴圈通常會呼叫TranslateMessage函式與DispatchMessage函式,這兩個函式會傳遞訊息給回呼函式,以及调用相应視窗的消息处理函数。 現在的繪圖介面架構程式設計,例如Visual Basic與Qt基本上是不會要求應用程式直接拥有視窗程式的訊息迴圈,但是會以鍵盤與滑鼠的按鍵動作來作為事件的處理機制。在這些架構底下,訊息迴圈的痕迹還是可以被找到的。 注意:在上述的原始碼裡,尤其在while迴圈大於零的條件。即使GetMessage函式的傳回值型態是英文字大寫的BOOL,但是在Win32視窗程式裡,它是被定義成int整數型態,它有兩個值,TRUE是整數的1,FALSE是整數的0。整數 -1代表error(例如第二个参数为输出的窗口句柄但取不到值的时候),整數0值当GetMessage获取到WM_QUIT訊息。假如有其他訊息,那麼非零值會當成傳回值(有訊息的傳回值通常是正值,但是有些程式設計的說明文件不一定會說明的很詳細)。傳回值(有訊息的傳回值通常是正值,但是有些程式設計的說明文件不一定會說明的很詳細)。
http://dbpedia.org/ontology/wikiPageExternalLink https://www.microsoft.com/msj/0795/dilascia/dilascia.aspx + , https://msdn.microsoft.com/en-us/library/ms644928.aspx + , https://msdn.microsoft.com/en-us/library/ms644936.aspx + , https://msdn.microsoft.com/en-us/library/ms644943.aspx + , http://edn.embarcadero.com/article/38447 + , https://msdn.microsoft.com/en-us/library/aa383682.aspx + , https://msdn.microsoft.com/en-us/library/ms632590.aspx +
http://dbpedia.org/ontology/wikiPageID 3987223
http://dbpedia.org/ontology/wikiPageLength 4989
http://dbpedia.org/ontology/wikiPageRevisionID 1021670264
http://dbpedia.org/ontology/wikiPageWikiLink http://dbpedia.org/resource/Windows_Presentation_Foundation + , http://dbpedia.org/resource/Message_passing + , http://dbpedia.org/resource/Main_program + , http://dbpedia.org/resource/Source_code + , http://dbpedia.org/resource/Category:Microsoft_application_programming_interfaces + , http://dbpedia.org/resource/Loop_%28computing%29 + , http://dbpedia.org/resource/Event-driven_programming + , http://dbpedia.org/resource/Qt_%28software%29 + , http://dbpedia.org/resource/Delphi_%28programming_language%29 + , http://dbpedia.org/resource/Microsoft_Foundation_Class_Library + , http://dbpedia.org/resource/Microsoft_Windows + , http://dbpedia.org/resource/Null-terminated_string + , http://dbpedia.org/resource/Message_queue + , http://dbpedia.org/resource/Callback_%28computer_programming%29 + , http://dbpedia.org/resource/Category:Events_%28computing%29 + , http://dbpedia.org/resource/Modal_dialog + , http://dbpedia.org/resource/Computer_program + , http://dbpedia.org/resource/Application_framework + , http://dbpedia.org/resource/Event_loop + , http://dbpedia.org/resource/X_Window_System + , http://dbpedia.org/resource/Windows_Forms + , http://dbpedia.org/resource/Graphical_user_interface + , http://dbpedia.org/resource/Thread_%28computing%29 + , http://dbpedia.org/resource/Xlib +
http://dbpedia.org/property/wikiPageUsesTemplate http://dbpedia.org/resource/Template:Unreferenced +
http://purl.org/dc/terms/subject http://dbpedia.org/resource/Category:Microsoft_application_programming_interfaces + , http://dbpedia.org/resource/Category:Events_%28computing%29 +
http://purl.org/linguistics/gold/hypernym http://dbpedia.org/resource/Section +
http://www.w3.org/ns/prov#wasDerivedFrom http://en.wikipedia.org/wiki/Message_loop_in_Microsoft_Windows?oldid=1021670264&ns=0 +
http://xmlns.com/foaf/0.1/isPrimaryTopicOf http://en.wikipedia.org/wiki/Message_loop_in_Microsoft_Windows +
owl:sameAs http://dbpedia.org/resource/Message_loop_in_Microsoft_Windows + , http://www.wikidata.org/entity/Q10296490 + , http://zh.dbpedia.org/resource/Microsoft_Windows%E7%9A%84%E8%A8%8A%E6%81%AF%E8%BF%B4%E5%9C%88 + , https://global.dbpedia.org/id/7cv8 + , http://ko.dbpedia.org/resource/%EB%A7%88%EC%9D%B4%ED%81%AC%EB%A1%9C%EC%86%8C%ED%94%84%ED%8A%B8_%EC%9C%88%EB%8F%84%EC%9A%B0%EC%9D%98_%EB%A9%94%EC%8B%9C%EC%A7%80_%EB%A3%A8%ED%94%84 +
rdf:type http://dbpedia.org/ontology/Settlement +
rdfs:comment 메시지 루프(message loop)는 윈도우 프로그램에서 메시지를 받아들이메시지 루프(message loop)는 윈도우 프로그램에서 메시지를 받아들이는 부분을 뜻하며, 윈도우 기반의 모든 GUI 프로그램에 반드시 포함되는 루틴이다. 윈도우의 GUI 프로그램은 기본적으로 으로 동작한다. 윈도우 시스템은 각각 프로세스에 대해서 개별적인 메시지 큐를 할당한다. 어떤 프로세스가 실행되었을 때 해당 프로세스는 메시지 큐를 부여 받으며, 프로세스에 대해서 사용자의 마우스 입력이나 키보드 입력 등 메시지가 발생했을 때 운영체제가 해당 프로세스의 메시지 큐에 메시지를 넣는다. 또는 프로세스가 이런 메시지들을 스스로 자신의 큐에 추가할 수도 있다. 사용자의 입력이나 기타 여러 가지 행동을 받아서 처리하기 위해서 각각의 프로세스는 자신의 큐에서 메시지들을 지속적으로 읽어들이면서 각 메시지에 대응하는 행동을 수행한다. 이를 위해 프로그래머는 프로그램 내부에 메시지를 받아들이는 GetMessage와 받은 메시지를 메시지 처리 함수로 디스패치(전달; 전파)하는 DispatchMessage를 무한정 호출하는 루프를 작성함으로써 프로세스가 메시지를 처리할 수 있게 한다. 이를 메시지 루프라고 한다. 이는 일반적으로 메인 프로그램(메인 함수)의 일부로서 메인 스레드에서 동작한다. 프로세스가 소유한 모든 창(윈도우) 각각에 대한 메시지는 메시지 큐를 통해 전달되며, 해당 프로세스의 메시지 루프에 의해 처리(핸들링)된다. 메시지 루프는 이벤트 루프의 일종이기도 하다.프에 의해 처리(핸들링)된다. 메시지 루프는 이벤트 루프의 일종이기도 하다. , 微軟視窗操作系统是以事件驅動做為程式設計的基礎。程式的執行緒会从作業系統获取訊息。應微軟視窗操作系统是以事件驅動做為程式設計的基礎。程式的執行緒会从作業系統获取訊息。應用程式會不斷循环呼叫GetMessage函式(或是PeekMessage函式)來接收這些訊息,這個循环稱之為“事件迴圈”。基本上事件迴圈的程式碼如下所示(C語言 / C++程式語言): MSG msg; //用于存储一条消息BOOL bRet;//从UI线程消息队列中取出一条消息while( (bRet = GetMessage( &msg, NULL, 0, 0 )) != 0){ if (bRet == -1) { //错误处理代码,通常是直接退出程序 } else { TranslateMessage(&msg); //按键消息转换为字符消息 DispatchMessage(&msg); //分发消息给相应的窗体 }} 雖然在程序上並沒有很嚴格的規定與要求,但是一般來說,它的事件迴圈通常會呼叫TranslateMessage函式與DispatchMessage函式,這兩個函式會傳遞訊息給回呼函式,以及调用相应視窗的消息处理函数。Message函式,這兩個函式會傳遞訊息給回呼函式,以及调用相应視窗的消息处理函数。 , The message loop is an obligatory section The message loop is an obligatory section of code in every program that uses a graphical user interface under Microsoft Windows.Windows programs that have a GUI are event-driven. Windows maintains an individual message queue for each thread that has created a window. Usually only the first thread creates windows. Windows places messages into that queue whenever mouse activity occurs on that thread's window, whenever keyboard activity occurs while that window has focus, and at other times. A process can also add messages to its own queue. To accept user input, and for other reasons, each thread with a window must continuously retrieve messages from its queue, and act on them. A programmer makes the process do that by writing a loop that calls GetMessage (which blocks for a message and retrisage (which blocks for a message and retri
rdfs:label 마이크로소프트 윈도우의 메시지 루프 , Message loop in Microsoft Windows , Microsoft Windows的訊息迴圈
hide properties that link here 
http://dbpedia.org/resource/Inter-process_communication + , http://dbpedia.org/resource/Event_loop + , http://dbpedia.org/resource/DirectInput + , http://dbpedia.org/resource/Shatter_attack + , http://dbpedia.org/resource/Windows_1.0x + http://dbpedia.org/ontology/wikiPageWikiLink
http://en.wikipedia.org/wiki/Message_loop_in_Microsoft_Windows + http://xmlns.com/foaf/0.1/primaryTopic
http://dbpedia.org/resource/Message_loop_in_Microsoft_Windows + owl:sameAs
 

 

Enter the name of the page to start semantic browsing from.