Hello all,
I have a C# control that is housed on a form that was created in VB 6.
There are some activities I want to do only if the control is on the
ActiveForm. However, since the form is a VB 6 form when I call
Form.ActiveForm I get a null back, even though I can see the form is
the active windows form. Is there a good way to get the ActiveForm in
this scenario?
Thank you. 3 2249
ramhog,
How did you get the .NET control onto a form in VB6? .NET doesn't
support exporting ActiveX controls, although it is possible (but not
recommended).
In this scenario, ActiveForm is not going to work, as .NET keeps track
of which window handles have .NET window representations attached to them.
Since the VB6 form is not in .NET, there is no form to return.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m
"ramhog" <ka*********@ng c.com> wrote in message
news:11******** *************@u 72g2000cwu.goog legroups.com... Hello all, I have a C# control that is housed on a form that was created in VB 6. There are some activities I want to do only if the control is on the ActiveForm. However, since the form is a VB 6 form when I call Form.ActiveForm I get a null back, even though I can see the form is the active windows form. Is there a good way to get the ActiveForm in this scenario?
Thank you.
Thank you for your response.
I understand it isn't recommended, probably because of issues just like
this. You can do this by creating the .NET control make it COM visible
and give it a ProgID and GUID, then you can create it in VB 6. I just
need to find a way to get the Handle to the form containing it, even if
that answer is in using an API.
Nicholas Paldino [.NET/C# MVP] wrote: ramhog,
How did you get the .NET control onto a form in VB6? .NET doesn't support exporting ActiveX controls, although it is possible (but not recommended).
In this scenario, ActiveForm is not going to work, as .NET keeps track of which window handles have .NET window representations attached to them. Since the VB6 form is not in .NET, there is no form to return.
Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard. caspershouse.co m
"ramhog" <ka*********@ng c.com> wrote in message news:11******** *************@u 72g2000cwu.goog legroups.com... Hello all, I have a C# control that is housed on a form that was created in VB 6. There are some activities I want to do only if the control is on the ActiveForm. However, since the form is a VB 6 form when I call Form.ActiveForm I get a null back, even though I can see the form is the active windows form. Is there a good way to get the ActiveForm in this scenario?
Thank you.
ramhog,
Why not just call the GetParent api method and pass your window handle
into it?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m
"ramhog" <ka*********@ng c.com> wrote in message
news:11******** **************@ y43g2000cwc.goo glegroups.com.. . Thank you for your response.
I understand it isn't recommended, probably because of issues just like this. You can do this by creating the .NET control make it COM visible and give it a ProgID and GUID, then you can create it in VB 6. I just need to find a way to get the Handle to the form containing it, even if that answer is in using an API.
Nicholas Paldino [.NET/C# MVP] wrote: ramhog,
How did you get the .NET control onto a form in VB6? .NET doesn't support exporting ActiveX controls, although it is possible (but not recommended).
In this scenario, ActiveForm is not going to work, as .NET keeps track of which window handles have .NET window representations attached to them. Since the VB6 form is not in .NET, there is no form to return.
Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard. caspershouse.co m
"ramhog" <ka*********@ng c.com> wrote in message news:11******** *************@u 72g2000cwu.goog legroups.com... > Hello all, > I have a C# control that is housed on a form that was created in VB 6. > There are some activities I want to do only if the control is on the > ActiveForm. However, since the form is a VB 6 form when I call > Form.ActiveForm I get a null back, even though I can see the form is > the active windows form. Is there a good way to get the ActiveForm in > this scenario? > > Thank you. > This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Sherwood |
last post by:
Greetings,
I have the following code (which displays a second form), but it is not
working as expected. I want to close the calling form after the dismissing
the second form. However, the second form never displays with the code I
have below. Any suggestions? .
ActiveForm.Hide();
frmInstructions frmInstructions = new frmInstructions();
frmInstructions.Show();
|
by: Dica |
last post by:
i want to allow my "Cut" command to dynamically determine the active control
and cut any selected text from it (assuming it's a textBox control). so far
i've got this:
private void menuItem5_Click(object sender, System.EventArgs e)
{
Object oControlType =
System.Windows.Forms.Form.ActiveForm.ActiveControl.GetType();
|
by: Hugh |
last post by:
Hi,
I used following sentex to change form width:
MainForm.ActiveForm.width = 200
However, a error was generated: An unhandled exception of
type 'System.NullReferenceException' occurred. I am
confused. The same command works for other applications.
Any idea.
|
by: ljlevend |
last post by:
Is there any way (either .NET or API) to detect when
Windows.Forms.Form.ActiveForm changes?
Thanks,
Lance
|
by: Eugene |
last post by:
Hi All,
I uses System.Windows.Forms.Form.ActiveForm to get the form with the current
control having the focus. However, I got a problem when my application pops
up another ShowDialog form. The problem is .ActiveForm doesn't returns me the
ShowDialog form, but instead the previously active form. Does anyone know how
I can determine the currently active form is the ShowDialog form? Or is there
anyhow I can know the previous form is no...
| |
by: Jim Madsen |
last post by:
OK--Beginner question--
I have a project with one form -- Form1. To change the text, why can't
I use "Form1.Text = something"? Instead I have to use
"Form1.ActiveForm.Text = Something". As an exercise, I rewrote a timer
app that I wrote in VB 5.0. You set the time, and when it runs, it
minimizes until the time is up, and then pops back up again and gives an
alerting sound. In VB 5.0, I was able to write the time to the forms
text...
|
by: Peter Morris |
last post by:
Form activeForm = System.Windows.Forms.Form.ActiveForm;
Form activeMdiChildForm = activeForm.ActiveMdiChild;
This code is in a component of mine and is triggered from various places
within my application. My problem is that when I run the app
Form.ActiveForm is always set, whereas when I am stepping through code using
the debugger it is always null. This results in a NullReferenceException
|
by: John Brown |
last post by:
Hi there,
Does anyone know how to (generically) determine the currently active form for an application using a "static" function (so I can call it from anywhere). There is no offiical way I've been able to find so I've written the following for starters:
public static Form GetActiveForm()
{
// Returns null for an MDI app
Form activeForm = Form.ActiveForm;
if (activeForm == null)
{
|
by: Emre Sevinc |
last post by:
Hello,
I have a strange situation. I create a very simple Windows Forms
application and place the code below however even though I place
breakpoints in various event handling points VS.NET 2005 only enters
the breakpoint for the button but not for the form. Am I missing
something? Why don't the events for my form Form1 have any effect?
Form1.cs:
|
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...
|
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...
| |
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 captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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,...
|
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |