I do the follwing :- import the type library using classWizard to import msado15.dll
whene finish the importing every thing seems to be ok , the classes of (ado,_recordset,....) were appears in the classView tree
my Questions is that :-
is this the right way to use Ado in mfc ?
is that way canceling needing of #import dirctive ?
how can i complete the connections and get records using that way ?
Using the class wizard is different than using #import. Both create wrapper around the COM interfaces.
YOu either use the MFC wrappers by the class wizard or the COM-Wrapper created by #import.
I usually always use #import with raw_interfaces_only and never relay on the wrappers created by #import or MFC.
I have the best experience in using the raw COM interfaces and directly checking the HRESULTs and using ATL Smartpointers.
The class wizard lets you import interfaces from a type library and builds MFC wrapping classes for those interfaces. The #import directive also imports interfaces from a type library but builds 'smart' COM-wrappers around them.
The two are not mutually exclusive, but I don't see the point of using both.
Here are some additional readings for you:
Adding an MFC Class from a Type Library
#import Directive (C++)
Related
The problem
I would like to use c++ to create an application that uses the new macbook pro touch bar. However I am not able to find any really good resources. And apple does not have any docs on using c++ to program the touch bar.
What I have done
I found this article on c++ and the touch bar, However I cannot find either of the header files for the script GLFW/glfw3.h and GLFW/glfw3native.h. These both seem critical to the script working.
More on the issue
Even if the above article's script works, there are no official docs for programing the touch bar with c++ (That I know of). I think that this is an important thing to have given the fact that many, if not most applications are written in c/c++.
Thank you in advance for the help!
So the article that you link to basically does not need the GLFW/glfw3.h and GLFW/glfw3native.h files if you are not using GLFW.
What UI framework are you using for your C++ app?
Unless it is still using Carbon, at the lowest level, the framework will be creating NSWindows to actually have windows in the UI. You need to get access to the NSWindow that your framework is using to host it the UI. If it is still using Carbon, I think you are probably not going to be able to accomplish this.
If the framework provides some mechanism to get the native platform window (which will be an NSWindow), you would replace the author's call to glfwGetCocoaWindow(window); with the correct call from your framework.
If the framework does not provide access to the NSWindow, then you will need to use the code that is commented out at the bottom of the article to attach your touchbar to the windows in your app.
Please note that all that code is Obj-C code; you'll need to have at least one .m or .mm file in your project to provide that Obj-C glue code to get access to the touchbar. Basically that code is a C-calleable wrapper around the Cocoa API.
Also note that you'll need to expand the list of buttons and actions for all the different things you want to put in the touchbar. You could add your own wrapping API so that the construction of the toolbar is done from C++ and registers actions that call-back into your C++ app to handle the events.
Fundamentally though, the touchbar is not available on any other platform, so there is no great benefit to trying to avoid writing Obj-C to implement your touchbar as that code will only run on macOS anyway. If you use .mm files to implement Obj-C++ for this code, you can still call into your C++ objects from your touchbar code.
In .NET WebBrowser Control, there is a Property named "ObjectForScripting". As you call window.external in Javascripts, it calls then the Function in .Net Code.
I'm wondering if this exists also in C++ wxWebView? Or maybe in another C++ GUI Library WebControl..
There is nothing like this in wxWebView at the moment, just the simple RunScript method. However there has been some work on doing this using the Webkit based wxWebView backends, more information is available here.
This is a followon to a prior question I posted (see here). I'm trying to call my native/C++ code from Javascript running in an HTML page. The answer in the referenced question was to create a COM object. The Javascript can then create an instance of the COM object and invoke methods on it getting to the native/C++ code.
So now I'm left with trying to create a simple COM object to accept the call from the Javascript. It looks like the way to go is to create a DLL and put the COM object in that DLL. Years ago I did tons of reading on COM and have tried to forget it since then :) Now I'm getting a headache wondering how to go about this easily without becoming an expert in COM.
Is there a simple/easy way to setup a DLL with a COM object that you would recommend?
EDIT: My application is written using native C++/Win32/MFC. I have an MFC dialog which uses the IE ActiveX browser control to render locally generated HTML. Currently the button handler code is all in Javascript, but as you can see from the referenced question, my goal is to handle it on the C++ side.
As I know the easy and fast way to create COM objects is to create an ATL project.
here's a nice tutorial that explains the steps to follow.
Scenario:
I am trying to migrate a C++ application to WinRT/Metro Style. This application uses an ATL/COM object that implements an IDispatch interface by using the class IDispatchImpl, however, according to MSDN IDispatchImpl is not available for Metro Style applications.
My ATL/COM class looks like this:
class MyATLClass :
public IDispatchImpl<IMyDispInterface, &IID_IMyDispInterface, &LIBID_MYLIB, 1, 0>,
public CComObjectRoot,
public CComCoClass<MyATLClass,&CLSID_MyATLClass>
{
...
}
Question:
Is there any replacement in WinRT for IDispatchImpl?
The replacement could involve deriving from different classes and discarding my IDL file for example. My ultimate goal is just to be able to do QueryInterface on an instance of MyATLClass and get a reference through IMyDispInterface. I can also include all my files (library and application) in a single project, but I do want to avoid changing the code where IMyDispInterface references are used if possible.
Re-implementing my COM/ATL class as a WRL based component is probably the best choice in this scenario (Thanks Larry). More information is provided on these video posts:
Porting a desktop app to a Metro style app
The Windows Runtime Library (WRL)
I'm trying to implement a plugin for a customer who has an interface defined in a TLB file, which they use to get video from my system.
I've got an ActiveX control based on COleControl, which needs to implement this interface, but am having trouble figuring out how to do it correctly. I'm using DISP_FUNCTION_ID and DISP_PROPERTY_ID to hook up methods/properties to the dispinterface in the TLB, but can't figure out how to register that my class is implementing the interface so that QueryInterface will pick it up.
I'm kinda new to the whole COM thing, so please be gentle, but any help would be greatly appreciated :)
Cheers,
Callum
TLB file is giving you the definition for Development. To register the component you actually need the COM dll. To register the DLL you need "REGSVR32" command (http://ss64.com/nt/regsvr32.html). If you are not able to create your class as part of COM Library you can refer the example http://www.codeproject.com/KB/atl/SimpleATLCom.aspx, This will give you simple COM object.