.NET Form Controls Display Solid Black When App Runs Inside AutoCAD 2016

.NET Form Controls Display Solid Black When App Runs Inside AutoCAD 2016

JamesDG1
Participant Participant
1,425 Views
4 Replies
Message 1 of 5

.NET Form Controls Display Solid Black When App Runs Inside AutoCAD 2016

JamesDG1
Participant
Participant

I appreciate the help I've received in the past through this forum, and I have a new problem that has me vexed ;-)!

 

First:

OS: Windows 10 x64

AutoCAD: AutoCAD 2016 x64

Development Environment: Visual Studio 2017

AutoCAD managed code reference .dlls for AutoCAD 2016

Target .NET Framework: 4.5

Language: VB.Net

 

I have a veeeery long term (read: very slow developing) project with multiple custom commands for AutoCAD that I am porting from VBA (where I've had good success over the years).

 

Late last fall I switched from developing in VS2012 to VS2017, per recommendations I received here, all to good effect. Recently, though (read: in the last two or three weeks), I've been seeing a very strange behavior when I start Debug mode (F5) from VS. AutoCAD starts up fine, NETLOAD loads my just-now-newly built .dll fine, but when I run one of my custom commands I see this:

 

Screen Cap - Running.PNG

 

Meanhwile, back in Visual Studio, the Form Designer looks like this:

 

Screen Cap - Developing.PNG

 

I am using all standard Windows.Forms.Controls object types, but TextBoxes and RadioButtons especially appear with solid black backgrounds and exaggerated black borders, and TextBox text is barely discernible unless selected. None of this bodes well for UI usability.

 

Not long before all this started happening, I spent time experimenting with a custom control derived from Windows.Forms.Label that would paint a colored gradient background inside the Label's borders, and would also paint a contrasting color drop shadow for the Label's .Text property. I accomplished this with a custom OnPaint event handler, all per directions and discussions I read in numerous places on the general subject of deriving custom controls from built-in .NET Windows.Forms controls...and as far as I can tell, none of which should have had an effect of any kind on anything else in the app.

 

I have since removed both the custom Label control and the references to its .dll from my project, thinking there may have been a connection. Alas, I still have the goofy dialog box display from inside AutoCAD. Weirder still, another of my custom command dialogs shows a similar issue, while a third one displays just fine! None of the form displays in their VS designer windows show any problems.

 

Skipping for the moment the visible differences in formatting of the dialog window's borders and title bar between the IDE/Designer rendering and that inside AutoCAD, the closet thing I've had so far to what feels intuitively like an approach is something to do with (...I dunno...) a difference between the IDE and running AutoCAD in where the called code for control objects exists (...should all be the same .NET objects...right?). Maybe there's a setting somewhere in Visual Studio that I changed inadvertently...again, I just do not know.

 

At this point, I'm not even sure just what questions to ask, so any and all help will be appreciated. And I will do my best to answer questions that anyone believes may help illuminate the problem and/or a solution.

 

Thanks in advance, and best regards,

 

--James G.

0 Likes
Accepted solutions (1)
1,426 Views
4 Replies
Replies (4)
Message 2 of 5

ActivistInvestor
Mentor
Mentor

Is it possible that your custom control experiments could have unintentionally altered the properties of other controls on the form? Are you using Version Control? Can you roll back the project to the point before you introduce the custom control to see if the problem exists there as well?

 

The fact that the problem appears only when running and not in the IDE suggest that an event handler is responsible because they don't run in the IDE.

 

 

0 Likes
Message 3 of 5

JamesDG1
Participant
Participant
@ActivistInvestor wrote:

    Is it possible that your custom control experiments could have unintentionally altered the properties of other controls on the form? Are you using Version Control? Can you roll back the project to the point before you introduce the custom control to see if the problem exists there as well?

    The fact that the problem appears only when running and not in the IDE suggest that an event handler is responsible because they don't run in the IDE.


 

I'm certain no other control properties were altered--I went over all of them pretty thoroughly. And no, I do not use version control (...maybe I should?...a separate topic, though...).

 

This dialog as yet has no event handlers, other than what are buried in the controls themselves, so not directly accessible.

 

Other reading/searching I've done suggests a possibility of something altered in the project manifest file, but again, I have no idea where or what to look for.

 

Thanks for the reply!

 

Best regards,

 

--James G.

0 Likes
Message 4 of 5

Virupaksha_aithal
Autodesk Support
Autodesk Support

Hi,

 

do you have any other forms in the module? what are their behavior? if other forms are working fine, please go through the source of the form which is giving issue to see code has any reference to background color...or any other code from custom control you tried.

 

 

 



Virupaksha Aithal KM
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 5 of 5

JamesDG1
Participant
Participant
Accepted solution

Virupaksha,

 

Thanks. Yes, I checked everything. (Or...at least...I thought I did!).

 

Before I read your post I stumbled across the solution. The Form's TransparencyKey property was set to Transparent:

 

Screen Cap - Solution - 1 of 2.PNG

 

The form that worked fine did not have this setting, it had the default TransparencyKey of White. Setting the problem form's TransparencyKey back to the default value...

 

Screen Cap - Solution - 2 of 2.PNG

 

...solved the problem:

 

Screen Cap - Solution - 3 of 3.PNG

 

Thanks to all who replied. An object lesson, I think, than when you're checking form and control properties to check them all! Smiley Very Happy

 

Also an object lesson (...and note-to-self for future efforts...) that when an ObjectARX app uses a Windows.Forms.Form object with its TransparencyKey set to Transparent, weird things happen.

 

Thanks again, and best regards to all,

 

--James G.

0 Likes