473,804 Members | 3,686 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Managed C++ MAKE_DELEGATE and LostFocus event in VS2005

I am using Managed C++ with a CFormView and a MaskedTextBox and have used
MAKE_DELEGATE to sink the LostFocus event of this control.

I have other events I've sinked off this control and they all work fine,
however, the LostFocus does not fire.

I found Scribble online and they do the same thing I did, however, when I
used this code in Visual Studio 2005 the LostFocus event didn't get fired
either.

My example code looks like this:

m_cValue->LostFocus += MAKE_DELEGATE( System::EventHa ndler, OnLostFocus );

In DoDataExchange:
DDX_ManagedCont rol(pDX, IDC_VALUE, m_cValue);

CWinFormsContro l<System::Windo ws::Forms::Mask edTextBox> m_cValue;

If I run into problems, I code it in C# and then convert it to C++. It
works fine in C#, however, my managed C++ does not. Is there something I've
implemented incorrectly?

Thanks,
Carmon
Apr 13 '06 #1
6 3784
From your explanations I can not see anything that you have made wrong.

My assumption is that the LostFocus event is not fired when the control is
hosted in an MFC window. I will do some tests with that now.

Marcus
"Carmon" <Ca****@discuss ions.microsoft. com> wrote in message
news:76******** *************** ***********@mic rosoft.com...
I am using Managed C++ with a CFormView and a MaskedTextBox and have used
MAKE_DELEGATE to sink the LostFocus event of this control.

I have other events I've sinked off this control and they all work fine,
however, the LostFocus does not fire.

I found Scribble online and they do the same thing I did, however, when I
used this code in Visual Studio 2005 the LostFocus event didn't get fired
either.

My example code looks like this:

m_cValue->LostFocus += MAKE_DELEGATE( System::EventHa ndler, OnLostFocus );

In DoDataExchange:
DDX_ManagedCont rol(pDX, IDC_VALUE, m_cValue);

CWinFormsContro l<System::Windo ws::Forms::Mask edTextBox> m_cValue;

If I run into problems, I code it in C# and then convert it to C++. It
works fine in C#, however, my managed C++ does not. Is there something
I've
implemented incorrectly?

Thanks,
Carmon


Apr 13 '06 #2
I have done a simple test with an MFC Dialog App, and the LostFocus event is
fired for a MaskedTextBox as well as for a normal TextBox.

There seems to be something else wrong with your code. Maybe my article [1]
is helpful for you.

[1] http://msdn.microsoft.com/msdnmag/is...h/default.aspx

Marcus

"Marcus Heege" <NO****@heege.n et> wrote in message
news:On******** *****@TK2MSFTNG P04.phx.gbl...
From your explanations I can not see anything that you have made wrong.

My assumption is that the LostFocus event is not fired when the control is
hosted in an MFC window. I will do some tests with that now.

Marcus
"Carmon" <Ca****@discuss ions.microsoft. com> wrote in message
news:76******** *************** ***********@mic rosoft.com...
I am using Managed C++ with a CFormView and a MaskedTextBox and have used
MAKE_DELEGATE to sink the LostFocus event of this control.

I have other events I've sinked off this control and they all work fine,
however, the LostFocus does not fire.

I found Scribble online and they do the same thing I did, however, when I
used this code in Visual Studio 2005 the LostFocus event didn't get fired
either.

My example code looks like this:

m_cValue->LostFocus += MAKE_DELEGATE( System::EventHa ndler,
OnLostFocus );

In DoDataExchange:
DDX_ManagedCont rol(pDX, IDC_VALUE, m_cValue);

CWinFormsContro l<System::Windo ws::Forms::Mask edTextBox> m_cValue;

If I run into problems, I code it in C# and then convert it to C++. It
works fine in C#, however, my managed C++ does not. Is there something
I've
implemented incorrectly?

Thanks,
Carmon


Apr 13 '06 #3
Marcus,

Could you either post or email me your test application? I have attempted
this with entirely managed C++ and WinForms but I haven't been able to get
CDialog or CFormView applications to work so I figured it was something I was
doing wrong.

Thanks,
Carmon

"Marcus Heege" wrote:
I have done a simple test with an MFC Dialog App, and the LostFocus event is
fired for a MaskedTextBox as well as for a normal TextBox.

There seems to be something else wrong with your code. Maybe my article [1]
is helpful for you.

[1] http://msdn.microsoft.com/msdnmag/is...h/default.aspx

Marcus

"Marcus Heege" <NO****@heege.n et> wrote in message
news:On******** *****@TK2MSFTNG P04.phx.gbl...
From your explanations I can not see anything that you have made wrong.

My assumption is that the LostFocus event is not fired when the control is
hosted in an MFC window. I will do some tests with that now.

Marcus
"Carmon" <Ca****@discuss ions.microsoft. com> wrote in message
news:76******** *************** ***********@mic rosoft.com...
I am using Managed C++ with a CFormView and a MaskedTextBox and have used
MAKE_DELEGATE to sink the LostFocus event of this control.

I have other events I've sinked off this control and they all work fine,
however, the LostFocus does not fire.

I found Scribble online and they do the same thing I did, however, when I
used this code in Visual Studio 2005 the LostFocus event didn't get fired
either.

My example code looks like this:

m_cValue->LostFocus += MAKE_DELEGATE( System::EventHa ndler,
OnLostFocus );

