Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29273 Discussions

Trouble getting DDE acknowledge message (handle to dde server)

carowjp
Beginner
1,576 Views
Can anyone dust off their DDE code to help solve a problem?
I cannot seem to get a WM_DDE_ACK message from another application after successfully intitiating DDE. I have used DDE Spy and Spy++ and can see the WM_DDE_INIT messages and the ACK response from the other app. My QuickWin app sleeps during GetMessage and fails to see the WM_DDE_ACK with PeekMessage. Any suggestions? Code is listed below. Thanks alot!
program dde_qq
use DFLIB
use DFWIN
implicit none

integer(2) aApp
integer(2) aTopic

integer(LRESULT) init
integer(LONG_PTR) lparam

type (T_MSG) mesg

integer(HANDLE) hwnd_ees
integer(HANDLE) hwnd

integer(USHORT) temp
integer(UINT) retval
integer(BOOL) success

hwnd=GetHWndQQ(QWIN$FRAMEWINDOW)


aApp=GlobalAddAtom('ees'C)
aTopic=GlobalAddAtom(''C)

lparam = MAKELONG(aApp,aTopic)
init=SendMessage (-1,WM_DDE_INITIATE,hwnd,lparam)

do while (PeekMessage
(mesg,hwnd,WM_DDE_ACK,WM_DDE_ACK,PM_REMOVE) .NE. .TRUE.)
enddo

hwnd_ees=mesg%wparam
temp=GlobalDeleteAtom(aApp)
temp=GlobalDeleteAtom(aTopic)
end program dde_qq
0 Kudos
2 Replies
Jugoslav_Dujic
Valued Contributor II
1,576 Views

Without going deeper into code, I can tell you that fundamental reason why it won't work is that it's a QuickWin program, and you're working from the wrong thread. QW has two threads,primary, which creates the windows, runs message loop and the callback, andsecondary, which runs the PROGRAM. OTOH, PeekMessage can retrieve only messagessent towindows created by the same thread.

So, if you recompile the code as console or win32 application, it should work (modulo other possible errors I didn't look into). If you have to use QuickWin for other reasons, you have to subclass the frame window and catch WM_DDE_ACK from subclassed procedure (see POKER CVF Sample or QWToolbar sample on my home page).

Jugoslav

0 Kudos
leonardopierobon
Beginner
1,576 Views
Dear carowjp, I can see that you were trying to make a FORTRAN code comunicate with EES. Did you finally manage to do so? I am also doing that same but i am having a lot of trouble. It would be really nice if you could give some suggestions.

Thanks for your help.

Leonardo
0 Kudos
Reply