.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

TabbedDialogExtension

8 REPLIES 8
Reply
Message 1 of 9
Anonymous
856 Views, 8 Replies

TabbedDialogExtension

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.
8 REPLIES 8
Message 2 of 9
Anonymous
in reply to: Anonymous

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...
Message 3 of 9
Anonymous
in reply to: Anonymous

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...
Message 4 of 9
Anonymous
in reply to: Anonymous

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.
Message 5 of 9
Anonymous
in reply to: Anonymous

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...
Message 6 of 9
Anonymous
in reply to: Anonymous

> 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...
Message 7 of 9
Anonymous
in reply to: Anonymous

Don't forget to add the mgd references!

-- Mike
___________________________
Mike Tuersley
___________________________
the trick is to realize that there is no spoon...
Message 8 of 9
Anonymous
in reply to: Anonymous

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.
Message 9 of 9
Anonymous
in reply to: Anonymous

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.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost