|
|
|
|
|
- Overview
- Opening a window from a secondary thread via a dialog by messages
- Principle
- Example
- The above-mentioned method is used in the example named WD Instant messaging.
Opening a window from a secondary thread
A secondary thread cannot directly open a window using classic WLanguage functions such as: Open, Use, ... Nevertheless, you may want to display a window from a secondary thread. For example, if a thread is used to manage some incoming calls, a window containing the characteristics of the caller can be displayed by this thread when an incoming call is detected. The solution consists in opening the window from a code run by the main thread. The following methods can be used to execute the code of the main thread from a secondary thread: - Run a global procedure of the project or a local procedure of a window via ExecuteMainThread,
- Run the "Request for refreshing the display" event of a window via RequestRefreshUI,
- Establish a dialog via messages between threads (PostMessage and Event).
Related Examples:
|
Complete examples (WINDEV): WD Live Messaging
[ + ] This example presents the "Socket" functions of WINDEV. The following topics are presented in this example: 1/ How to connect to a socket 2/ How to create a socket Summary of the example supplied with WINDEV: This example present the different functions for socket management supplied with WINDEV. To use this example, a list of contacts must be entered in your address book. The contacts must be identified by a name and the IP address of their computer. When the application is started, the program searches for the accessible contacts (which means the ones who have started this application on their computer). When you double-click a "connected" contact, a discussion window is opened, giving you the ability to communicate with the contact
|
Opening a window from a secondary thread via a dialog by messages Principle To open a window from a secondary thread: - When the secondary thread wants to open a window, it sends a message to the main thread with PostMessage. This message indicates to the main thread the window that must be opened as well as the parameters required to open the window.
- The main thread manages a specific event, corresponding to the request for window opening. When this event occurs, the WLanguage procedure opens the specified window (with Open for example) with the specified parameters.
The above-mentioned method is used in the example named WD Instant messaging. The code for opening the main window is used to: - implement an event to manage the opening of the window in the main thread.
- trigger the secondary threads.
gnEventID = Event("ChatOpening", "*.*", "ChatStart")
IF gnEventID = 0 THEN
Error("Unable to manage the window for chat opening", ErrorInfo())
EndProgram()
END
ThreadExecute("ThreadPresence", threadNormal, "ListenPresenceRequest")
ThreadExecute("ThreadRequest", threadNormal, "ListenConnectionRequest")
The window is opened in the code of the ListenRequestStartMessage procedure for example. This procedure is run in a thread. The code used to open the window from the thread is as follows:
PostMessage(Handle(WIN_Main),"ChatStart", FILE_CONTACT.CONTACTID, FILE_CONTACT.CONTACTID)
The "ChatStart" message is sent to the main window (identified by its handle). This message contains the different parameters that must be passed to the window. The message is handled by the event defined in the opening code of the window. When the message occurs, the "ChatOpening" procedure is automatically run. This procedure is used to open the window. The code of this procedure is as follows: PROCEDURE ChatOpening(nParam,nContact)
OpenSister(WIN_Message, nContact)
Related Examples:
|
Complete examples (WINDEV): WD Live Messaging
[ + ] This example presents the "Socket" functions of WINDEV. The following topics are presented in this example: 1/ How to connect to a socket 2/ How to create a socket Summary of the example supplied with WINDEV: This example present the different functions for socket management supplied with WINDEV. To use this example, a list of contacts must be entered in your address book. The contacts must be identified by a name and the IP address of their computer. When the application is started, the program searches for the accessible contacts (which means the ones who have started this application on their computer). When you double-click a "connected" contact, a discussion window is opened, giving you the ability to communicate with the contact
|
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|