I am currently working with a 3rd party ActiveX Control (an editor for topographical data distributed by Cadcorp SIS). I have to do some fairly complex stuff with it in a VB.NET (framework 4) program and am finding that the API that comes with the control is quite limited.
As of now I have made a custom control which houses the control and acts as a wrapper for it to allow me to extend the API, which works fine, but What I would really like to do it give the control more events so that I can monitor what is going on with the data more closely.
I'm not sure how to go about doing this though...
I tried inheriting from the control and I can extend it just fine, but I can't figure out how to reuse it after that. Is there some way I can inherit the control and get it to appear in the toolbox so I can just drop it onto a form? Or do I have to load it programatically? If so, how can I do it?
Any pointers, examples, tutorials or alternative ideas as to how to do this kind of thing would be welcome.
If you are not seeing your control class in toolbox it doesn’t mean that you can’t use it just modify code from your form's designer to use your inherited class
Or
You can drag-and-drop your assembly (dll) from Windows Explorer to the
toolbox in VS.NET. Or you can right click on the toolbox in VS.NET and
choose Add/Remove items. Is this what you are looking for?
Also
<ToolBoxItem(True), ToolboxBitmap("MyNamespace.MyClass.bmp")> _
Public Class MyClass
Related
I want to make own UI control in c# and save it as dll. After that I want to import this library to the Enterprise Architect. It is possible? Maybe I can make other way?
I know about MDG technology, but there are some problems when I'm modifying the appearance of stereotype.
I also want to make the field "name" be more flexible - how to move it inside control?
So it is possible to import dll with custom controls to the EA or maybe some tips how to increase MDG?.
Yes you can use your own UI controls in EA. You can either launch them as popup from our add-in code, or you can use Repository.Window or Repository.AddTab to add your control in a docked window, or the main diagram tab.
You can find a simple working example using a docked window on my github repository
A more elaborate example is the EA Navigator for which you can find the code on github as well.
Soo... I am making a control like the Windows Update "panels".
Everything's fine up to the "container" part.
What I want to do is to allow the designer to place controls in a Panel which is inside my control.
(The panel's variable is held in my control's class and inside the control itself.)
How do I bypass this?
As a reference, you might want to try out this AeroWizard Control, which does this pretty well.
(Yes, I have looked at it and didn't find a clue but custom designers!)
As a side note, I'd rather not make a complicated designer class...
If you don't want to create a custom designer class, you should implement your control as a templated custom control, preferably inheriting from CompositeControl.
There doesn't seem to be a way to do the same in Windows Forms without a custom designer class. However, there's a nice, short, working example of such a designer here.
I've only just started using C#/VS this past week and wondered how to do something which, I think, should be quite simple:
What I want to do is extend the class used by a UI component and therefore implement my own methods in it - just for one instance of a UI component though. If I was using xcode/objective c I would normally just change the class name of the component in interface builder and it would become an instance of that class which would in turn extend the original UI class.
How do I do something comparable using C#/Visual Studio?
You can take any component class in Windows Forms and subclass it. Visual controls all derive from the Control class and you can do so as well.
If your component is a User Control (i.e., it derives from System.Windows.Forms.UserControl), it should automatically appear in the Toolbox after you build the project. For other components, you can add them to the Toolbox by right-clicking on the Toolbox and select Customize Toolbox, selecting the .NET Framework Components tab, clicking the Browse button, and selecting the DLL with the control.
Remember that all (or most) UI components are classes, so they can be "extended" just like any other class.
Some will have virtual members you can override to take special actions. In all cases, you can add properties, methods, and events to the components.
Once you've created and built them, you can use them from the Toolbox, just as though they were the "built-in" .NET components.
I am currently exploring the option of porting some older VB6 application to WPF with C#. The plan, in phase one, is to port several key forms and not all the application. The theoretical goal is to open the VB6 form in a container of some sort within WPF via an ActiveX dll.
Is this even possible?
I've tried looking at the Interop and can't seem to find a solid example of how get it to work with anything but Win32 controls, not a full form. I have full access to the old VB6 code and can modify it in anyway needed.
The following screenshot of the main WPF app would serve as the wrapper/container:
http://www.evocommand.com/junk_delete_me/main_menu_mockup.png
The current VB6 maintenance screen that would be loaded in the “white space” section on the right side of the previous screen.
I was able to accomplish the task with the following steps:
Created a new VB6 Active X Control Project. Copied and pasted the entire contents of the VB6 form controls and code behind into the new control. There are several elements that have to be handled in switching to a control:
you lose the ability to display
the caption of the form in the
previous manner. You can work around
it with alternate controls
(label/borderlesstextbox, etc) that
accomplish the same functionality if
needed. This wasn’t a priority since
each screen was being hosted in a
browser like tab system in our new
.Net project.
All mousepointer references have to
be changed from Me.Mousepointer to
Screen.mousepointer
You cannot use Me.Hide and have to
alternate events to hide the .Net
container.
Any and all references to
Me.[anything] have to be removed or
replaced with UserControl.[anything]
if they are applicable.
If you use any functions that
reference a
[yourcontrol].Contianer.Property on a
form they will need to be altered to
loop through the UserControl.Controls
collection instead and “Container” is
invalid for vb6 ActiveX controls
All non-modal forms/dialog boxes
must be removed from the project as
there is now no Hwnd to handle in WPF.
You get an error of 'Non-modal forms
cannot be displayed in this host
application from an ActiveX DLL,
ActiveX Control, or Property page'.
In our case we had a simple splash
screen that would display when certain
long processes/reports displayed to
let the user know what was running.
I was unable to directly add the VB6 control via the interop to a WPF project . As such a new .Net “Windows Form Control Library” project was created. A reference to the VB6 OCX was added to the project. The VB6 Control s were then added to the .Net toolbox by “right click” –> “Add Item” and pointing a com reference to the VB6 control ocx. The .Net control was then used to host/serve the VB6 Control.
To display host a form in the VB6 and get it to fire the necessary initialization functionality the VB6 OCX controls were defaulted in a Visible.False manner so they were initially added to the .Net OCX as invisible controls. When needed the VB6 control is set to visible = True which fires the UserControl_Show() event. All code formerly in Form_Load() was moved to this event. The show event was the easiest method of accessing the Form_Load as needed. MSDN: “The control does not receive Show events if the form is hidden and then shown again, or if the form is minimized and then restored. The control’s window remains on the form during these operations, and its Visible property doesn’t change.”
Wrapping the vb6 controls within a .Net Winform control resolved the issue with Radio/Option buttons being rendered as black as outlined elsewhere in one of my responses to this question without having to convert the frames to Picture boxes as suggested.
In the WPF app as a menu choice is selected xaml code is dynamically created and displayed via a wrapper with a WindowsFormsHost tag. A dynamically created control object from the .Net winform app is then pushed into the WindowsFormsHost tag on the xaml and the control is made visible on the .net project which fires vb6 UserControl_Show and then load and display of the vb6 form.
I think what you will have to do is extract the VB6 form contents into an ActiveX control. You can then expose this in your ActiveX dll and place that in your WPF form. I doubt it's possible to host a VB6 form within any other type of form.
Can you even load that VB6 form in another VB6 form? I suggest you get that working first.
There is no reliable way to set parent of a VB6 form. You can always hack it or use plain ActiveX control (UserControl in VB6) as UI container instead of VB6 forms.
I found a method to do what was needed within WinForms rather than WPF at this point.
http://www.codeproject.com/KB/vb-interop/VB6formsinNET.aspx
I figure if I can get it working 100% there I can port it over to WPF or worse case host the WinForm element in the WPF form if I absolutely have too (U-G-L-Y).
Anyway, I've gotten a bit closer, but am having a very odd issue with certain controls painting too the screen. Radio/Option buttons are rendering as solid black:
http://www.evocommand.com/junk_delete_me/optionbuttons.png
I've tried explicitly changing the controls' background color from buttonface to a fixed color and it still does it. I'm assuming it's a layering issue with the option buttons being within the frame control. I'm at a bit of a loss on how to proceed without massive rework of the VB6 content to change the options buttons to checkboxes. It's a hefty app and there are 600+ option button controls across the application that I don't exactly want to deal with.
EDIT:
I was able to confirm it has something to do with the layering of the option within a Frame control. If pulled out to the base form the issue does not occur:
http://www.evocommand.com/junk_delete_me/optionbuttons2.png
Using .NET 2.0 with WinForms, I'd like to create a custom, multi-columned menu (similiar to the word 2007 look&feel, but without the ribbon).
My approach was creating a control, and using a left/right docked toolstrip, I have constructed a similar look&feel of a menu. However, there are a few shortcomings of this solution, such as
the control can only be placed, and displayed within the form;
if the form is too small, some area of the control won't be displayed;
the control also have to be manually shown/hidden.
Thus, I'm looking for a way to display this control outside of the boundaries of the application. Creating a new form would result in title-bar deactivating on display, so that's also out. Alternatively, any other approach to create a customized menu would be very welcomed.
Edit: I don't want to use any commercial products for this; and since it's about a simple menu customization, it's not related to Microsoft's ribbon "research" in any way.
unless you are in the business of providing .net components, you should be looking to buy it off the shelf. Its a lot of work getting such a control right - There are already vendors providing this kind of UI. e.g. ComponentOne
if you are trying to build this component as a product, you should look at the link below. Apparently Microsoft has a 'royalty-free' license around the Office UI to protect their R&D investments. As of now you need to tell them that you are using something similar to the Office UI. More of that here
The MenuStrip class has a Renderer property. You can assign your own ToolStripRenderer derived class to customize the painting. It's a fair amount of work.