.NET

Reply
*Glenn Ryan
Message 1 of 9 (159 Views)

TabbedDialogExtension

159 Views, 8 Replies
05-23-2005 01:55 AM
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.
*Mike Tuersley
Message 2 of 9 (159 Views)

Re: TabbedDialogExtension

05-23-2005 06:55 AM in reply to: *Glenn Ryan
If you have the 2.0 framework installed, restrict AutoCAD to use v1.1.4322.
That was the cause/solution in my case.

-- Mike
___________________________
Mike Tuersley
___________________________
the trick is to realize that there is no spoon...
*Glenn Ryan
Message 3 of 9 (159 Views)

Re: TabbedDialogExtension

05-23-2005 11:41 PM in reply to: *Glenn Ryan
Mike,

Thanks for the reply. I did have 2.0 on the system as part of the C# 2005
Express install,
however I removed that a few weeks ago.

Do you still think it could be making the difference?

As far as restricting Acad to 1.1 are you talking about the acad.exe.config
file? If so, what should it look like?

Cheers,
Glenn.

"Mike Tuersley" wrote in message
news:4853342@discussion.autodesk.com...
If you have the 2.0 framework installed, restrict AutoCAD to use v1.1.4322.
That was the cause/solution in my case.

-- Mike
___________________________
Mike Tuersley
___________________________
the trick is to realize that there is no spoon...
*Glenn Ryan
Message 4 of 9 (159 Views)

Re: TabbedDialogExtension

05-24-2005 03:38 AM in reply to: *Glenn Ryan
Well, I sent the dll to a friend and asked him to load it in his 2006 and
still no go. He doesn't have .NET 2.0 loaded.
I'm at a loss at this point, unless somebody can give me another direction
to try
or if anybody has some sample code like this to post...

Cheers,
Glenn.
*Tim Strandberg
Message 5 of 9 (159 Views)

Re: TabbedDialogExtension

05-24-2005 06:19 AM in reply to: *Glenn Ryan
Mike,

Do you have any sample code for implementing a tabbed extension using C#?

Thanks,

Tim Strandberg


"Mike Tuersley" wrote in message
news:4853342@discussion.autodesk.com...
If you have the 2.0 framework installed, restrict AutoCAD to use v1.1.4322.
That was the cause/solution in my case.

-- Mike
___________________________
Mike Tuersley
___________________________
the trick is to realize that there is no spoon...
*Mike Tuersley
Message 6 of 9 (159 Views)

Re: TabbedDialogExtension

05-24-2005 08:13 AM in reply to: *Glenn Ryan
> Do you have any sample code for implementing a tabbed extension using C#?
No, not at the moment. Here is one in VB.NET though that will get you
going. It's done in VS2003 and you can only add a tab to 2006+

-- Mike
___________________________
Mike Tuersley
___________________________
the trick is to realize that there is no spoon...
*Mike Tuersley
Message 7 of 9 (159 Views)

Re: TabbedDialogExtension

05-24-2005 08:26 AM in reply to: *Glenn Ryan
Don't forget to add the mgd references!

-- Mike
___________________________
Mike Tuersley
___________________________
the trick is to realize that there is no spoon...
*Albert Szilvasy
Message 8 of 9 (159 Views)

Re: TabbedDialogExtension

05-24-2005 10:39 AM in reply to: *Glenn Ryan
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.
*Glenn Ryan
Message 9 of 9 (159 Views)

Re: TabbedDialogExtension

05-24-2005 04:34 PM in reply to: *Glenn Ryan
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.
Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.