|
2#
楼主 |
发表于 2014-3-20 18:58:11
|
只看该作者
1、LAUNCHER
初始变量
- private ThisAddIn addin;
- private Excel.Application app;
- private AutoSetForm autoSetForm;
- private void Ribbon1_Load(object sender, RibbonUIEventArgs e)
- {
- addin = Globals.ThisAddIn;
- app = addin.Application;
- this.grpModeless1.DialogLauncher.ScreenTip =
- "ScreenTip\r\nScreenTip\r\n";
- this.grpModeless1.DialogLauncher.SuperTip =
- "SuperTip\r\nSuperTip\r\n";
- }
复制代码
//模态
- private void grpModal_DialogLauncherClick(object sender, RibbonControlEventArgs e)
- {
- //获得窗口
- if (autoSetForm == null || autoSetForm.IsDisposed)
- {
- autoSetForm = new AutoSetForm();
- }
- //显示
- autoSetForm.ShowDialog();
- }
复制代码
//非模
- //非模态,关联EXCEL
- private void grpModeless1_DialogLauncherClick(object sender, RibbonControlEventArgs e)
- {
- //获得窗口
- if (autoSetForm == null || autoSetForm.IsDisposed)
- {
- autoSetForm = new AutoSetForm();
- }
- //关联Excel窗口
- IntPtr handel;
- //获得窗口句柄:方法一
- handel = Process.GetCurrentProcess().MainWindowHandle;
- //获得窗口句柄:方法二
- handel = new IntPtr(app.Hwnd);
- //得到父窗口
- NativeWindow win = NativeWindow.FromHandle(handel);
- //显示
- autoSetForm.Show(win);
- }
复制代码
//非模态,不关联EXCEL
- private void grpModeless2_DialogLauncherClick(object sender, RibbonControlEventArgs e)
- {
- //获得窗口
- if (autoSetForm == null || autoSetForm.IsDisposed)
- {
- autoSetForm = new AutoSetForm();
- }
- //显示
- autoSetForm.Show();
- }
复制代码
|
|