interop

Can/how do you host a full VB6 Form in a C# WPF app?

元气小坏坏 提交于 2019-11-30 09:51:54
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

Prevent JavaFX thread from dying with JFXPanel Swing interop?

杀马特。学长 韩版系。学妹 提交于 2019-11-30 09:35:34
I'm embedding several JFXPanels into a Swing app and the JavaFX thread dies when the JFXPanels are no longer visible. This is problematic because creating another JFXPanel after the JavaFX thread dies will not start another JavaFX thread and thus the JFXPanel will be blank. From what I can tell the JFXPanel ctor starts the JavaFX thread by calling: PlatformImpl.startup(new Runnable() { @Override public void run() { // No need to do anything here } }); Later on once the JFXPanel has a parent component its addNotify method is called which calls registerFinishListener which registers a

WPF WinForms Interop issue with Enable / Disable

为君一笑 提交于 2019-11-30 09:12:52
I have a WinForms usercontrol hosting a WPF custom Listbox in it. After the WinForms user control gets disabled and then re-enabled the WPF control in the WinForms usercontrol is unresponsive. Has anyone else experienced this? We had to hack a soultion into remove and re-add the element host each time the control gets disable / enabled to fix the issue. WinForms wpfControl.Enabled = false; ... wpfControl.Enabled = true; Hack for fixing it in the WinForms EnabledChanged method for the usercontrol if ( Enabled ) { ElementHost oldEh = ctlElementHost; ElementHost eh = new ElementHost(); eh.Name =

Converting images from word document into bitmap object

落爺英雄遲暮 提交于 2019-11-30 08:44:24
问题 As per project requirement we need to convert images from word document into bitmap object. To achieve this we tried to convert inlineshape object from Microsoft.Office.Interop.Word dll into bitmap. However unable to get success, getting clipboard object as null. Please find the code which we tried as below; using System.Drawing; using Microsoft.Office.Interop.Word; namespace WordApp1 { class Program { static void Main(string[] args) { Application wordApp = (Application)System.Runtime

How to know if native method is safe / unsafe?

可紊 提交于 2019-11-30 08:43:18
I implement this function : GetSystemPowerStatusEx & GetSystemPowerStatusEx2 according to this article on MSDN , I should create a class named according to the functions I will use, but my question is : How can I know in which class I should put GetSystemPowerStatusEx & GetSystemPowerStatusEx2 ? I'm lost... Thanks for help. [EDIT] My question is : which of these three class names are the good one for me (NativeMethods / SafeNativeMethods / UnsafeNativeMethods) ? These methods should be in one of the following classes: NativeMethods - This class does not suppress stack walks for unmanaged code

How to change the size of a picture after inserting it into a word document

北城余情 提交于 2019-11-30 08:34:31
问题 I'm adding a picture to a word document at a certain bookmark. However, the picture is too big and is forcing text off the page, so I need to be able to change the size of the picture after it is in the word document. 回答1: When you insert the image, it should return you an InlineShape, which you can modify: Word.Application app = new Word.Application(); var doc = app.Documents.Open(@"C:\Users\SomeUserName\Desktop\Doc1.docx"); var shape = doc.Bookmarks["PicHere"].Range.InlineShapes.AddPicture(

Excel Interop - Draw All Borders in a Range

一笑奈何 提交于 2019-11-30 08:09:02
问题 I see from Microsoft's documentation that I can access the particular border edges of a cell using the 'xlBordersIndex' property and for example set the border style for the left edge of a cell: range.Borders[Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeLeft].LineStyle = Excel.XlLineStyle.xlContinuous; But what if I just want to draw all borders? I have tried range.BorderAround2(); but that just draws a box around the range itself, which I understand. So then I tried range.Cells

Is C NULL equal to C++11 nullptr

空扰寡人 提交于 2019-11-30 07:55:47
问题 I like to use nullptr instead of NULL. Now I call a C function (from libjansson in this case). NULL in C is implementation defined. For nullptr I found that "A null pointer constant is an integral constant expression (5.19) rvalue of integer type that evaluates to zero". So the safest thing to do: auto string_obj=json_object_get(m_handle,name); if(string_obj!=NULL) { auto string=json_string_value(string_obj); if(string!=NULL) {return string;} } return nullptr; Do I really need that or can I

Accessing Delphi DLL throwing ocasional exception

空扰寡人 提交于 2019-11-30 07:46:06
When I'm calling a Dll method it sometimes throws an exception, and sometimes doesn't. I'm calling it like this: public class DllTest { [DllImport(@"MyDll.dll")] public extern static string MyMethod(string someStringParam); } class Program { static void Main(string[] args) { DllTest.MyMethod("SomeString"); } } And the exception I get sometimes is this: AccessViolationException Attempted to read or write protected memory. This is often an indication that other memory is corrupt. Does anyone have any idea why I only get this exception sometimes ? Why does it run smoothly sometimes? David

Setting dllimport programmatically in C#

半世苍凉 提交于 2019-11-30 07:12:25
I am using DllImport in my solution. My problem is that I have two versions of the same DLL one built for 32 bit and another for 64 bit. They both expose the same functions with identical names and identical signatures. My problem is that I have to use two static methods which expose these and then at run time use IntPtr size to determine the correct one to invoke. private static class Ccf_32 { [DllImport(myDllName32)] public static extern int func1(); } private static class Ccf_64 { [DllImport(myDllName64)] public static extern int func1(); } I have to do this because myDllName32 and