Posts 1 - 10 of 13
First | Prev. | 1 2 | Next | Last
|
|
Jason Coley
Posts: 272
Joined: 2005-05-26
|
Hi there,
I have an addin, it works in Outlook, Word, and Excel.
In Word and Excel I want to show a formm so I create the form,
Application.CreateForm(TMyForm, MyForm);
then i use MyForm.Show; to show the form.
The Form is set to Always on Top (Is there a better way to have this form on top of Word, like a popup, but not on top of other windows?)
Anyway, when I close the form, Word crashes? There is no code on the close event of the form, and the form is freed on the addin Finalize event.
Any ideas why this is happening?
The controls on the form are: TComboBox, TListBox, TButton x 2 and TPanel x 2.
Jason
|
|
Posted 31 Oct, 2006 14:45:24
|
|
Top
|
|
Nicholas Glasier
Guest
|
Instead of this:
Application.CreateForm(TMyForm, MyForm);
Try this:
var
MyForm: TMyForm;
begin
MyForm := TMyForm.Create(nil);
try
...
finally
FreeAndNil(MyForm);
end;
end;
The application object does not actuially exist for a dll. if you declare the forms unit in your uses clause and then point to the host application with GetActiveWindow, then you can use it for several things.
But if you use it for creating forms, then you may get problems when closing because you have destroyed the form yourself, and the host app owns it.
The methjod shown above certainly works well for me.
Regards, Nick
|
|
Posted 31 Oct, 2006 15:36:15
|
|
Top
|
|
Jason Coley
Posts: 272
Joined: 2005-05-26
|
thank for that, an ideas for other issue, about having a form only showing on top of a word window, but not modal?
Also, is there any way to tell if the word document being worked on is a word document as oppossed to an email with Use Word as Email Editor on?
Jason |
|
Posted 31 Oct, 2006 15:48:50
|
|
Top
|
|
Nicholas Glasier
Guest
|
Hi,
First question: If you make the form StayOnTop then it will also appear above other program windows, and if you make it modal then you won't be able to interact with the hostapp, which is what I guess you want to do.
You could just show the form (not modally) and then go into a loop using application.processmessages until a var is set that lets you know the form has been closed. Then you could free the form. you will have to get a handle to the hostapp with GetActiveWindow in order to be able to use the application object. (don't forget to free it when you're done).
The problem with that is getting the form back on top in order to use or close it, because it won't have a "window button" on the taskbar, and it will disappear behind the hostapp the moment you click on the hostapp window.
I guess you could put a button on your addin's toolbar that would check to see if a form had been created, create one if it hadn't, and bring to front if it did exist.
As far as your second question is concerned. Word has a commandbar called "Envelope" that only appears when it is being used as an Outlook Editor. ADX have a code example that shows how to use this to determine if the current copy of Word is being used inside Outlook or not. Here's the link:
http://www.add-in-express.com/projects/adx-word-with-outlook.zip
Hope this helps, Nick |
|
Posted 31 Oct, 2006 16:27:07
|
|
Top
|
|
Jason Coley
Posts: 272
Joined: 2005-05-26
|
cool thanks for that, I wonder, would popupparent work, if i assigned this to the result of GetActiveWindow?
Jason |
|
Posted 31 Oct, 2006 16:48:31
|
|
Top
|
|
Jason Coley
Posts: 272
Joined: 2005-05-26
|
ahh that seems to be it, use normal Show, and set the PopupMode to imAuto, Don't assign anything to PopupParent, and it all seems to work fine on preliminary tests.
Jason |
|
Posted 31 Oct, 2006 16:52:16
|
|
Top
|
|
Nicholas Glasier
Guest
|
I'm curious, what objects popupmode and popupparent properties are you dealing with?
TIa Nick |
|
Posted 31 Oct, 2006 20:06:18
|
|
Top
|
|
Dmitry Kostochko
Add-in Express team
Posts: 2880
Joined: 2004-04-05
|
Hi Nick and Jason,
Nick, I think Jason uses Delphi 2005 or 2006, and PopupMode and PopupParent are new properties of the TCustomForm object.
Jason, is the problem resolved?
|
|
Posted 01 Nov, 2006 06:10:31
|
|
Top
|
|
Nicholas Glasier
Guest
|
|
Posted 01 Nov, 2006 16:03:58
|
|
Top
|
|
Jason Coley
Posts: 272
Joined: 2005-05-26
|
I am using BDS2006 Delphi Win32.
Yeah things look pretty good now.
One problem I have is if I fire code to show my form when Excel opens in the Excel Application, WindowActivate event, the menubars and toolbars do not show, and if I close my form, Excel closes, so this doesn't look as though it will work in Excel.
Jason |
|
Posted 07 Nov, 2006 13:57:23
|
|
Top
|
|
Posts 1 - 10 of 13
First | Prev. | 1 2 | Next | Last
|