- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am involved with a project at work where we have an application using dialog windows and registering a windows procedure routine (WndProc) to digest the Windows Messages sent to the window. We have a scenario where we are supposed to be use the WM_COPYDATA message to pass information between our application and another application. The information I am sending is being received and decoded just fine by the other application, but when I receive a WM_COPYDATA message with the return information encoded, my application is able to detect that I received a message, but I am not understanding how to get at the information that is encoded.
I guess part of the issue is understanding how to use the information picked up by the WndProc routine. The call statement for the WndProc routine in Fortran has four parameters: msg, hwnd, wparam, lparam. But these are all integer values within this routine, so it doesn't look like a standard T_MSG data structure, but appears to be a set of pointers into the actual T_MSG structure? The information I need to decode is in the lparam portion of the actual message structure. I also know that the information in the lparam location is expected to be a T_COPYDATASTRUCT structure.
I tried creating a dummy message variable and then 'load' it up with the four pointer values:
Module Dummy
type (T_COPYDATASTRUCT) dummyStruct
type (T_MSG) dummyMsg
integer pointA
pointer (pointA, dummyStruct)
end
...then, in the WndProc routine...
integer function MainWndProc ( hwnd, mesg, wParam, lParam)
use Dummy
...
select case (mesg)
case (WM_COPYDATA)
pointA = lParam
...then in the subroutine where I want to use the lParam information, I try to extract the lpdata portion of the T_COPYDATASTRUCT variable, which contains the data I want...
character*10 text
integer pointB
pointer (pointB, text)
...
pointB = dummyStruct.lpdata
write(6,*) text
...
So, somewhere in all this convoluted programming, I am obviously not correctly addressing the various pointers to get into the message structure. This is hard to find help pages for, since all my searches on Windows Messaging show C++ examples, but no Fortran examples.
Any ideas or recommendations?
Terry
I guess part of the issue is understanding how to use the information picked up by the WndProc routine. The call statement for the WndProc routine in Fortran has four parameters: msg, hwnd, wparam, lparam. But these are all integer values within this routine, so it doesn't look like a standard T_MSG data structure, but appears to be a set of pointers into the actual T_MSG structure? The information I need to decode is in the lparam portion of the actual message structure. I also know that the information in the lparam location is expected to be a T_COPYDATASTRUCT structure.
I tried creating a dummy message variable and then 'load' it up with the four pointer values:
Module Dummy
type (T_COPYDATASTRUCT) dummyStruct
type (T_MSG) dummyMsg
integer pointA
pointer (pointA, dummyStruct)
end
...then, in the WndProc routine...
integer function MainWndProc ( hwnd, mesg, wParam, lParam)
use Dummy
...
select case (mesg)
case (WM_COPYDATA)
pointA = lParam
...then in the subroutine where I want to use the lParam information, I try to extract the lpdata portion of the T_COPYDATASTRUCT variable, which contains the data I want...
character*10 text
integer pointB
pointer (pointB, text)
...
pointB = dummyStruct.lpdata
write(6,*) text
...
So, somewhere in all this convoluted programming, I am obviously not correctly addressing the various pointers to get into the message structure. This is hard to find help pages for, since all my searches on Windows Messaging show C++ examples, but no Fortran examples.
Any ideas or recommendations?
Terry
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
First, all Windows proc functions have a standard set of arguments and this is how they need to be declared in Fortran:
Return messages from Windows frequently include information passed back to the proc function in the form of pointers to Windows data structures, where lParam is usually the pointer and wParam, if used, is typically an integer value. So what you would have in your code would be simply
POINTER(lParam, dummyStruct)
which will have meaning (ie, there will be a dummyStruct present to be pointed to by lParam) only for messages which involve dummyStruct, so this declaration does not create any problems for messages which do not involve dummyStruct or which use lParam in some other way. The message-processing code for CASE(WM_COPYDATA) can simply process dummyStruct%whatever objects as appropriate.
[bash]INTEGER(HANDLE), INTENT(IN) :: hwnd INTEGER(UINT), INTENT(IN) :: msg INTEGER(fWPARAM), INTENT(IN) :: wParam INTEGER(fLPARAM), INTENT(IN) :: lParam [/bash]
Return messages from Windows frequently include information passed back to the proc function in the form of pointers to Windows data structures, where lParam is usually the pointer and wParam, if used, is typically an integer value. So what you would have in your code would be simply
POINTER(lParam, dummyStruct)
which will have meaning (ie, there will be a dummyStruct present to be pointed to by lParam) only for messages which involve dummyStruct, so this declaration does not create any problems for messages which do not involve dummyStruct or which use lParam in some other way. The message-processing code for CASE(WM_COPYDATA) can simply process dummyStruct%whatever objects as appropriate.

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