473,568 Members | 2,986 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DLL and Message Posting

Hi I have a DLL written in C/C++ that is passed Hwnd when it is called.

When the DLL has data for the calling program it uses Hwnd to post a windows
message back to the calling program saying it wants attention.

I have looked at Delegates and events, but it's not obvious how I can
replicate this feature in C#.

Anyone got a sample of code that does something similar in C# ?

Thanks Ken

Nov 15 '05 #1
2 1402
You can still use Handles (Windows Forms equivalent of an Hwnd) and message
posting calls to send data back and forth. If you really want to do it the
..NET way then delegates will work. You simply have the *dll* accept a
delegate as a parameter, and have the caller pass in a handler that matches
the delegate. Then you can simply call that method inside of your dll and
the caller will get the information. It isn't nearly the same as the
Windows Message Pump, but all of that still exists if you are familiar with
it and still want to use it.
--
Justin Rogers
DigiTec Web Consultants, LLC.

"Ken Williams" <g3***@gb7abc.n et> wrote in message
news:bi******** **@newsg4.svr.p ol.co.uk...
Hi I have a DLL written in C/C++ that is passed Hwnd when it is called.

When the DLL has data for the calling program it uses Hwnd to post a windows message back to the calling program saying it wants attention.

I have looked at Delegates and events, but it's not obvious how I can
replicate this feature in C#.

Anyone got a sample of code that does something similar in C# ?

Thanks Ken

Nov 15 '05 #2
Delegates aren't really meant to be marshalled to an external dll unless the
external dll is a mixed mode C++ assembly or an actual piece of managed
code. I am sure there is a way to do the marshalling so that it looks like
nothing more than a function pointer, but I think it is also possible for
the location of the function pointer to change and you wouldn't want to call
back onto a garbage pointer. If you are still wanting an unmanaged dll I
would simply stick with passing the Handle around and using your message
pump code.
--
Justin Rogers
DigiTec Web Consultants, LLC.

"Ken Williams" <g3***@gb7abc.n et> wrote in message
news:bi******** **@newsg2.svr.p ol.co.uk...
So How do I pass a delegate to the DLL do I use something like "ref delegate name" in the call to the DLL ?

Ken

"Justin Rogers" <Ju****@games4d otnet.com> wrote in message
news:uy******** ******@TK2MSFTN GP11.phx.gbl...
You can still use Handles (Windows Forms equivalent of an Hwnd) and

message
posting calls to send data back and forth. If you really want to do it

the
.NET way then delegates will work. You simply have the *dll* accept a
delegate as a parameter, and have the caller pass in a handler that

matches
the delegate. Then you can simply call that method inside of your dll and the caller will get the information. It isn't nearly the same as the
Windows Message Pump, but all of that still exists if you are familiar

with
it and still want to use it.
--
Justin Rogers
DigiTec Web Consultants, LLC.

"Ken Williams" <g3***@gb7abc.n et> wrote in message
news:bi******** **@newsg4.svr.p ol.co.uk...
Hi I have a DLL written in C/C++ that is passed Hwnd when it is called.
When the DLL has data for the calling program it uses Hwnd to post a

windows
message back to the calling program saying it wants attention.

I have looked at Delegates and events, but it's not obvious how I can
replicate this feature in C#.

Anyone got a sample of code that does something similar in C# ?

Thanks Ken



Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
2291
by: dmiller23462 | last post by:
My brain is nuked....Can anybody tell me right off the bat what is wrong with this code? Along with any glaring errors, please let me know the syntax to display a message (Response.Write would be fine I think) that will say "I'm sorry but the data you requested cannot be found" or something along those lines.... This code is on an archive...
4
9270
by: Thys Brits | last post by:
Hi, I'm using the System.Web.Mail class to send an e-mail from my ASP.Net application, but when sending the e-mail, I'm getting the above error. It seems to be because I have Office XP installed, and the version of CDO is replaced by this installation. I haven't been able to find this error anywhere on any MS site. Anyone have a clue on how...
4
9525
by: amywolfie | last post by:
I would like to put code behind a Find button on a form which: 1) Performs a find based on a field on the form 2) If NO RECORDS ARE FOUND, then displays a custom "No Records Found" message box. Thanks!! amy ===
3
7563
by: Roman Muntyanu | last post by:
Hi all, I got a problem with Return key in my C++/C# application. On CView dilalog I put my C# control. This C# control has couple other controls nested. I have problem with RichTextBox control which is at the bottom of my control hierarchy. It does not process VK_RETURN key down. So I can not create new line. All other keys work in...
1
5399
by: Steve Grahovac | last post by:
I have been having trouble the last few days opening any ASP.NET web forms in the design view in the designer. Every time I clicked on an aspx file I got a message box with the error "Unable to open in designer. Illegal characters in path" and the file is instead opened in HTML view. I don't know what application or situation may have...
3
1492
by: bas jaburg | last post by:
Hi, I am using the Microsoft Application BuildingBolock (Freudian slip, hahaha) Exception Management and am using a CustomPublisher. This goes fine and it write's stuff the Windows EventLog. However, each entry starts with the following: The description for Event ID ( 0 ) in Source ( <<appname>> ) cannot be found. The local computer...
8
9995
by: Rod | last post by:
I have been working with ASP.NET 1.1 for quite a while now. For some reason, opening some ASP.NET applications we wrote is producing the following error message: "The Web server reported the following error when attempting to create or open the Web project located at the following URL: 'http://localhost/WebApplication1'. 'HTTP/1.1 500...
10
3692
by: Rider | last post by:
Hi, simple(?) question about asp.net configuration.. I've installed ASP.NET 2.0 QuickStart Sample successfully. But, When I'm first start application the follow message shown. ========= Server Error in '/QuickStartv20' Application. -------------------------------------------------------------------------------- Configuration Error...
8
2128
by: Vladimir S. Oka | last post by:
Please ignore... Thanks Vladimir
0
8118
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7665
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7962
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5501
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5217
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3631
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2105
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1207
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
933
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.