|
Hi,
I need to convert the mfc code to atl for connecting to the windows shell. Please provide me some ideas or sample coding regarding this. I've enclosed the MFC coding below.
LPCONNECTIONPOINTCONTAINER pContainer;
LPCONNECTIONPOINT pXConnection = NULL;
DWORD dwCookie = 0;
CoInitialize(NULL);
if(m_pInterface == 0)
{
if(m_pInterface.CreateInstance(__uuidof(SHDocVw::ShellWindows)) == S_OK)
{
if ((m_pInterface != NULL) && SUCCEEDED(m_pInterface->QueryInterface (IID_IConnectionPointContainer,(LPVOID*)&pContainer)))
{
if (SUCCEEDED( pContainer->FindConnectionPoint (__uuidof(SHDocVw::DShellWindowsEvents, &pXConnection)))
{
ASSERT(pXConnection != NULL);
pXConnection->Advise( GetIDispatch(FALSE), &dwCookie);
pXConnection->Release();
}
pContainer->Release();
}
}
}
Regards
saravanan
|
|
|
|
|
Is there any ATL template/ wizard to implement a Outgoing IDispatch Interface at the client side.
If not how should it be implemented in the client side.
Preetham Raghunanda
|
|
|
|
|
I write a nt service, it need connect to database to update data.
I use CDataSource|CSession|CDynamicAccesor to implement it, it can't work, in other program, it just works fine. I can't know how to resolve it!
I can run the service.exe on CMD, it works, but from MMC to start the service, it can't work. return "Unknown error", why???
big is big...
|
|
|
|
|
what are you talking about ?
what database do you use ?
what error is returned ? any description ?
how do you proceed ?
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Probably you cannot authenticate on database server. Possibly you set SSPI authentication and when you start your service manually it use your account in your domain (and you have access to the database). When you start as service, it has LOCAL SYSTEM account and cannot login to database server.
|
|
|
|
|
Can u give me code for putting Icon(Bitmap Images) which is in a file,pasting on the toolbar button of Outlook
|
|
|
|
|
Hi,
I'm using the ATL OLEDB classes and I get the following error:
"Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done."
when I query the database with a query that uses the "DISTINCT" keyword. Here is a sample of my code.
<br />
HRESULT hr;<br />
CDataSource ds;<br />
CSession session;<br />
CCommand<CDynamicAccessor, CRowset, CMultipleResults> m_Accessor;<br />
<br />
<br />
CComBSTR bstrUser(strUserId);<br />
CComBSTR bstrPassword(strPasswd);<br />
CComBSTR bstrServer(strSvrName);<br />
CComBSTR bstrDatabase(strDbName);<br />
<br />
CDBPropSet dbinit(DBPROPSET_DBINIT);<br />
dbinit.AddProperty(DBPROP_AUTH_PASSWORD, bstrPassword);<br />
dbinit.AddProperty(DBPROP_AUTH_PERSIST_SENSITIVE_AUTHINFO, false);<br />
dbinit.AddProperty(DBPROP_AUTH_USERID, bstrUser);<br />
dbinit.AddProperty(DBPROP_INIT_CATALOG, bstrDatabase);<br />
dbinit.AddProperty(DBPROP_INIT_DATASOURCE, bstrServer);<br />
<br />
hr = ds.Open(_T("SQLOLEDB"), &dbinit);<br />
<br />
if ( SUCCEEDED(hr) )<br />
{<br />
hr = session.Open(ds);<br />
}<br />
else<br />
{<br />
session.Close();<br />
ds.Close();<br />
exit(1);<br />
}<br />
<br />
CDBPropSet propset(DBPROPSET_ROWSET);<br />
propset.AddProperty(DBPROP_IRowsetChange, true);<br />
propset.AddProperty(DBPROP_IRowsetScroll, true);<br />
propset.AddProperty(DBPROP_CANFETCHBACKWARDS, true);<br />
propset.AddProperty(DBPROP_UPDATABILITY, <br />
DBPROPVAL_UP_CHANGE | DBPROPVAL_UP_INSERT | DBPROPVAL_UP_DELETE );<br />
<br />
char Query[] = "select distinct dl_num from deal"<br />
LONG lRowsAffected = 0;<br />
<br />
hr = myAccessor.Open(m_session, Query, &propset, lRowsAffected);<br />
If I remove the DISTINCT keyword, the query works fine
Are there some things I need to set for the DISTINCT and GROUP BY keywords to work? We are using SQL Server 2000. Thanks for your help.
|
|
|
|
|
I am new to WTL/ATL, and I am trying to make a popup style window like MSN Messenger has. I have a class that has CWindowImpl as it's base. When I try to create the window, the error I get is: The system cannot find the file specified.
In my .h file, I have:
DECLARE_WND_CLASS("CInfoPopup")
and then to create the object, I have
this->mParent = theParent;<br />
HWND hwndMain;<br />
<br />
HINSTANCE hInstance = _AtlBaseModule.GetResourceInstance();<br />
WNDCLASSEX wcx;<br />
<br />
ZeroMemory(&wcx,sizeof(WNDCLASSEX));<br />
wcx.cbSize = sizeof(WNDCLASSEX);<br />
wcx.style = CS_HREDRAW|CS_VREDRAW | CS_DBLCLKS;<br />
wcx.lpfnWndProc = ::DefWindowProc;<br />
wcx.cbClsExtra = 0;<br />
wcx.cbWndExtra = 0;<br />
wcx.hInstance = hInstance;<br />
wcx.hIcon = NULL;<br />
wcx.hCursor = LoadCursor(NULL, IDC_ARROW);<br />
wcx.hbrBackground = (HBRUSH)(COLOR_WINDOW);<br />
wcx.lpszMenuName = NULL;<br />
wcx.lpszClassName = "CInfoPopup";<br />
wcx.hIconSm = NULL;<br />
<br />
if (!RegisterClassEx(&wcx))<br />
return 0;<br />
<br />
hwndMain = CreateWindowEx(WS_EX_NOPARENTNOTIFY | WS_EX_TOPMOST, "CInfoPopup", "", WS_POPUP, 0, 0, 0, 0, this->mParent->m_hWnd, NULL, hInstance, NULL);<br />
I have also tried registering the class, and then
CWindowImpl<CInfoPopup>::Create(this->mParent->m_hWnd, rect, "", CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS, WS_EX_NOPARENTNOTIFY | WS_EX_TOPMOST, 0U, NULL);
When I do that, I get: The specified module could not be found.
Any help would be appreciated!
|
|
|
|
|
Don't call RegisterClass() yourself, ATL does that the first time you create a window using that C++ class - look at the code behind DECLARE_WND_CLASS and you'll see it.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ
Strange things are afoot at the U+004B U+20DD
|
|
|
|
|
Thanks for the reply. Unfortunately I am still having problems. If I use
CreateWindowEx(WS_EX_NOPARENTNOTIFY | WS_EX_TOPMOST, "CInfoPopup", NULL, WS_POPUP, 0, 0, 0, 0, NULL, NULL, hInstance, NULL);
I get "Cannot find window class".
If I use
CWindowImpl<CInfoPopup>::Create(this->mParent->m_hWnd, rect, "CInfoPopup", WS_POPUP, WS_EX_NOPARENTNOTIFY | WS_EX_TOPMOST, 0U, NULL);
I get "The system cannot find the file specified".
Which call should I use, and do you have any idea why I am getting those errors? Thanks!
|
|
|
|
|
Use the CWindowImpl window traits parameter to set the default styles:
typedef CWindowTraits<WS_POPUP, WS_EX_NOPARENTNOTIFY|WS_EX_TOPMOST> InfoPopupTraits;
class CInfoPopup : public CWindowImpl<CInfoPopup, CWindow, InfoPopupTraits>, ...
{ ... }; Then create a window using CInfoPopup which makes ATL register the window class:
CInfoPopup wnd;
wnd.Create ( mParent->m_hWnd, rect );
--Mike--
Visual C++ MVP
LINKS~! Ericahist | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ
Strange things are afoot at the U+004B U+20DD
|
|
|
|
|
I did exactly what you said and I get the error "The system cannot find the file specified." Is there something wrong with my class? I am trying to convert "Taskbar Notification dialog" By John O'Byrne (http://www.codeproject.com/dialog/TaskbarNotifier.asp)from MFC to WTL. Thank you so much for your help. Sorry for being such a dope.
|
|
|
|
|
|
Would this error have something to do with the fact that this class is being used in a deskband dll, and this class needs to be registered?
|
|
|
|
|
hi
I have created the outlook addins with ATL/COM I am havung problem in adding the custom icons to the cusom outlook toolbars which are created. or can we put the custom icons to menubar items.
cheers
jhon
|
|
|
|
|
I've made a dll,and i wanted to call a function which has a parameter that is a data structure which was defined by me.It can't be compile!
Q:Why i could not call the function from a dll?
Any help would be greatly appreciated!
|
|
|
|
|
how you declared function in the dll and in the calling application?
You should define __declspec(dllexport) before declaration of the function that exported from dll and __declspec(dllimport) in the calling application.
example
in dll
__declspec(dllexport) int MyFunc(MyDataType MyData);
in exe
__declspec(dllimport) int MyFunc(MyDataType MyData);
and don't forget add lib to additional lib dependencies.
|
|
|
|
|
I'm making a Toolbar, or atleast, trying but I don't know how these things work, but mostly I created my COM object with ATL Simple Object and started to Implement Interfaces but then I started to add IDeskband, IInputObject, etc.. but it gives me an error:
c:\Program Files\Microsoft Visual Studio .NET\Vc7\atlmfc\include\atlcom.h(1756): error C2259: 'ATL::CComObject<base />' : cannot instantiate abstract class with
[
Base=CBandObj
]
class ATL_NO_VTABLE CBandObj :
public IObjectWithSiteImpl<cbandobj>,
public IDispatchImpl<ibandobj, &__uuidof(ibandobj)="">
Why does it give this error.. and if you can explain how to use the resource toolbar from the resources I'd really appreaciate it.
Alot of helps I find are all for VC 6.0 and add these Interfaces just like that, so I guess that is the problem.They're older versions.I would like to use only ATL programming to program the toolbar etc.. no WTL. Thanks
Oscar Ferreira
oscarferreira1@portugalmail.pt
|
|
|
|
|
there is a popular example of atlopengl_demo that can be downloaded in the page http://www.codeproject.com/atl/atlopengl.asp.
It is a opengl control created in VC, but when I use it in vb ,it can not work, why?
If I want to use it well in VB,how can I do?
thank you very much!
GOOD LUCK
|
|
|
|
|
What are the symptoms?
--
Schni Schna Schnappi! Schnappi Schnappi Schnapp!
|
|
|
|
|
what's the difference between:
int func(classA & test)
and
int funct(classA * test)
with differences i don't mean, the first is by reference and the second one is a pointer.
But what i want to know is, what are the advantages / disadvantages of those 2 ways of working to each other? And when should i use the first way, and when the second way?
why am i asking this? because sometimes i'm programming i don't know for which one to chose, because they both work for me.
thx
|
|
|
|
|
First difference, this is the wrong forum for this post! But, since people make honest mistakes...
Behind the scenes, there is no difference, at least not in VC++ 6.0. How references are implemented by a compiler is completely up to the compiler, but VC++ uses pointers. For example, if you create a function in a DLL that takes a reference, and you call it from a C program and pass in a pointer, it will still work correctly (at least, using the same builds of VC++ 6.0).
As far as usage, references are only available in C++ , not in C . Pointers have to be manually dereferenced in order to modify the item that it points to. References do this automatically, so the syntax of using them is different. For example:
int FuncA( int &iTest )
{
iTest = 10;
*iTest = 10;
return;
}
int FuncB( int *piTest )
{
*piTest = 10;
piTest = 10;
return;
} Think of a reference as an "atomatically-dereferencing" pointer. Barring IntelliSense or a similar coding aid, when you use references, it becomes easy for someone else to call the function not realizing that their variable may be modified by the function. When using pointers, they have to take the extra step to pass in the address of the variable, so they have an idea of what is going to happen (assuming non-const here).
Additionally, you can pass in a NULL pointer to a function, to indicate "nothing", but a reference has to refer to a real instance of something. For example, you can have an int pointer with a value of NULL , which means a pointer to nothing/nowhere, but you cannot have a reference that refers to nothing (barring some sneaking coding tricks).
References also have to be initialized, pointers do not:
<CODE>int iValue;
int *piValue;
int &riValue; There are a lot more details available on pointers and references beyond what I have written here...
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Tip for new SUV drivers: Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
thx for this info
sorry about the wrong forum, but didn't know where to post it, i didn't find a c++ forum.
|
|
|
|
|
The Visual C++ forum is the place for C++ related stuff.
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Tip for new SUV drivers: Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
hmm...
All the C++ boffins will tell you to use the reference version because it's "safer", and that's their justification for just about everything to do with the language Just remember that you can't reassign references and you can with pointers - this might nudge you towards the pointer version.
Unless you have a fairly strange function, there is no performance gain from using one in particular. If you want to emulate the powers-that-be and go in the direction the C++ standards commitee have not-so-subtlely been trying to push us in, use the reference version. Be aware of the possiblity of unseen anonymous objects being created when you pass by reference (if you do indeed have to create a temporary const object) - obviously this isn't possible with pointers and prevents this bit of bloat.
I go with references cos company's love to see them in your code. To be honest there's not much to gain from it, but try and stick to one in style. It also stops you having to stick &'s everywhere
|
|
|
|
|