LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

send message from dll to external application

My application is developed in MFC, and the application used one dll which was developed in CVI. The MFC application calls a function "ErasePages" in the CVI dll. Inside of this function, I have a "for" loop, and in each iteration of the loop, I wan't to send a text message back to the MFC application. How can I do that?
 
void ErasePages (int startPage, int endPage)
{
     int page;
     for (page = startPage; page <= endPage; page++)
     {
         EraseAPage(page); // this is a function defined in the dll project.
 
         // I want to send a text message here back to the MFC application
     }
}
 
Thank you.
0 Kudos
Message 1 of 11
(7,183 Views)
Hello,

Since CVI is a C-based system (not C++), you'll likely have more success in directly calling into the Windows API than by using a MFC call, as MFC is a C++ wrapper around the API.  National Instruments doesn't directly support this type of low-level Windows communication, since more extensive resources can be found on MSDN (http://msdn.microsoft.com) or the many third-party sites that specialize in Windows programming.  I recommend giving those a look, as you're more likely to find what you're looking for there. 
Cheers,

Matt Pollock
National Instruments
0 Kudos
Message 2 of 11
(7,157 Views)
I don't know how you can post text messages to an MFC app.

If you just want to post windows messages to the MFC apps window, you can always use PostMessage() or SendMessage(), which are Windows SDK calls. Ofcourse if you are using custom messages, you will need to make sure your MFC app is aware of those messages and has some handlers for them so that it can update its UI.
Bilal Durrani
NI
0 Kudos
Message 3 of 11
(7,143 Views)

PostMessage() and SendMessage() can only be called inside of MFC. What I want is sending a message from CVI. It seems like CVI doesn't support this.

Thanks

0 Kudos
Message 4 of 11
(7,133 Views)
These are Windows SDK functions, so to use these you need to include the windows.h header as the very first include file in your list of includes.
I am assuming you have CVI FDS, which includes the full Win32 SDK and that you enabled the Windows SDK feature when you installed CVI.
Bilal Durrani
NI
0 Kudos
Message 5 of 11
(7,113 Views)
Just to clarify, you can use PostMessage and SendMessage if you have CVI Base as well.
Bilal Durrani
NI
0 Kudos
Message 6 of 11
(7,099 Views)

Hi Bilal,

The first argument of PostMessage and SendMessage is of type HWND which is the handle of the window we want to send the message to. Inside of the dll (CVI), I don't have that window handle of the window I want to send the message to, and I'm not sure if CVI supports this HWND data type.

Thanks

0 Kudos
Message 7 of 11
(7,096 Views)
Hi Bilal,
 
It works. Thank very much.
 
 
0 Kudos
Message 8 of 11
(7,087 Views)

For anyone who comes across this thread at a later date, the function GetCVIWindowHandle() will return the HWND handle from CVI for use with SDK functions.

0 Kudos
Message 9 of 11
(7,081 Views)
Another solution is using the function 'ClipboardPutText("Text")' putting a string to the clipboard from the DLL and inside the EXE getting it back using ClipboardGetText ().
0 Kudos
Message 10 of 11
(6,999 Views)