How to load an OCX using an .INF configuration file - c#

It's my first post, so if I’m posting wrong or something, please let me know!
I'm developing an application in C# where I have to stream picture and sound from an IP Camera.
I have found a SDK from the manufacturer of the IP camera which should make it possible to integrate the streaming process into an application.
The IP camera is a LevelOne FCS-0010, and the SDK contains an .OCX file, an .INF file and a PDF file, which describes the different configuration parameters for the .INF file.
And here's my question: how do I use the OCX file in my application?
According to some forums, the OCX can just be drag 'n dropped into the toolbar in VS and then drag 'n dropped onto a WinForms form. This actually goes pretty well!
But then I just get a clean ActiveX object into my application, nearly just blank. Probably the OCX component needs to be configured, but how?
I guess I have to use the -INF file in some way in my application, so the OCX component could be configured. However, I really can’t figure out how.

It has to be registered first, use the vendor's recommended install procedure. Then you need to generate a AxHost wrapper for control, that allows it to be placed on a Winforms form or a WPF ElementHost.
Two ways to do that. Right-click the toolbox, Choose Items, COM tab and pick the control from the list. Which might be hard to do or not work at all if you don't know the name of the control. Second way is to run the Visual Studio Command Prompt and type aximp foo.ocx. That produces an AxFoo.Interop.dll, you can put it on the toolbox through Choose Items, Browse tab.
Not every ActiveX control is compatible with .NET, window-less controls are not supported.

Related

When creating a custom file extension, is it possible to assign it an icon different from the application icon?

Hello wonderful people!
I have created some code for an application which upon startup, simply makes sure the registry has a key for my own file extension (or I guess 'class', as Windows calls it). It allows me to double-click a file with said extension and have it open with my program. Simple.
My query is this; is it possible for me to change the icon for this file class, to be different from the icon of my application? I would prefer to have some different icons for the various file extensions I'm registering, much in the same way that Photoshop for example gives a different icon for .PSD files than the actual application icon.
In simpler terms, I would like to mimic this behaviour but with my own icons and application:
Photoshop (the actual application):
Photoshop Document file:
I am working in C# and WPF. And I should also specify that the solution I'm looking for should be able to work in a scenario where I was to send my application to someone else to install on their computer; they should be able to see all the icons as described. I'd kindly request that in your answers you provide code examples, as I am not particularly familiar with working directly with the registry.
I should also specify that my application does have an icon, and this is currently what the custom filetype displays in Windows Explorer.

While dragging an item from my app, can I limit dragging only into Windows explorer and get the target path when done?

I'm implementing a drag and drop capability, that should allow users to drag files from my UWP C# app to an external target.
The problem is that the file is not necessarily available when dragging starts, and needs to be fetched/processed so it's ready for the drag operation.
When the file is not available yet, dragging should only be allowed to Windows explorer with the possibility of getting the target path where the file was dropped to.
The app will likely have the broadfileSystemAccess restricted capability, so a possible solution to allow dragging of unavailable items will be to drag a dummy item, and replace it with the actual file, once it's fetched.
The only relevant events I found for the draggable element flow are: dragStarting and dropCompleted, and it seems that none of them provide the relevant API.
Is there any more API which I might have missed, or any other ideas about how this might be possible?
Thanks

VS crashes and winforms data lost

I am developing an application using Visual Studio 2019 and I am designing winforms.
Visual Studio commonly crashes when I am creating the forms by freezing, and recently my designed winform has somehow disappeared (even though I saved it). When i open it it shows as the default winform that is shown when a new one is created:
When I browse the solution explorer it seems that I can still see all the components I had added to the form:
Finally, when I try to restart and manually add the components back, I get an error message saying that the component can't be added due to duplication - which is probably because they are somehow still there (as shown in the solution explorer) but the data has been corrupted somehow:
If anybody has any idea of how to recover the data and the winform, I would very much appreciate it. If any additional information is required, please let me know. Thanks!
According to your description, first, the controls actually exist, but they are not
displayed in the design window.
You can try to check whether the. add statement of each control added to the window still
exists in the .Design.cs file.
If not, you can add it manually.
Second, solution explorer shows the missing components, but there is an error in adding
components. It means that only the declaration of this control in the .Design.cs file does
not assign a value to this control. You can delete the declaration of the component in the
.Design.cs file, and then add the component in the design interface.
Result:

Use WPF component from external .exe

Here's the situation:
We have an existing .NET executable that contains an application using WPF components (dialogs and forms). This executable was created using Gupta Team Developer 6.1, but I'm not sure that is relevant to my question. We'd like to re-use some of these forms in a C#-application, but this is proving difficult.
When we include the external components, either in XAML or by instantiating them in code, they look OK (i.e. fields, buttons, layout etc.), but the event wiring seems to be missing. Nothing happens when pressing buttons and tables/grids are empty.
I've read previous articles on this site on using external WPF components, but they all mention external assemblies compiled as control libraries. Are we trying to do something that's not really possible?
P.S As an experiment we've tried to instantiate the App-object from the executable directly and this brings up a fully functional version of the entire application (well, duh), but we'd really like to be able to pick and choose from the individual forms/dialogs.

Drag Files From ListView

It seemed farily straight forward learning how to process files dropped onto a ListView control. But I can't seem to find anything about dragging files FROM the ListView control.
To complicate things, the ListView control is displaying an FTP directory. So I don't want to actually download the files until I confirm they have been dropped on a window that will accept them.
I know that it's possible to provide the actual data for a drag-and-drop operation only after the drop has taken place. But I'm having trouble finding anything about doing this from a ListView control using C# and Webforms.
Any tips?
Thanks!
The best link I've found on this issue yet is at Delay's Blog.
He starts by saying "This code [...] and is specifically targeted at scenarios where an application wants to allow the user to drag an element to a folder and create a file (or files) dynamically on the drop/paste. The standard .NET APIs for drag-and-drop don't support this scenario [...]"
Wow, that's the answer. For all the problems I have with C# and .NET, I run into yet another obstacle. He does have some code to workaround this. I'll be checking that out.

Categories