473,785 Members | 2,266 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Detect when ActiveForm changes

Is there any way (either .NET or API) to detect when
Windows.Forms.F orm.ActiveForm changes?

Thanks,
Lance

Nov 21 '05 #1
7 2566
"ljlevend" <lj******@nospa m.nospam> schrieb:
Is there any way (either .NET or API) to detect when
Windows.Forms.F orm.ActiveForm changes?


If you are able to keep track of all open forms in your project, then you
can add a generic handler to their 'Activated' events and check the 'sender'
parameter to get a reference to the last activated form. You can use
'AddHandler' to add handlers dynamically, and 'RemoveHandler' to remove a
handler.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #2
Thanks for the idea but that won't work because of forms that are
instantiated outside of my application (e.g., MessageBox or UITypeEditor
forms). Of course I could create my own form types that mimic the behavior
of these classes (in which case your idea would be possible), but the
motivation of this question was to avoid doing that.

Any other ideas?
Lance

Nov 21 '05 #3
Hi

The ActiveForm is a readonly property and it will call the
GetForegroundWi ndow API underlying to get the current active window, so we
did not call any .NET method to set the property, so we have no idea it has
been changed unless we monitor the property.(e.g. use a timer to monitor
the property)

Why you need the requirement, maybe we have another solution.

Thanks!
Best regards,

Perter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 21 '05 #4
Thanks for the info. The reason for wanting to know when ActiveForm changes
is that I need to stop a timer in a 3rd party control whenever a Dialog
window is displayed. My idea was to catch an event when ActiveForm changes
and then test ActiveForm to see if it is modal. If so, then I would stop the
control's timer until ActiveForm changed to a modless window. Using a timer
to monitor ActiveForm should work although it is not as efficient as
listening for an event.

Thanks again,
Lance

Nov 21 '05 #5
Hi

If so, I think we have no other better solution than the Timer one. Because
the ActiveForm is a readonly property, it never call the set routine as
common property, so we have no idea when it is changed.

Hope this helps.

Best regards,

Perter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 21 '05 #6
What about overriding WndProc and using WM_ACTIVATE message?
"ljlevend" <lj******@nospa m.nospam> wrote in message
news:8F******** *************** ***********@mic rosoft.com...
Thanks for the info. The reason for wanting to know when ActiveForm
changes
is that I need to stop a timer in a 3rd party control whenever a Dialog
window is displayed. My idea was to catch an event when ActiveForm
changes
and then test ActiveForm to see if it is modal. If so, then I would stop
the
control's timer until ActiveForm changed to a modless window. Using a
timer
to monitor ActiveForm should work although it is not as efficient as
listening for an event.

Thanks again,
Lance

Nov 21 '05 #7
" Just Me" <gr****@a-znet.com> schrieb:
What about overriding WndProc and using WM_ACTIVATE message?


This could be replaced by automatically adding handlers to the forms'
'Activate' and 'Deactivate' events.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #8

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

Similar topics

1
5830
by: jdph40 | last post by:
I am using Access 2002. I downloaded the forms sample database FrmSmp97.mdb from Microsoft and used the following code in the timer event of a hidden form in order to close a database if no activity was detected. I have it set for one minute for testing purposes only. However, my problem with this code is when the message box pops up and says "No user activity detected...", you have to actually click the OK button before the database...
1
1411
by: polarz | last post by:
here are the lines of code that I've tried. All crash the program shownVals is a string array data is my datatable //problem code #1 loop here{ ((Form1)NewsMyWay.Form1.ActiveForm).data.Rows.Add(shownVals); }
2
1310
by: alex | last post by:
Hi, how can I detect if an MDI is already open or not in order to prevent it from being opened again. How can I bring the MDI form to the TOP from the parent window. If I do a Dim myChildForm1 As New frmForm1() myChildForm1.MdiParent = Me
1
1285
by: Ludovic Lemarinel | last post by:
Hi, I've got a Tab Control, with a lot of tabs, and a lot of controls in each tab (textboxes, comboboxes, listviews, checkboces, etc...). As these controls are updating a Database, I need to detect if there is any change on any control when closing then form, or on record change . I know which events I should use, but I can't see any property to find if my controls have changes.
3
4502
by: ton | last post by:
How can I detect that the user has modified the data on the page where several textboxes, checkboxes and dropdownlist exist. Ton
1
2720
by: siliconpi | last post by:
I'm looking for the simplest and cleanest way of having 10 buttons on a form, on which if I move my mouse over, a label's text changes as specified. I'm using Visual Basic .NET and I'm not too familiar with its intricacies, so I'm getting a bunch of errors on certain scenarios. The code below works fine but breaks if I click on Button1 a few times without moving the program window ----------
5
2277
by: Elmo Watson | last post by:
Let's say I have a child form - frmEdit - on that form a RichText Box called txtedit So - in VB6 days - I used to be able to refer to that particular active form's Rich Text box - like this: With frmMain.ActiveForm.txtedit....... So - now - I'm using DotNet 2.0 - --
2
1976
by: JonBosker | last post by:
I have a form developed in ASP.net and as such all of my controls are server controls and do not have access to onchange events. What I need is a javascript program to detect changes. Here is my idea... when the page loads the program cycles through all of the objects in the form and saves their values into a variable. Then, when the user attempts to navigate away the program cycles through all of the objects in the form and saves the...
0
1229
by: sudhansutiwari | last post by:
Hi Friends, I am trying to port an application written in VB 6.0 to VB 2005. As I am new to .NET environment any suggestion would be highly precious for me. My Current problem is : li_mode = Screen.ActiveForm.ScaleMode 'UPGRADE_ISSUE: Form property Screen.ActiveForm.ScaleMode is not supported. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="8027179A-CB3B-45C0-9863-FAA1AF983B59"'...
0
9489
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10356
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...
0
10162
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10100
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
9959
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
8988
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...
1
7509
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5396
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...
1
4061
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

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.