Albert,
That workaround functioned perfectly. I thought I was going mad there for a
while.
I had FlatStyle set to System for the controls, to pick up XP visuals and
this didn't work at all.
I then set FlatStyle back to Standard and this seemed to allow the "browse"
button to spit up the Pick-A-Folder dialog.
I then hit a checkbox control in the groupbox and this toggles the enabled
state of all the controls in the groupbox.
So now the controls were disabled, hit checkbox again to enable the controls
and it would hang again.
Your workaround has fixed all this and I can set FlatStyle to System to get
the visuals. Nicely done.
Thanks very much.
Cheers,
Glenn.
"Albert Szilvasy" wrote in message
news:4854858@discussion.autodesk.com...
This is a bug in AutoCAD (acmgd.dll). There's a relatively easy workaround.
Add the following code to your user control:
const int GWL_EXSTYLE = -20;
const int WS_EX_CONTROLPARENT = 0x00010000;
[DllImport("user32.dll")]
private static extern int SetWindowLong(IntPtr hWnd, int nIndex, int
dwNewLong);
[DllImport("user32.dll")]
private static extern int GetWindowLong(IntPtr hWnd, int nIndex);
[DllImport("user32.dll")]
private static extern IntPtr GetParent(IntPtr hWnd);
protected override void OnLoad(EventArgs e)
{
//workaround bug in AutoCAD: the WS_EX_CONTROLPARENT style is
not set on the tab hosting
//our user control (the parent of the our control). This
confuses user32.dll into hanging in
//an infinite loop. Manually set the style to correct this.
IntPtr hwndParent = GetParent(this.Handle);
SetWindowLong(hwndParent,GWL_EXSTYLE,GetWindowLong(hwndParent,GWL_EXSTYLE)
| WS_EX_CONTROLPARENT);
base.OnLoad (e);
}
Albert
"Glenn Ryan" wrote in message
news:4853128@discussion.autodesk.com...
Hello everyone,
I'm using AutoCAD 2006, VS 2003 and writing a C# tab add-in for the options
dialog.
I've added a user control to my project, then added a groupbox which
contains several controls, including a button.
The button event is supposed to fire up a FolderBroswerDialog, however,
whenever I hit the button, AutoCAD hangs
as if it's lost focus. I then knocked this out and just tried spitting up a
MessageBox - no go either.
Interestingly enough, if I have a buton by itself (not contained in the
groupbox) on the user control, I can get it to successfully work.
Does anyone have any ideas as to what is causing this behaviour?
Cheers,
Glenn.