Visio got problem with Datagrid on a .NET form

A

Amir

Hi
I was trying to make a .NET form as a Visio window's child using the code
bellow in VB.NET:


<Code Begin>

Const GWL_STYLE As Short = (-16)
Const WS_CHILD As Int32 = &H40000000
Const WS_VISIBLE As Int32 = &H10000000

' MyWindowsForm is the .NET form's class
Dim displayForm as new MyWindowsForm
Dim anchorWindow as Window
Dim windowStates As Object
Dim left As Integer
Dim top As Integer
Dim width As Integer
Dim height As Integer

windowStates = VisWindowStates.visWSAnchorTop _
Or VisWindowStates.visWSAnchorLeft _
Or VisWindowStates.visWSAnchorAutoHide _

anchorWindow = visioApplication.ActiveWindow.Windows.Add( _
"MyWindow", _
windowStates, _
VisWinTypes.visAnchorBarAddon)

displayForm.Show()
Dim listViewHwnd as Int32= displayForm.Handle.ToInt32()

' A windows API that has been declared before
SetWindowLongW(listViewHwnd, _
GWL_STYLE, _
WS_CHILD Or WS_VISIBLE)

' A windows API that has been declared before
SetParent(listViewHwnd, _
anchorWindow.WindowHandle32)

displayForm.Dock = System.Windows.Forms.DockStyle.Fill

anchorWindow.GetWindowRect(Left, _
top, _
width, _
height)
anchorWindow.SetWindowRect(left, _
top, _
width + 1, _
height + 1)


<Code End>



That was working perfect Until I put a DataGrid control on the form instead
of a Listbox control.
The visio can not render the DataGrid and generate an exception.
Exception's Stack Trace is like the bellow:

System.ArgumentException: Invalid parameter used.
at System.Drawing.Graphics.CheckErrorStatus(Int32 status)
at System.Drawing.Graphics.FillRectangle(Brush brush, Int32 x, Int32 y,
Int32 width, Int32 height)
at System.Drawing.Graphics.FillRectangle(Brush brush, Rectangle rect)
at System.Windows.Forms.DataGridParentRows.PaintBorder(Graphics g,
Rectangle bounds)
at System.Windows.Forms.DataGridParentRows.Paint(Graphics g, Rectangle
visualbounds, Boolean alignRight)
at System.Windows.Forms.DataGrid.OnPaint(PaintEventArgs pe)
at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e,
Int16 layer, Boolean disposeEventArgs)
at System.Windows.Forms.Control.WmPaint(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
IntPtr wparam, IntPtr lparam)

I even used GWL_EXSTYLE instead of GWL_STYLE in calling "SetWindowLongW" API.
I'm using windows 2000 server and Visio 2003.

Any help..
Thanks in advance
 
A

Al Edlund

are you coding this as a standalone app, an add-in, web based, activex
control?
al
 

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