Thank you very much for your prompt response. It is very helpful to me.
Yes, my user interface dll will export a function to the application so that
the application can call it to launch the interface. In the function, as you
named, StartMyDllUserInterface(MyInterfaceClass*), the appplication will pass
a pointer which contains all functions that the UI dll needs to communicate
with the application. Most communications are one-way from the interface to
the application. The application is like a database to the UI. The interface
Dll will also export another function to allow the application to inform the
UI of data changes.
With the helpful information from your response, I think I need to create a
user-interface thread from the exported function "StartMyDllUserInterface". I
am going to look more to figure out the details. Any advice will be
appreciated.
Kate
>> >Hi, there,
>> >
[quoted text clipped - 23 lines]
>
>Thank you very much for your prompt response. It is very helpful to me.
You're quite welcome.
>Yes, my user interface dll will export a function to the application so that
>the application can call it to launch the interface. In the function, as you
>named, StartMyDllUserInterface(MyInterfaceClass*), the appplication will pass
>a pointer which contains all functions that the UI dll needs to communicate
>with the application. Most communications are one-way from the interface to
>the application. The application is like a database to the UI.
Be aware that callbacks to the application will be done in the context
of your thread! This may have unusual consequences unless the
application is carefully designed and written to handle calls from
arbitrary threads.
>The interface
>Dll will also export another function to allow the application to inform the
>UI of data changes.
Since this function will be called from a different thread than the UI
thread, it should only post messages to the UI thread or UI windows.
It should not use SendMessage or any UI call that implies SendMessage
(i.e., SetWindowText, SetDlgItemText). Otherwise, you could have two
threads updating the same UI, which is dangerous and often causes
deadlocks.
>With the helpful information from your response, I think I need to create a
>user-interface thread from the exported function "StartMyDllUserInterface". I
>am going to look more to figure out the details. Any advice will be
>appreciated.
Your UI thread will probably look much like WinMain(); it will need to
create a window (or dialog box) and start a message loop.
If the main application also has a user interface, you may need to
become familiar with such calls as AttachThreadInput(). Here are some
articles that may help:
http://support.microsoft.com/default.aspx?scid=kb;en-us;90975
http://support.microsoft.com/default.aspx?scid=kb;en-us;97925
and especially:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndllpro/html/m
sdn_winthr.asp
--
Phillip Crews aka Severian
Microsoft MVP, Windows SDK
Posting email address is real, but please post replies on the newsgroup.
MechSoft - 03 Jun 2005 23:30 GMT
Thank you! Those references are very good readings. I have learnt quite a lot
today! And I have been able to display a dialog box already from the dll.
Thanks again,
Kate
> >> >Hi, there,
> >> >
[quoted text clipped - 72 lines]
> Microsoft MVP, Windows SDK
> Posting email address is real, but please post replies on the newsgroup.