|
[Edit - Sorry - I didn't notice it was a method function call!!!]
For a free function pointer, the following will work:
<font>typedef void (*FnPtr)();
FnPtr fp;
fp();</font> i.e. you need the brackets to turn a function pointer into a function call.
For a member function pointer, you need the brackets and a class instance:
<font>typedef void(CMyClass::*Func_Ptr)(void);
CMyClass c;
Func_Ptr fp;
(c.*fp)();</font> If you want to call it from a method of the class, using the instance of the class pointed to by this , you'll need to explicitly state that:
<font>void CMyClass::Dispatch(int c)
{
CommandFunctionMap::iterator commandIter = g_cmdfuncts.find(c);
if( commandIter != g_cmdfuncts.end() )
{
(this->*commandIter->second)();
}
}
</font>
In this case, I've used the member function pointer through the iterator, rather than dereferencing it explicitly.
HTH!!!
Last modified: 20mins after originally posted --
|
|
|
|
|
|
Hello All,
I have a DLL which is builded in C# and i have to use this one into shared addin.
in shared addin project i am getting class not register error but i have prepared a simple MFC application in which i am able to crete instance of that class and also able to call function from that DLL.
can anybody tell me what is the problem with shared addin why it is not able to create instance
please share your knowledge.............
|
|
|
|
|
What does this have to do with ATL/WTL/STL?
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
I create a new Windows Service Project. I find there is not _ATL_MIN_CRT in both Unicode Release build configuration. I think it is weird so I added _ATL_MIN_CRT in them. Then building action failed with message "unresolved external symbol _main".
why can not define _ATL_MIN_CRT in Win32 Service Project?
|
|
|
|
|
Look at the documentation:
MSDN wrote: Remember that using the _ATL_MIN_CRT macro does not guarantee that no functions from the CRT will be required. If you use a function that requires the CRT startup code to operate properly, you will get the following linker error:
LIBCMT.LIB(crt0.obj) : error LNK2001: unresolved external symbol _main Providing your own implementation of _main does not solve this problem: you must either remove reliance on the functions that require the CRT startup code, or you must either statically link the startup code in your image or dynamically link to the CRT. When _ATL_MIN_CRT is used without the /GS- compiler option, ATL headers will require the static CRT library.
What that says is that your service is using C run-time library functions that rely on having the C run-time startup code. Possibly malloc (maybe via new ?).
|
|
|
|
|
|
Looks like a regular property to me
Steve S
Developer for hire
|
|
|
|
|
sorry, the question has been modified, I mean to get the name in the atl control , not from the container.
|
|
|
|
|
But my reply still stands. Presumably the container has named the control, which it would do, presumably, by setting a property of the control...
Steve S
Developer for hire
|
|
|
|
|
I have solve the problem.
LPOLECLIENTSITE lpSite;
GetClientSite(&lpSite);
EnumAllControlNames(lpsite);
void CRadioButton::EnumAllControlNames(LPOLECLIENTSITE lpSite)
{
LPOLECONTAINER lpContainer;
LPENUMUNKNOWN lpEnumUnk;
// Note that the IOleContainer interface is currently defined as
// mandatory. It must be implemented by control containers,
// in the OLE Control Containers Guidelines.
HRESULT hr = lpSite->GetContainer(&lpContainer);
if(FAILED(hr)) {
OutputDebugString(_T("Unable to get to the container.\n"));
return;
}
// OLECONTF_EMBEDDINGS is used to retrieve OLE Controls.
// OLECONTF_OTHERS is used to retrieve other objects such as
// Visual Basic internal controls
hr = lpContainer->EnumObjects(
OLECONTF_EMBEDDINGS | OLECONTF_OTHERS,
&lpEnumUnk);
if(FAILED(hr)) {
lpContainer->Release();
return;
}
LPUNKNOWN lpUnk;
while (lpEnumUnk->Next(1, &lpUnk, NULL) == S_OK) {
LPOLEOBJECT lpObject = NULL;
LPOLECONTROLSITE lpTargetSite = NULL;
LPOLECLIENTSITE lpClientSite = NULL;
LPDISPATCH lpDisp;
hr = lpUnk->QueryInterface(
IID_IOleObject, (LPVOID*)&lpObject);
if(SUCCEEDED(hr)) {
// This is an OLE control.
// Navigate to the Extended Control because Visual Basic 4.0 uses
// Extended controls.
hr = lpObject->GetClientSite(&lpClientSite);
if(SUCCEEDED(hr)) {
// You have the IOleClientSite interface
hr = lpClientSite->QueryInterface(
IID_IOleControlSite, (LPVOID*)&lpTargetSite);
if(SUCCEEDED(hr)) {
// You have the IOleControlSite interface
// Get the IDispatch for the extended control.
// Note that Extended controls are optional in the OLE
// specifications for OLE Control Containers.
hr = lpTargetSite->GetExtendedControl(&lpDisp);
}
}
}
else {
// This is either an internal VB control or the
// VB form itself.
hr = lpUnk->QueryInterface(
IID_IDispatch, (LPVOID*)&lpDisp);
}
if(SUCCEEDED(hr)) {
VARIANT va;
VariantInit(&va);
DISPID dispid;
DISPPARAMS dispParams = { NULL, NULL, 0, 0 };
// Get the names of all the controls present in a VB form.
LPWSTR lpName[1] = { (WCHAR *)L"Name" };
hr = lpDisp->GetIDsOfNames(IID_NULL, lpName, 1,
LOCALE_SYSTEM_DEFAULT, &dispid);
if(SUCCEEDED(hr)) {
hr = lpDisp->Invoke(dispid/*0x80010000*/, IID_NULL,
LOCALE_SYSTEM_DEFAULT,
DISPATCH_PROPERTYGET |
DISPATCH_METHOD,
&dispParams, &va, NULL, NULL);
if(SUCCEEDED(hr)) {
CString szTmp((LPCWSTR)va.bstrVal);
// szTmp now has the name.
OutputDebugString(_T("And the name is ... ") + szTmp +
_T("\n"));
}
}
lpDisp->Release();
}
// Release interface pointers.
if(lpObject) lpObject->Release();
if(lpTargetSite) lpTargetSite->Release();
if(lpClientSite) lpClientSite->Release();
lpUnk->Release();
} // End of While statement
// Final clean up
lpEnumUnk->Release();
lpContainer->Release();
}
|
|
|
|
|
Hello,
what functions that are used to block Print Screen which is key in keyboard in C++?
thanks in advance
|
|
|
|
|
I don´t know; but this might help
http://www.vbforums.com/showthread.php?t=291473
cheers
You have the thought that modern physics just relay on assumptions, that somehow depends on a smile of a cat, which isn’t there.( Albert Einstein)
|
|
|
|
|
Why would you want to block Print Screen?
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
In a "Invisible" ATL ActiveX, is there a way to capture WM_DEVICECHANGE messages without creating a window from inside the control?
I'm calling
HDEVNOTIFY hDevNotify = RegisterDeviceNotification( GetForegroundWindow(),
&NotificationFilter, DEVICE_NOTIFY_WINDOW_HANDLE);
But I think GetForegroundWindow is returning the handle to I.E., so ultimately the control never receives the messages.
Thanks in advance.
|
|
|
|
|
Hi everyone,
I have a class that implements an interface that derives from IDispatch directly,and I want to add a new interface which also derives from IDispatch,and then derive my class from this interface too.Expectedly,my problem is ambiguouty (did I spell it correctly??).I use COM_INTERFACE_ENTRY2 macro,but i keep getting error "cannot instantiate abstract class" error in atlcom.h
this is the IDL file:
<code>library TheLibrary
{
importlib("stdole2.tlb");
[
object,
uuid(),
dual,
nonextensible,
helpstring("Primary dispatch interface for the class."),
pointer_default(unique)
]
interface ISomething : IDispatch
{
};
[
uuid(),
helpstring("help string.")
]
coclass CSomething
{
[default] interface ISomething};
[
uuid(),
nonextensible,
helpstring("the new Interface"),
]
dispinterface INewInterface
{
properties:
methods:
[id(0), helpstring("method default"), local] HRESULT DefaultMethod(void);
};</code>
and this is the COM mapping
BEGIN_COM_MAP(CSomething)
COM_INTERFACE_ENTRY(ISomething)
COM_INTERFACE_ENTRY2(IDispatch, ISomething)
COM_INTERFACE_ENTRY(IObjectWithSite)
COM_INTERFACE_ENTRY_IID(IID_IOleWindow, IDeskBand)
COM_INTERFACE_ENTRY_IID(IID_IDockingWindow, IDeskBand)
COM_INTERFACE_ENTRY(IDeskBand)
COM_INTERFACE_ENTRY_IID(IID_IInputObject,IInputObject)
COM_INTERFACE_ENTRY(IPropertyNotifySink)
COM_INTERFACE_ENTRY(INewInterface)
END_COM_MAP()
I tried using interface instead of dispinterface .Didn't help either.I know I'm missing something,but can't figure out what it is...
|
|
|
|
|
ajitatif angajetor wrote: ambiguouty (did I spell it correctly??)
No - ambiguity - close, though
Anyway - I've had a look through my code collection - I have a class that implements two IDispatch interfaces, in ATL 3.0 (it's an old VC6 project). Here's the relevant bit of the IDL:
[
uuid(01b836c6-51c8-4476-bf15-ae91b0fe74f6),
oleautomation,
dual
]
interface ICommands : IDispatch
{
[id(1), helpstring("method RereadEnvironment")]
HRESULT RereadEnvironment();
};
[ hidden, uuid(0309A24D-B3E7-4C6A-8ACD-B3F0F8FAA483) ] coclass ApplicationEvents
{
[default] dispinterface IDispApplicationEvents;
}
[
uuid(6c5658bc-946b-4bc7-94bf-5530cad3d654)
]
coclass Commands
{
[default] interface ICommands;
}; and code
class ATL_NO_VTABLE CCommands :
public CComObjectRootEx<CComSingleThreadModel>,
public CComCoClass<CCommands, &CLSID_Commands>,
public IDispatchImpl<ICommands, &IID_ICommands, &LIBID_DSWENVLib>,
public IDispatchImpl<IApplicationEvents, &IID_IApplicationEvents, &LIBID_DSWENVLib>
{
BEGIN_COM_MAP(CCommands)
COM_INTERFACE_ENTRY(ICommands)
COM_INTERFACE_ENTRY2(IDispatch, ICommands)
COM_INTERFACE_ENTRY(IApplicationEvents)
END_COM_MAP()
DECLARE_NOT_AGGREGATABLE(CCommands)
<class continues>
Don't know if there's anything obvious there - the COM map looks very similar to yours - what about the inheritance? Do you have an IDispatchImpl inheritance for each IDispatch interface you want to implement?
|
|
|
|
|
uuuuuuh,no.
I added an IDispEventImpl to inheritance list and it worked.Great help,thanks
|
|
|
|
|
Cool - glad I could help
|
|
|
|
|
hi all,
i need to migrate our vc6 atl service .exe from windows nt 4.0 to windows 2003.
i just register the service in windows 2003 without changing the existing code . After that, i gave the stop command in services tool for that service, it lead to a stopping for a long time and never it stops. So, I need to restart the server. Please suggest me any solution to stop the service ASAP.
Thanks.
Sumoon
|
|
|
|
|
Hi All,
I followed Michael Dunn's article on The Complete Idiot's Guide to Writing Shell Extensions - Part I[^], and created a pair of (two separate) extensions: one for creating file checksums; and a second for verifying. Reference: A File Checksum Shell Menu Extension Dll[^].
It is apparent these are mutually exclusive on Vista (I just retested on Windows 2000 - OK):
* Register both Create and Verify
- Only Create is available
* Register only Verify (unregister Create)
- Verify is available
Any ideas? I pasted part of the Registry Resource (to verify uniqueness of UUIDs). But I suspect it has to do with the way the handler registers. I verifed both are registered under HKEY_CLASSES_ROOT\*\shellex\ContextMenuHandlers.
Jeff
The Ctx prefix was added below so that the items would 'stack' on the Context menu.
HKCR
{
NoRemove CLSID
{
ForceRemove {7E745006-3E3F-42F8-B806-E24D4133439C} = s 'CtxVerifyHash Class'
...
and
HKCR
{
NoRemove CLSID
{
ForceRemove {571077DC-F353-43C8-ACAC-4DE4B7EFC4E3} = s 'CtxCreateHash Class'
...
|
|
|
|
|
Hi All,
A fresh build using Visual Studio 2005 (new project, not a port) did not resolve the issue. I did copy and paste content. I suspect it is the IDL file... Also, the issue is confirmed in XP.
Jeff
|
|
|
|
|
Hello all,
I am trying to add toolbar using shared addin(C++/ATL) using VS 2003.
i have successfully done with VS 2005 but on same i am getting error like _Commandbar::add function does not 4 argument but it is running in 2005.
can anybody tell what should be problem behind that.
Thanks
bankey
|
|
|
|
|
I've been working on an application that uses OLE DB to read and store data from an ODBC source (currently an access file on the local machine). Up until today everything has been working perfectly when I made some changes to the database structure and several query functions. The odd thing is I haven't changed the code in this function or the connection setup code. In the example below, the SQL statement is something to the effect of "SELECT * FROM Sensor WHERE SensorVar='Temperature' ORDER BY -SensorID;" which is a query that worked yesterday.
<br />
HRESULT hRet;<br />
if(FAILED(hRet=m_Accessor.Open(m_Sess,sSQL,m_Propset)))<br />
{<br />
return FALSE;<br />
}<br />
The function values with a hRet value of 0x80040E21, which corresponds with "Multiple step OLE DB operation generated errors" or DB_E_ERRORSOCCURRED, depending on which google result one believes. Since the problem occurred after the database changes (the net effect being the addition of a table) I'm inclined to believe the problem lies there, but I've included the relevant code and I'm open to any suggestions
Thanks!
<br />
CDataSource m_Source;<br />
CSession m_Sess;<br />
CCommand <CAccessor<CSomeAccessor>> m_Accessor;<br />
CDBPropSet* m_Propset;<br />
<br />
<br />
..............<br />
<br />
<br />
if(m_Source.OpenFromInitializationString(A2OLE(szBuff),FALSE)!=S_OK)<br />
{<br />
m_Source.Close();<br />
return FALSE;<br />
}<br />
<br />
if(m_Sess.Open(m_Source)!=S_OK)<br />
{<br />
m_Sess.Close();<br />
m_Source.Close();<br />
return FALSE;<br />
}<br />
<br />
m_Propset=new CDBPropSet(DBPROPSET_ROWSET);<br />
m_Propset->AddProperty(DBPROP_IRowsetChange,true);<br />
m_Propset->AddProperty(DBPROP_CANFETCHBACKWARDS,true);<br />
m_Propset->AddProperty(DBPROP_CANSCROLLBACKWARDS,true);<br />
m_Propset->AddProperty(DBPROP_UPDATABILITY,DBPROPVAL_UP_CHANGE|DBPROPVAL_UP_INSERT|DBPROPVAL_UP_DELETE);<br />
<br />
szBuff is a ODBC connection string.
modified 12-Jul-20 21:01pm.
|
|
|
|
|
Hi,
I am trying to create an ActiveX control in an ATL project through code. I can create the control but the interface is not showing on the window created.
I am using the following line of code:
========================================================
CComPtr<iunknown> pControl;
GridPtr spGrid;
static const IID IID_Grid = { xxxxx.......};
AtlAxWinInit();
// Paste Grid(ActiveX) in the main window.
AtlAxCreateControl( L"Grid.Grid.1",
hChild,
NULL,
0x00
);
// Get the interface on the grid
AtlAxGetControl( hChild, &pControl );
pControl->QueryInterface( IID_Grid, (void **)&spGrid );
==========================================================
Please suggest what can be the problem .
Regards,
Arjun
Arjun Marwaha
|
|
|
|
|