Beispiel #1
0
 public static bool IsControlFrame(Control c)
 {
     Microsoft.Office.Interop.Access.Control o = (Microsoft.Office.Interop.Access.Control)c.Tag;
     if (o is Microsoft.Office.Interop.Access.OptionGroup)
     {
         return(true);
     }
     return(false);
 }
Beispiel #2
0
        void selectForm(Microsoft.Office.Interop.Access.Form form)
        {
            panelMain.Controls.Clear();
            selec = null;

            if (form.CurrentView != 0)
            {
                if (MessageBox.Show("選択されたフォームは、現在デザインビューの為に起動されていません。デザインビューに切り替えないと、変更は保存されません。\n\nいますぐ切り替えますか。", "", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                {
                    string name = form.Name;
                    form.Application.DoCmd.OpenForm(
                        form.Name,
                        Microsoft.Office.Interop.Access.AcFormView.acDesign,
                        null,
                        null,
                        Microsoft.Office.Interop.Access.AcFormOpenDataMode.acFormPropertySettings,
                        Microsoft.Office.Interop.Access.AcWindowMode.acWindowNormal,
                        null
                        );
                    form = form.Application.Forms[name];
                }
            }

            List <Control> box = new List <Control>();
            SortedDictionary <int, Point> sec2pos = new SortedDictionary <int, Point>();

            if (true)
            {
                Microsoft.Office.Interop.Access._Section sec;
                int si, y = 0;

                try {
                    sec         = form.get_Section(si = (int)Microsoft.Office.Interop.Access.AcSection.acHeader);
                    sec2pos[si] = new Point(0, y);
                    y          += sec.Height;
                }
                catch (COMException err) {
                    if (err.ErrorCode == -2146825826)   // {"セクション番号の指定が正しくありません。"}
                    {
                    }
                    else
                    {
                        throw;
                    }
                }

                sec         = form.get_Section(si = (int)Microsoft.Office.Interop.Access.AcSection.acDetail);
                sec2pos[si] = new Point(0, y);
                y          += sec.Height;

                try {
                    sec         = form.get_Section(si = (int)Microsoft.Office.Interop.Access.AcSection.acFooter);
                    sec2pos[si] = new Point(0, y);
                    y          += sec.Height;
                }
                catch (COMException err) {
                    if (err.ErrorCode == -2146825826)   // {"セクション番号の指定が正しくありません。"}
                    {
                    }
                    else
                    {
                        throw;
                    }
                }
            }

            int cz = form.Controls.Count;

            for (int z = 0; z < cz; z++)
            {
                Microsoft.Office.Interop.Access.Control src = (Microsoft.Office.Interop.Access.Control)form.Controls[z];
                Point pos      = sec2pos[Convert.ToInt32(COMUtil.GetProperty(src, "Section"))];
                int   x        = Convert.ToInt32(COMUtil.GetProperty(src, "Left")) + pos.X;
                int   y        = Convert.ToInt32(COMUtil.GetProperty(src, "Top")) + pos.Y;
                int   cx       = Convert.ToInt32(COMUtil.GetProperty(src, "Width"));
                int   cy       = Convert.ToInt32(COMUtil.GetProperty(src, "Height"));
                int   tabIndex = Convert.ToInt32(COMUtil.GetProperty(src, "TabIndex", -1));
                Label c        = new Label();
                c.Location    = new Point(MeasureUtil.PosToPix(x), MeasureUtil.PosToPix(y));
                c.Size        = new Size(MeasureUtil.PosToPix(cx), MeasureUtil.PosToPix(cy));
                c.Text        = "" + tabIndex;
                c.TextAlign   = ContentAlignment.MiddleCenter;
                c.Visible     = true;
                c.BorderStyle = BorderStyle.FixedSingle;
                c.Tag         = src;
                c.TabIndex    = (tabIndex < 0) ? 10000 : tabIndex;
                c.MouseDown  += new MouseEventHandler(c_MouseDown);
                if (tabIndex >= 0)
                {
                    c.BackColor = clrAvail;
                }
                box.Insert(0, c);
            }
            panelMain.Controls.AddRange(box.ToArray());
        }