- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am trying to write a Fortran subroutine (part of a DLL) that communicates with another program via DDE. The Fortran sends commands to the other program using a PostMessage command as follows:
...
cfile = GlobalAddAtom('')
Command = GlobalAddAtom(eescmnd) !eescmd is a CHARACTER*100
lparam = MAKELONG(cfile,command)
...
MsgResult = PostMessage(EESWindowHandle,wm_DDE_REQUEST,
& trnhwnd,lparam)
...
In the case at hand, the command is one to open a file.
Where I am running into difficulty is getting a message back from the other program. It is supposed to respond by a PostMessage with either "opened" or "error" packed into lparam. I am trying to use GlobalGetAtomName to see the result:
i = GlobalGetAtomName(HiWord(mesg%lparam),TempText,255)
i = GlobalGetAtomName(LoWord(mesg%lparam),TempText,255)
TempText is declared as a CHARACTER*255. Neither of the values in LoWord or HiWord seem to have anything to do with the message that the other program is sending. I get something instead that looks like #37152 or #36672 depending not upon whether the file was succesfully opened but on whether the called program was already running. Are these pointers to the text that I am trying to get? If so, how do I translate the pointer into something recognizable? I am fairly sure that what the other program is sending the appropriate message because I can see those messages using a DDE spy program. Any hints, thoughts, or examples of using GlobalGetAtomName in Fortran would be greatly appreciated.
Thanks in advance,
David
...
cfile = GlobalAddAtom('')
Command = GlobalAddAtom(eescmnd) !eescmd is a CHARACTER*100
lparam = MAKELONG(cfile,command)
...
MsgResult = PostMessage(EESWindowHandle,wm_DDE_REQUEST,
& trnhwnd,lparam)
...
In the case at hand, the command is one to open a file.
Where I am running into difficulty is getting a message back from the other program. It is supposed to respond by a PostMessage with either "opened" or "error" packed into lparam. I am trying to use GlobalGetAtomName to see the result:
i = GlobalGetAtomName(HiWord(mesg%lparam),TempText,255)
i = GlobalGetAtomName(LoWord(mesg%lparam),TempText,255)
TempText is declared as a CHARACTER*255. Neither of the values in LoWord or HiWord seem to have anything to do with the message that the other program is sending. I get something instead that looks like #37152 or #36672 depending not upon whether the file was succesfully opened but on whether the called program was already running. Are these pointers to the text that I am trying to get? If so, how do I translate the pointer into something recognizable? I am fairly sure that what the other program is sending the appropriate message because I can see those messages using a DDE spy program. Any hints, thoughts, or examples of using GlobalGetAtomName in Fortran would be greatly appreciated.
Thanks in advance,
David
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Did you properly terminate strings with char(0)? I tried a similar example (I didn't bother to create server/client, I just ran different codes twice in a row, as global atom are persistent):
Another thing to look at is typecasting. ATOMs are unsigned 16-bit values (integer(2)), but Fortran does not have unsigned types and arithmetics. You must take care not to lose the original bit-pattern as was returned from GlobalAddAtom by means of type conversions and sign extension.
Note also that GlobalAddAtom fails on an empty string (""C or char(0)).
Jugoslav
!First run:
integer(2):: cfile, command
cfile = GlobalAddAtom("fff"C)
Command = GlobalAddAtom("asadfasdfa"C) !eescmd is a lparam = MAKELONG(cfile,command)
!
!Second run:
cfile = -16279 (value returned from 1st run)
command = -16281
lparam = MAKELONG(cfile,command)
i = GlobalGetAtomName(HiWord(lparam),TempText,255)
i = GlobalGetAtomName(LoWord(lparam),TempText,255)and it retrieved the strings correctly.Another thing to look at is typecasting. ATOMs are unsigned 16-bit values (integer(2)), but Fortran does not have unsigned types and arithmetics. You must take care not to lose the original bit-pattern as was returned from GlobalAddAtom by means of type conversions and sign extension.
Note also that GlobalAddAtom fails on an empty string (""C or char(0)).
Jugoslav
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page