In DoDataExchange:
DDX_ManagedCont rol(pDX, IDC_VALUE, m_cValue);

CWinFormsContro l<System::Windo ws::Forms::Mask edTextBox> m_cValue;

If I run into problems, I code it in C# and then convert it to C++. It
works fine in C#, however, my managed C++ does not. Is there something
I've
implemented incorrectly?

Thanks,
Carmon



Apr 13 '06 #4
Carmon,
Could you either post or email me your test application? I have attempted
this with entirely managed C++ and WinForms but I haven't been able to get
CDialog or CFormView applications to work so I figured it was something I
was
doing wrong.

Thanks,
Carmon


You can download it here: http://www.marcusheege.de/mfctestapp.zip

Marcus Heege
www.heege.net
Apr 13 '06 #5
Thank you, that helped me get my code working for that aspect.

Thanks,
Carmon

"Marcus Heege" wrote:
Carmon,
Could you either post or email me your test application? I have attempted
this with entirely managed C++ and WinForms but I haven't been able to get
CDialog or CFormView applications to work so I figured it was something I
was
doing wrong.

Thanks,
Carmon


You can download it here: http://www.marcusheege.de/mfctestapp.zip

Marcus Heege
www.heege.net

Apr 17 '06 #6
"Carmon" <Ca****@discuss ions.microsoft. com> wrote in message
news:53******** *************** ***********@mic rosoft.com...
Thank you, that helped me get my code working for that aspect.

Thanks,
Carmon

"Marcus Heege" wrote:
Carmon,
> Could you either post or email me your test application? I have
> attempted
> this with entirely managed C++ and WinForms but I haven't been able to
> get
> CDialog or CFormView applications to work so I figured it was something
> I
> was
> doing wrong.
>
> Thanks,
> Carmon


You can download it here: http://www.marcusheege.de/mfctestapp.zip

Marcus Heege
www.heege.net


You're welcome.
Apr 17 '06 #7

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

Similar topics

4
8953
by: MJW | last post by:
Is there a way for me to know if or which command button was just clicked that triggers the LostFocus event for the current control on a Form? I have a form that has many types of users who each have their own set of fields they can change. Therefore I use setfocus property in the lostfocus event for some of the users to get from one control to another. Since I am "directing traffic" with setfocus, the users are unable to use the...
1
1940
by: The Real Andy | last post by:
This is probably not the most relevant NG for this topic, but if someone could point me to a more relevant NG I would be forever grateful. I am having some issues with the Managed DirectX AudioVideoPlayer namespace. All I am trying to do is play a video file on a secondary video device in full screen. However, as soon as the form on the secondary video looses focus, or as it would seem, the player sets Video.Fullscreen to false. I tried...
4
21209
by: Bernard Bourée | last post by:
I have some TextBoxes created by code. I want to write a procedure to handle the lost of focus of any of these TextBox. How should I do that ? Thanks --
4
1385
by: Wayne Wengert | last post by:
I have a form that has a cbo set to TabIndex 0 (it is the only item set to tabindex 0). On page Load if I step through the code that cbo LostFocus event fires after other initializations are completed and after the LostFocus event completes, that cbo gets focus and the form opens? Why is that LostFocus event firing? Any hints on how to debug this? Wayne
2
3185
by: Paul | last post by:
I have a datagrid tied to a data adapter. Everything works great, EXCEPT, the LostFocus event only fires when I click on a specific cell within the DataGrid. If I set focus on another control, the LostFocus event does not fire. This is causing problems because I am checking for HasChanged on every CurrentCellChanged event. So if I change a cell, move to a new row, the update occurs just fine. However, if I change a cell, then set the...
0
1292
by: Scott McChesney | last post by:
All - I am in the process of developing a custom control that mimics the Office 2003 "Inbox" as closely as possible. After a great deal of frustrating work trying to do a heavily custom-drawn ListView (which is how I believe MS is doing it) and getting nowhere, I said "screw it" and built the thing from scratch. I have a UserControl with a few contained controls, a header control I'm drawing entirely by hand, and a Panel in which I'm...
14
14639
by: teddysnips | last post by:
WINDOWS FORMS I've a form that has a textbox that allows the user to enter a string. On the LostFocus event, the textbox formats the string into a preferred format. However, if the user presses the "Save" button while the textbox has the focus, the LostFocus code doesn't run at the right time, so that the "Save" function is dealing with an incorrectly formatted string and the whole caboodle goes splat.
7
5142
by: Don | last post by:
Getting errors after following the MSDN article on using VB.NET (and VS2005) for "Implementing a Managed OnSave Event Sink" for Exchange Server 2007. Not sure, but part of the problem may be that it's the 64-bit version of Exchange 2007 installed on Windows Server 2003 Enterprise x64, while the Exchange 2007 SDK samples seem mostly geared toward 32-bit. Even at that, I was able to build the TLB and install it into COM+ Component Services,...
0
2365
by: kirk | last post by:
I started with a System.Windows.Forms.Form and subscribed to its LostFocus event. The event fires perfect. I added a System.Windows.Forms.LinkLabel to the aforementioned Form and tested the same LostFocus event again. It does not fire any longer. If I remove the LinkLabel, LostFocus fires again. Why does this fail and how can I get LostFocus to fire for the container Form with a LinkLabel present?
0
9706
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10580
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10323
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
10082
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9157
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5525
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5652
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3821
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2993
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.