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

Home Posts Topics Members FAQ

Getting .NET form to respond to Excel window events

Hi,

I am writing a COM add-in for Excel using c#. Everything works fine,
but I am trying to get the some finishing touches sorted out and one
of them is bugging me and I cannot see anything written on the web
trying to achieve this:

My add-in displays a couple of windows forms and some of these behave
more like floating toolbars than standalone modal dialogs. I want to
be able to somehow mirror the behaviour that normal Office commandbars
exhibit (and to some extent modal windows forms) in that:

* when Excel is minimized or deactivated I would like these
"floating" forms to disappear and when Excel is reactivated or
restored to reappear

* when Excel has the focus I would like the form to float over
other windows (if it is not positioned over Excel).

My natural approach is to try to use the api setparent call, but this
does not do what I want. does anyone have any other dieas about how
to do this. ideally, I do not want to hook Excel and respond to
events myself, but would prefer it if their was a natural way I can
"attach" the window to Excel.

Any help is much appreciated.
Seth

May 2 '07 #1
1 1703
Seth,

In VB.NET the following snippet code makes the form to be part of Excel:

Dim frm As New AboutBox1
Dim appWindow As New NativeWindow

Try

appWindow.Assig nHandle(Process .GetCurrentProc ess().MainWindo wHandle)
frm.ShowDialog( appWindow)
Catch ex As Exception
MessageBox.Show (ex.ToString, My.Application. Info.Title.ToSt ring)
Finally
appWindow.Relea seHandle()
End Try
Is this what You want?

---------------
With kind regards,
Dennis
Weekly Blog .NET & Excel: http://xldennis.wordpress.com/
My English site: http://www.excelkb.com/default.aspx
My Swedish site: http://www.xldennis.com/
May 2 '07 #2

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

Similar topics

1
1819
by: mabond | last post by:
Firstly I hope I'm in the right forum ..... if not can someone re-direct me please. I have an application with a main form properties set to mdiparent = true. Toolbar button allows user to open an instance of Excel for work on a particular file dim xlApp as New Excel.Application xlApp.Visible = true
16
11884
by: David Lauberts | last post by:
Hi Wonder if someone has some words of wisdom. I have a access 2002 form that contains 2 graph objects that overlay each other and would like to export them as a JPEG to use in a presentation. I can do this individually for each graph but this does not help me as I need both on the same JPEG. I thought I would try an export the form that contains both but I am having trouble. (My VBA is self taught and a little knowledge is...
8
8092
by: Colleyville Alan | last post by:
I have been working on an Access app that takes info from a file and writes it to a spreadsheet on a form, simultaneously saving the spreadsheet to Excel. I got the idea that the same concept could work in reverse, i.e. we have a cost model written in Excel that calculates the profitability of customer accounts based on several inputs and they need to be updated at least once per year. These cost models sit on lots of people's hard...
5
73223
by: RAJ | last post by:
hi plz tell me how to know "how window is going to close"... i have to right code for X button of forms... plz telll me thanks bye
4
1969
by: Hardy Wang | last post by:
Hi, I have a win form application, when a button is clicked, a lengthy operation will be triggered. During the time program is still running, this application seems not to be able to response to other actions. When I switch to other window, and switch back to my application, all I can see is a white window, it won't refresh itself until operation finishes. If I have some other buttons in the form, it is not possible to show up during...
6
3230
by: Gary Miller | last post by:
Does anyone know how to detect a modeless form on closing by the form that invoked the modeless form? form.Show();
1
1445
by: Souri Challa | last post by:
Hi all, Is there any way to pass a large amount of data from an asp.net form to another browser window opened through client script ? (i.e without using sessions ). Here is my scenario.I've a datagrid in a user control on my webform. when I click a button on my webform, it should display the contents of datagrid ( content type = excel ) in a new browser window. Right now I'm able to get the contents of datagrid into a HTML string and
1
1765
by: tomg | last post by:
How can I get all of my MS Access form names into an Excel file? thanks,
5
24363
kadghar
by: kadghar | last post by:
Most of the times VBA is used with variables. Objects (such as worksheets, cells or databases) are only used when we read their properties (value, formula, font...) or we use a method (save, open...). But their events are rarely used, and mainly when working with MS Forms. Excel has two very important object types: Workbook and Worksheet, which besides their properties and methods, they have events. The Worksheet's events are not shown in...
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
9579
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
10332
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
10320
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
9150
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
6853
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();...
1
4299
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
2
3820
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2991
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.