Quantcast
Channel: Visual Studio Integrate forum
Viewing all articles
Browse latest Browse all 4410

Setting page unable to auto resize

$
0
0

Hi Expert,

We are working on VSpackage project based on MPF. We implemented a setting page and we found the grid is unable to auto resize when we drag the dialog. We get debug into MPF base project (Settingpage.cs)and get following code:

public virtual void Activate(IntPtr parent, RECT[] pRect, int bModal)
		{
			if(this.panel == null)
			{
                if (pRect == null)
                {
                    throw new ArgumentNullException("pRect");
                }

				this.panel = new Panel();
				this.panel.Size = new Size(pRect[0].right - pRect[0].left, pRect[0].bottom - pRect[0].top);
                this.panel.Text = SR.GetString(SR.Settings, CultureInfo.CurrentUICulture);
				this.panel.Visible = false;
				this.panel.Size = new Size(550, 300);
				this.panel.CreateControl();
				NativeMethods.SetParent(this.panel.Handle, parent);
			}

			if(this.grid == null && this.project != null && this.project.Site != null)
			{
				IVSMDPropertyBrowser pb = this.project.Site.GetService(typeof(IVSMDPropertyBrowser)) as IVSMDPropertyBrowser;
				this.grid = pb.CreatePropertyGrid();
			}

			if(this.grid != null)
			{
				this.active = true;


				Control cGrid = Control.FromHandle(new IntPtr(this.grid.Handle));

				cGrid.Parent = Control.FromHandle(parent);//this.panel;
				cGrid.Size = new Size(544, 294);
				cGrid.Location = new Point(3, 3);
				cGrid.Visible = true;
				this.grid.SetOption(_PROPERTYGRIDOPTION.PGOPT_TOOLBAR, false);
				this.grid.GridSort = _PROPERTYGRIDSORT.PGSORT_CATEGORIZED | _PROPERTYGRIDSORT.PGSORT_ALPHABETICAL;
				NativeMethods.SetParent(new IntPtr(this.grid.Handle), this.panel.Handle);
				UpdateObjects();
			}
		}

For cGrid's Parent, it sets to prarent which is a dialog windows passed by VS (I find this using SPY++). Therefore it is unable to casted as control, and the cGrid's parent become null. And there is a comment about panel, for my side, to set the parent to be panel is more make sense.

At the end of code, it calls native method to set parent for grid to be panel. But it seems doesn't work, during debug, the owner still be null.

So far using the commented implement resolved my work. What's I want to know is that why the original copy of mpf project will comment out that code? and any risk may have? 

Thanks in advance.

Regards,

Yi


MSC on Computer Science (Parallel algorithm)


Viewing all articles
Browse latest Browse all 4410

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>