Ejemplo n.º 1
0
        private void OnResize()
        {
            int width               = SystemInformation.Border3DSize.Width;
            int height              = SystemInformation.Border3DSize.Height;
            int captionHeight       = SystemInformation.CaptionHeight;
            int windowCaptionHeight = SystemInformation.ToolWindowCaptionHeight;

            StandAloneWordControl.MoveWindow(this.WordHwnd, -2 * width, -2 * height - captionHeight,
                                             this.Bounds.Width + 4 * width, this.Bounds.Height + captionHeight + 4 * height + windowCaptionHeight - 18, true);
        }
Ejemplo n.º 2
0
 public void LoadDocument(string x_filename)
 {
     this.DeactivateEvents = true;
     this.FileName         = x_filename;
     this.ReleaseDocument();
     this.ReleaseWordApp();
     this.InternalWordApp = new ApplicationClass();
     this.PrepareWordApp();
     if (this.WordHwnd != 0)
     {
         this.PrepareCommandBars();
         try
         {
             this.InternalWordApp.Visible = true;
             StandAloneWordControl.SetWindowPos(this.WordHwnd, this.Handle.ToInt32(), 0, 0, this.Bounds.Width, this.Bounds.Height, 39U);
             this.OnResize();
         }
         catch (Exception ex)
         {
             int num = (int)MessageBox.Show("Error: do not load the document into the control until the parent window is shown!");
         }
         try
         {
             int systemMenu = StandAloneWordControl.GetSystemMenu(this.WordHwnd, false);
             if (systemMenu > 0)
             {
                 int menuItemCount = StandAloneWordControl.GetMenuItemCount(systemMenu);
                 StandAloneWordControl.RemoveMenu(systemMenu, menuItemCount - 1, 5120);
                 StandAloneWordControl.RemoveMenu(systemMenu, menuItemCount - 2, 5120);
                 StandAloneWordControl.RemoveMenu(systemMenu, menuItemCount - 3, 5120);
                 StandAloneWordControl.RemoveMenu(systemMenu, menuItemCount - 4, 5120);
                 StandAloneWordControl.RemoveMenu(systemMenu, menuItemCount - 5, 5120);
                 StandAloneWordControl.RemoveMenu(systemMenu, menuItemCount - 6, 5120);
                 StandAloneWordControl.RemoveMenu(systemMenu, menuItemCount - 7, 5120);
                 StandAloneWordControl.RemoveMenu(systemMenu, menuItemCount - 8, 5120);
                 StandAloneWordControl.DrawMenuBar(this.WordHwnd);
             }
         }
         catch
         {
         }
         this.Parent.Focus();
     }
     this.RegisterWordEvents();
     this.DeactivateEvents = false;
 }
Ejemplo n.º 3
0
        private void PrepareWordApp()
        {
            object           Template         = (object)this.FileName;
            object           NewTemplate      = (object)false;
            object           DocumentType     = (object)0;
            object           Visible          = (object)true;
            object           obj1             = (object)false;
            object           obj2             = (object)"WordDrivePass";
            WdProtectionType wdProtectionType = WdProtectionType.wdAllowOnlyFormFields;

            try
            {
                string caption = this.InternalWordApp.Caption;
                this.InternalWordApp.Caption = "Barid-Word-Instance" + (object)DateTime.Now.Ticks;
                if (this.WordHwnd == 0)
                {
                    this.WordHwnd = StandAloneWordControl.FindWindow("Opusapp", this.InternalWordApp.Caption);
                }
                this.InternalWordApp.Caption = caption;
                if (this.WordHwnd == 0)
                {
                    return;
                }
                StandAloneWordControl.SetParent(this.WordHwnd, this.Handle.ToInt32());
                if (this.InternalWordApp != null)
                {
                    if (this.InternalWordApp.Documents != null)
                    {
                        this.WordDocument = this.InternalWordApp.Documents.Add(ref Template, ref NewTemplate, ref DocumentType, ref Visible);
                        if (this.Protect)
                        {
                            Document document = this.WordDocument;
                            int      num      = (int)wdProtectionType;
                            // ISSUE: explicit reference operation
                            // ISSUE: variable of a reference type
                            object& NoReset = @obj1;
                            // ISSUE: explicit reference operation
                            // ISSUE: variable of a reference type
                            object& Password = @obj2;
                            object  obj3     = (object)Missing.Value;
                            // ISSUE: explicit reference operation
                            // ISSUE: variable of a reference type
                            object& UseIRM = @obj3;
                            object  obj4   = (object)Missing.Value;
                            // ISSUE: explicit reference operation
                            // ISSUE: variable of a reference type
                            object& EnforceStyleLock = @obj4;
                            document.Protect((WdProtectionType)num, NoReset, Password, UseIRM, EnforceStyleLock);
                        }
                    }
                }
                try
                {
                    this.InternalWordApp.ActiveWindow.ActivePane.DisplayRulers = true;
                    this.InternalWordApp.ActiveWindow.DisplayRightRuler        = true;
                    this.InternalWordApp.ActiveWindow.DisplayScreenTips        = true;
                    this.InternalWordApp.ActiveWindow.DisplayVerticalRuler     = true;
                    this.InternalWordApp.ActiveWindow.DisplayRightRuler        = true;
                    this.InternalWordApp.ActiveWindow.ActivePane.DisplayRulers = true;
                    this.InternalWordApp.ActiveWindow.ActivePane.View[]        = WdViewType.wdPrintView;
                }
                catch
                {
                }
            }
            catch
            {
            }
        }