dialog help needed

R

rassiel

Please check this code in C

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? I tried getting the handle of the window through WinAPI but this is not good enough, and it dosnt worked as i expected
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top