473,569 Members | 2,761 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

MessagePump (PeekMessage) for managed code events?

I worte an OCX with events. In order to allow the dialog box (or
whatever) to be updated by the event, I had to add a messagepump to the
event.

void MessagePump()
{
MSG msg;
while (PeekMessage(&m sg, NULL, 0, 0, PM_REMOVE))
{
if (msg.message == WM_QUIT) {
PostQuitMessage ((int)msg.wPara m); // resubmit WM_QUIT
// Also need to abort your action here
break;
}
TranslateMessag e(&msg); // Only needed if you allow keyboard messages
DispatchMessage (&msg);
}
}
How can I create a MessagePump in managed code?


--
Bruce E. Stemplewski
GarXface OCX and C++ Class Library for the Garmin GPS
www.stempsoft.com
Jan 2 '07 #1
1 3559
Bruce wrote:
I worte an OCX with events. In order to allow the dialog box (or
whatever) to be updated by the event, I had to add a messagepump to the
event.

void MessagePump()
{
MSG msg;
while (PeekMessage(&m sg, NULL, 0, 0, PM_REMOVE))
{
if (msg.message == WM_QUIT) {
PostQuitMessage ((int)msg.wPara m); // resubmit WM_QUIT
// Also need to abort your action here
break;
}
TranslateMessag e(&msg); // Only needed if you allow keyboard messages
DispatchMessage (&msg);
}
}
How can I create a MessagePump in managed code?

Do I use System::Windows ::Forms::Applic ation::DoEvents ()? This seems
to work.

--
Bruce E. Stemplewski
GarXface OCX and C++ Class Library for the Garmin GPS
www.stempsoft.com
Jan 2 '07 #2

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

Similar topics

0
1294
by: Mario Giacomino | last post by:
Hi, I am using .NET Framework 2.0 with Visual Studio 2005 Beta Professional. Here is the deal: Currently I have a managed class "A" (located ina C# class library) that has a few custom events. An unmanaged C++ class "B" has a member variable of type "A". Can class "B" directly receive the events of class "A", and if so how (code examples)?...
2
9904
by: JR | last post by:
Hi folks, How can I implement the following in C#? while(AppExitFlag == false) { if(AppPausedFlag == true) { GetMessage(); // Process messages.
2
626
by: Jeff | last post by:
What is the .Net Framework equivalent of the Windows API function PeekMessage? Or any other method that will do the same thing. I simply need to check to see if there are messages waiting to be processed. Thanks!
2
7848
by: Jozsef Bekes | last post by:
Hi All, I am trying to implement a general threading approach in C#, and I have faced this problem: I have the function f_main running in thread th1. I want to invoke two functions f1 and f2 in th_2. From f_main I want to do two distinct function calls, the first results only in invoking f1 in the context of th_2, the second function call...
0
1927
by: Arnaud Debaene | last post by:
Hello all. I've got a bunch of existing, non managed, C++ DLLs that export types with, among other things, public events implemented using the boost::signals library. Now, I need to have these DLL interoperate with managed code. Among others things, the managed code need to be able to register for notification with the boost signals....
3
2711
by: Brett Hall | last post by:
I have a VB.NET interface that my managed C++ code is to implement. I seem to be stuck implementing an event defined in that interface. Does anyone have a simple code snippet that will show me the basics of what I need to implement? I've seen all the MSDN articles on implementing events in managed C++ and I've gotten events to work without...
3
3662
by: Lonewolf | last post by:
Hi all, I'm having difficulties passing data back to managed class from my native class when the data is generated from within a native thread in the native class itself. I will give the following runtime error, " Attempting to call into managed code without transitioning out first. Do not attempt to run managed code inside low-level native...
1
3498
by: Apu Nahasapeemapetilon | last post by:
Hello and thank you in advance for your help. Can anyone think of a reason why this code would work properly on one PC, but not another? I've got a System.Windows.Forms.UserControl that products events which I want to consume (sink) within Internet Explorer. I'm following the instructions at:...
1
8948
by: SeeSharp Bint | last post by:
Hi I'm using some of the definitions I found pinvoke.net for PostMessage and PeekMessage as follows public static extern bool PostMessage( HandleRef hWnd,// handle to destination window UInt32 Msg, // message
0
7612
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8120
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...
0
7968
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
5512
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
5219
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
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3640
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1212
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
937
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.