The example I used is just one of many (maybe > 1000) that are used within the application.
>> would need to know more about why you are using windows messages in the original version.
See above. Usually the messages that are handled are API related. This is not an uncommon task for an most "serious" applications or custom components to handle. In Win32 Delphi it's trivial.
I think I found a solution to my problem by creating a MessageCracker of the appropriate type, passing through the API Message parameter . I had to scour the borland.vcl.messages namespace to find a class which returned a TRect structure from the LPARAM Integer/pointer. It was interesting to see how this class marshalled the data to/from the TRect structure - and also how a class as useful as the MessageCracker is not documented.
I think my original question was more aimed at how to make use of data structures which are passed as pointers, rather than API/Message handling in general. If I have an integer, this CAN be a pointer which I should be able to typecast as a particular structure. Even though, for argument's sake, I know it will ALWAYS point to Txyz, I will always lose out to the compiler which refuses to take my word for it.
During the conversion of our applications to .NET, I've very much mixed feelings about the transition. On the one hand I appreciate - and LOVE - the true object orientated nature of .NET. This is fantastic. From my own background (Turbo Pascal, Borland Pascal for Windows, Delphi 1,2,3,4,5,6,7) I can see just how easy day-to-day development has become with each new technology (e.g. with BP for Windows, it took the use of three applications, 20 lines of code just to.......... create a button and for it to do something when clicked).
On the other hand with .NET, there is the constant feeling of suffocating constraint. Yes, perhaps it is possible to do most of the low-level things you take for granted in Win32, but my god is it a ball-ache. Take the TRect example - updating a member via a pointer is a single line of code. Now I have to marshal the data out into an external object, change the data and marshal the data back in, all the time understanding what this marshalling is doing once I've eventually found out this is how I go about achieving such a simple operation.
Some applications may convert more easily than others to .NET. Ours for one is not going to be one of them. We use our own versions of most VCL components, many developed from the ground up with no commonality between their standard VCL counterparts. This is necessary to develop our own data-aware components which act upon our own database technology (m21 - MUMPS if you're interested). As such, I find myself deep in the depths of custom component writing and can't help thinking that Win32 is soooooo easy and who's idea was it to convert to .NET. Oh, yes, It was mine.
Main Topics
Browse All Topics





by: developmentguruPosted on 2007-09-05 at 13:46:12ID: 19835661
.NET in general cringes whenever you try to use pointers (considering them unsafe). I would need to know more about why you are using windows messages in the original version. If it was just a convenient way to handle it, you may need to consider an alternative. You could still use the message to trigger an event, but I think you would use "remoting" to get an object's data across in .NET. Here is an article on Remoting
/dynamic/o ffsite.htm ?zi=1/XJ/Y a& sdn=delp hi&cdn=com pute&tm=80 &gps=102_3 _1276_863& f=22& su=p2 84.8.150.i p_&tt=14&b t=1&bts=1& zu=http%3A //rick-ros s.com/ pape rs/borcon2 003/1207.h tml
http://delphi.about.com/gi
Let me know if you can use this or need more.