473,399 Members | 2,278 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

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 1688
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.AssignHandle(Process.GetCurrentProcess() .MainWindowHandle)
frm.ShowDialog(appWindow)
Catch ex As Exception
MessageBox.Show(ex.ToString, My.Application.Info.Title.ToString)
Finally
appWindow.ReleaseHandle()
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
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...
16
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....
8
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...
5
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
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...
6
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
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...
1
by: tomg | last post by:
How can I get all of my MS Access form names into an Excel file? thanks,
5
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,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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,...
0
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...

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.