I am trying to write a visio application. If I write in Macro (within visio app), I get all objects. However, when I try to write same code in Visual Studio 2019, I cant find references. Like ActiveWindow or visSectionAction. I am trying to follow this: Add Menu Action Programatically to Visio
What references am I missing. I added nuget package, added office object library.
TIA
To use Visio object model from a .NET application, you need to add a reference to Visio type library to that application. This is Microsoft.Office.Interop.Visio. You could start over in the Microsoft documentation: https://learn.microsoft.com/en-us/visualstudio/vsto/visio-object-model-overview
The global VBA objects, like ActiveWindow, are available as app.ActiveWindow (assuming the "app" is the root Visio Application object you access). In case of an Add-In:
var w = Globals.ThisAddIn.Application.ActiveWindow
or in case you need to access from a method of the add-in:
var w = Application.ActiveWindow
Enumerations should be prefixed with its type: VisSectionIndices.visSectionAction.
Please note that the answer in the linked question explains how to add a menu item to a shape, not to the application. If you want to extend application menu rather than shape menu (?), you need to add your menu item to the ribbon definition.
Related
Is it possible to automate setting the Option Set file reference programmatically when creating a new Delphi project using the IOTAProjectOptions respectively IOTAProjectOptionsConfigurations interface1?
Or can I do that using any of the other OTAPI IDE services2?
I'm currently using the RAD Studio Delphi 10 Seattle IDE. Though, if newer OTAPI versions would support that feature, I'd still like to know about that.
I couldn't find any appropriate property or function, that seems to do that action in my current ToolsAPI.pas.
I want to achieve the same as choosing Apply Option Set -> Reference at the root project configurations root node in the IDE's project manager view:
Hypothetically I'm looking for some functionality like
procedure IOTAProjectOptionsConfigurations.BaseConfiguration.ApplyOptionSetReference
(const optSetFilePath : string);
A bit more background:
I'm currently developing legacy project wizards for our company wide Delphi project settings. I already have a working IOTAProjectCreator implementation that also manipulates the .dproj MSBuild XML file after it was generated and saved by the IDE. I'm just adding some conditional Import elements there.
Now we also want to use a Options Set file that is stored at a central repository. I know and studied the differences done in the .dproj XML, after that action was applied using the GUI, but there's a non negligible amount of logic going on (regarding dependencies and such), and I'm refraining to (re-)implement that logic via plain XML file manipulations. Not to mention that the necessary logic is prone to be changed with future versions of the IDE.
1)I'm trying to use that in the context of a IOTAProjectCreator implementation, with the definition of the procedure SetInitialProjectOptions(NewProject : IOTAProject); function.
2)It's a shame that these features are documented so poorly.
I have deveoped a custom file type, together with a custom editor (basically a tree with several data pages attached and a few extra buttons). OK, I can run it stand alone and that is fine, and even add it to the tools menu, but I would like to integrate it into the Delphi IDE so that my custom editor (or a similar new version) appears in the IDE, rather like a DFM file has a custom editor. I can find references to most extensions in the Delphi IDE, but not this one. Any guiding hands? Note that this is not a property or component editor (the file type has nothing to do with either of these) nor is it simply syntax highlighting of a text file.
AFAIK it currently isn't possible to reliably integrate a custom editor into the Delphi IDE. The required API simply isn't there. See QC89028 Custom Module support.
During the Delphi 2010 and XE betas I spent most my spare time trying to get a resource editor integrated. Although the effort had the official blessing of Embarcadero and got some, half hearted, support from the IDE engineer, I was never able to get them to deliver on their promises and surface the module API. I eventually abandoned the project.
Update: I've now checked my old correspondence regarding this and it turns out part of the problem was that IOTAModuleCreator (used to implement File|New for custom file types) and IOTAEditorContent (used to transfer data to/from the custom module) only supports text data. Binary data gets mangled.
You can probably do this via an IDE plugin that uses the ToolsAPI (see ToolsAPI.pas in the IDE's source folder (e.g. Program Files (x86)\Embarcadero\Studio\source\ToolsAPI\ToolsAPI.pas.)
For information on writing a plugin in general, see David G Hoyle's excellent blog. Once you know the basics - i.e., write a 'wizard' and get it to do something - you will need to work on integrating your editor.
I have never done this, and so I can't guarantee it is possible. However, some interfaces that look worth investigating and implementing are INTACustomEditorView, which represents a 'view' (file tab when that file is open - think the code editor, Welcome view, type library editor, etc) and IOTAEditorViewServices, to register your custom view. I do not know how you associate a view type with a file type, sorry - possibly something to do with the personality interfaces. You might also be interested in INTACustomEditorSubView which is what creates a tab on the bottom of a file.
Good luck, and if you find a solution please write here so that other people can learn too!
D6 Prof.
Because of Z-Order problem I created a new form. I want to register this custom form in Delphi, to I can use it as normal form, and to I can replace my forms with this - to avoid Z-Order problems.
But I don't know, how to do it.
I created the class, but how to register?
How to force Delphi to show it under "New..." menu?
Thanks for your help:
dd
If you added new properties or the like you have to call RegisterCustomModule() within a design-time package to register the form with Delphi. Use RegisterNoIcon to avoid registration in the component palette.
#durumdara, you can use the object repository from the delphi IDE.
check theses links
Working with the Delphi Object Repository
Using the Object Repository
Mastering Delphi 6 - Delphi Object Repository (Google books)
Right click the form and select "Add to repository..."
Are there examples and resources (source code and documentation) available which show how a 'New xyz Application' or 'New xyz Document' wizard can be created with Delphi which then will appear in the new project / new file dialog of the Delphi IDE?
What I want to do: for some of my libraries I would like to add a new project type and a new file type to the IDE dialogs, which will guide the developer through a wizard and then create some customized auto-generated source code.
So far I found this short overview:
Experts and Wizards in Delphi
And this article
OTA: Visual design of Wizards
Note that this question is not about wizard or GUI creation in general but on how the Delphi IDE can be extended to include my own new project / file type dialogs. The new project and file types should appear in the new file or new project type dialog in the matching category (or even a new one).
The source code for the "Visual design of Wizards" article is here.
That code in itself is an example of what you're asking for, but it can also be used to create your "creators" by writing less code and designing more in the IDE object inspector.
Basically, to have a new source file item for Delphi's "New Items" dialog you need to implement IOTAModuleCreator ; for a new project item you need to implement IOTAProjectCreator. You can even implement IOTAProjectGroupCreator to add an item which will create a whole project group with several projects at once.
Your implementors of these interfaces should generate the source code and return it to the IDE via an implementation of IOTAFile interface. ToolsAPI already contains TOTAFile class which you can easily use by passing it a string of the whole contents of the new file. This will create an unnamed file in memory which the user can then save to hard disk and give it a file name.
You can also find more information by following the links in Zarko's article.
Also see the ToolsAPI unit where the interfaces are declared. There are also some explanations in the comments.
You can try the JvWizard from the JVCL Components.
you can check an example of use here (translated page)
alt text http://vingrad.ru/blogs/bose/files/2008/12/image26.png
Bye.
I'm using Turbo Delphi 2006.
The DLL will be called from within Excel as part of a VBA/DLL combination.
The first part of the problem is trying to find out how to pass to the DLL a reference to the current Excel session. Most other code I've seen was that it launched a separate instance of Excel apart from the one you're in.
I've seen some C++ code that creates an instance of IDispatch and then passes something in to a method of the IDispatch object, but not knowing much C++.
Any ideas?
What you describe is called writing a COM addin. You need to create an automation DLL and implement the IDTExtensibility2 interface. You will then receive the Excel Application interface as a parameter to the OnConnection method.
You will also need to register your DLL as an addin so Excel will automatically load it.
EDIT: Forgot to mention: You might want to take a look at Add-in Express. Their framework and components make getting started with the creation of Office addins ridiculuously easy. You definitely won't have to bother with the details of IDTExtensibility2. All that comes with a (well-justified) price tag, though.
Delphi comes with a set of ActiveX controls to give complete access to Excel and the other Office applications. They should be on the "Servers" tab of the Tool Palette.
If the aren't there, then select Components|Install Packages, and scroll down the list there until the very end, and select the right package.
In a default installation, they should be called:
Microsoft Office Sample Automation Server Wrapper Components
and there should be one for XP and Win2k. The XP ones will work for Vista.
Now that if if you want to automate Excel.
If you merely want to add functionality to Excel by using Delphi, I'd suggest using a COM object, as I suspect that Excel is very accepting of COM objects. Otherwise, you can create a straight DLL, and use that the same way that Excel uses any other DLL.
I do not know much about Office, but I guess you should use COM/ActiveX. Then you also get your IDispatch. See http://delphi.about.com/od/comoleactivex/OLE_COM_DCOM_Automation_ActiveX_Delphi_knowledge_base.htm