R
rassiel
using System
using Microsoft.Office.Core
using Word
using FormNamespace= System.Windows.Forms
namespace Tes
public class WordApplication:ApplicationClas
CustomDialog dlg
public WordApplication(
CommandBar cb
((ApplicationEvents2_Event)this).Quit+=new ApplicationEvents2_QuitEventHandler(WordApplication_Quit)
cb= CommandBars.Add("My Bar",MsoBarPosition.msoBarTop,Type.Missing,true)
CommandBarButton button= (CommandBarButton)cb.Controls.Add(MsoControlType.msoControlButton,Type.Missing,Type.Missing,Type.Missing,Type.Missing)
button.Caption= "Test Button"
button.TooltipText= "Click me"
button.FaceId= 35
button.Click+=new _CommandBarButtonEvents_ClickEventHandler(button_Click)
cb.Visible= true
private void WordApplication_Quit(
this.Visible= false
FormNamespace.Application.Exit()
[STAThread
public static void Main(string[] args
new WordApplication().Visible= true
FormNamespace.Application.Run()
private void button_Click(CommandBarButton Ctrl, ref bool CancelDefault
dlg= new CustomDialog()
dlg.ShowDialog()
The statement dlg.ShowDialog() shows the form as modal but with no owner, check what happens if you move the dialog, word doesnt repaint well. i gues it is because hi is not the owner of the dialog. I wonder if there is some way to get the handle of the Word application, because ShowDialog is an overloaded method that supports this signature: (IWin32Window owner) ,this interface IWin32Window provides a property Handle, so the method ShowDialog can call owner.Handle (the result type is an IntPtr(safe pointer)) and show it as a child of the owner. I suppose this can solve the problem, but i'm not so sure. Any idea please?
using Microsoft.Office.Core
using Word
using FormNamespace= System.Windows.Forms
namespace Tes
public class WordApplication:ApplicationClas
CustomDialog dlg
public WordApplication(
CommandBar cb
((ApplicationEvents2_Event)this).Quit+=new ApplicationEvents2_QuitEventHandler(WordApplication_Quit)
cb= CommandBars.Add("My Bar",MsoBarPosition.msoBarTop,Type.Missing,true)
CommandBarButton button= (CommandBarButton)cb.Controls.Add(MsoControlType.msoControlButton,Type.Missing,Type.Missing,Type.Missing,Type.Missing)
button.Caption= "Test Button"
button.TooltipText= "Click me"
button.FaceId= 35
button.Click+=new _CommandBarButtonEvents_ClickEventHandler(button_Click)
cb.Visible= true
private void WordApplication_Quit(
this.Visible= false
FormNamespace.Application.Exit()
[STAThread
public static void Main(string[] args
new WordApplication().Visible= true
FormNamespace.Application.Run()
private void button_Click(CommandBarButton Ctrl, ref bool CancelDefault
dlg= new CustomDialog()
dlg.ShowDialog()
The statement dlg.ShowDialog() shows the form as modal but with no owner, check what happens if you move the dialog, word doesnt repaint well. i gues it is because hi is not the owner of the dialog. I wonder if there is some way to get the handle of the Word application, because ShowDialog is an overloaded method that supports this signature: (IWin32Window owner) ,this interface IWin32Window provides a property Handle, so the method ShowDialog can call owner.Handle (the result type is an IntPtr(safe pointer)) and show it as a child of the owner. I suppose this can solve the problem, but i'm not so sure. Any idea please?