|
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
|
|
|
|
|
try this:
ShowWindow(hChild, SW_SHOW);
IMO is more easy to create an activex control with the CAxWindow class, because you can pass style, position on create method.
[]'s
Clebson
|
|
|
|
|
I wrote a prog that parses files in certain format,
extracting some UTF8 strings (language may be
arbitrary) out of these files
and placing these strings in Window.Forms controls
like RichEdit and ListBox. This program was written
originally in C#.NET, and the strings were correctly
drawn in the corresponding controls via using
GetString() method of System.Text.Encoding.UTF8.
Now I'm translating the prog from .NET to WTL.
The problem is that I failed to make WTL controls
(derived from CListViewCtrl and CRichEditCtrl templates)
to correctly interpret extracted multibyte UTF8 strings.
The compiler settings for the project are default:
"Use multibyte characters" (_MBCS).
Besides, I set explicitly code page to CP_UTF8 writing
"_setmbcp(CP_UTF8);" in the .OnCreate() handler in MainFrame.cpp.
However it produces no effect: instead of, say, cyrillic strings
of size N there is drawn an abracadabra
of size 2N, i.e. the corresponding controls interpret the string as
the sequence of ordinary bytes instead of the sequence of UTF8 characters
2 bytes wide each.
The attempt to convert UTF8 strings to Unicode with MultiByteToWideChar()
failed as well. Though the resulting strings are correct unicode strings,
substituting them into controls (with LPCTSTR cast -- otherwise source
failed to compile) leads to drawing the first char only for ordinary ASCII
symbols and to drawing an abracadabra (of different kind than that without
unicode conversion). If one substitutes in the controls
CString(UnicodeString) instead of pure Unicode string, then ASCII
strins are represented correctly, but in place of cyrillics stand
a sequence of "?" (of correct length N).
So the question is: do there exists a way to compile the project
with _MBCS option (instead of _UNICODE -- which produces a big number of
error messages all over the code and I would not like to rewrite the whole
code) and to draw, nevertheless, the strings correctly inside WTL controls?
|
|
|
|
|
Windows doesn't use UTF-8 internally. 9x uses the ANSI code page, and NT uses UTF-16. Your choices are:
Do an MBCS build and convert from UTF-8 to the ANSI code page. This can lose data if the code page doesn't contain a character in the input. This is your only choice on 9x.
Do a Unicode build and convert from UTF-8 to UTF-16. You can then pass those strings to APIs and controls.
If you don't care about 9x support, doing a Unicode build is the way to go.
|
|
|
|
|
Thanks for Your kind answer!
Michael Dunn wrote: Your choices are:
Do an MBCS build and convert from UTF-8 to the ANSI code page. This can lose data if the code page doesn't contain a character in the input.
Well, this chice is bad for me: UTF8 strings extracted
from files can correspond to arbitrary ANSI code pages
or even to some mixture of them. I wonder only why
the choice of the "universal" code page CP_UTF8
has no effect on the visualization of strings in WTL controls.
Michael Dunn wrote: This is your only choice on 9x.
Eh, well. I'm not worried about 9x compatibility too much, if at all
Michael Dunn wrote: Do a Unicode build and convert from UTF-8 to UTF-16.
That's exactly what I've done yesterday. It took me not more
than 40 minutes to react on several dozens of compiler errors,
arising while compiling with _UNICODE,
replacing char*'s and ordinary string manipulation routines by their
"wide" versions. Now everything's great
|
|
|
|
|
Hello all,
I am making a simple ATL Project and in which i am adding a ATL Simple Object.
i have to register this object as word addin.
anybody have idea, how it is possible?
please share with me.
Thnaks
bankey
|
|
|
|
|
Hi,
I currently have a working BHO that receives several events fired from its browser through a SINK_MAP, but Im missing an event, an event fired from a change of focus. IE events ID contained in IWebBrowser2 dont seem to have an event for that. The closest thing I managed to extract form the Browser pointer was the window object which has window.blur and window.focus methods, and which events are usually handled in JavaScript. My question: can I handle these envents in C++ and if so whats the interface DIID and event that I want to look for.
|
|
|
|
|
How can ATL be used for non COM applications. What particular aspect of it is being contributed to the non COM application eg. a win32 app.
|
|
|
|
|
The windowing classes in ATL don't require COM. There is also WTL if you need a GUI library with more features.
|
|
|
|
|
What does the following code do?
PROCESS_INFORMATION procinfo;<br />
STARTUPINFO stinfo;<br />
<br />
if ( CreateProcess(NULL, chCmdLine, NULL, NULL, FALSE, 0, NULL, NULL, &stinfo, &procinfo) != 0)<br />
{<br />
ULONG i;<br />
while ( i=0, GetExitCodeThread(procinfo.hProcess, &i) && i == STILL_ACTIVE)<br />
{<br />
_sleep(1000);<br />
}<br />
}
|
|
|
|
|