|
Have you add a COM object to your server properly?
Then try "Build All"
I am seeking...
For what?
Why did you ask me for what? I don't know!
|
|
|
|
|
Hi all,
ATL question:
suppose I have two interfaces (IFirst, ISecond), and both
interfaces have a method Test(). Now I would like to implement
both IFirst and ISecond in a single object, but still have two
separate implementations of the Test() method.
Any pointers on how this can be done ?
Thanks,
Alwin
|
|
|
|
|
Use rename when importing the typelib?
Only way i can think of...
/Magnus
- I don't necessarily agree with everything I say
|
|
|
|
|
What you may have to do is what's sometimes called forwarding shims. The trick is to "prebind" the virtual methods. Observe:
class IFirstFwd : public IFirst {
public:
HRESULT Test() {
return IFirst_Test();
}
virtual HRESULT IFirst_Test() = 0;
};
class ISecondFwd : public ISecond {
public:
HRESULT Test() {
return ISecond_Test();
}
virtual HRESULT ISecond_Test() = 0;
};
class CYourComClass : public IFirstFwd, public ISecondFwd {
public:
HRESULT IFirst_Test() {
...
}
HRESULT ISecond_Test() {
...
}
}; I know it looks clumbsy, but since C++ does not have a feature for renaming inherited methods, this is the most type safe way to do it. Ok, so know that you know how it works, let's cut off those extra 8 bytes from the vtable (on wintel ia32) by adding templates:
template <typename T>
class IFirstFwd : public IFirst {
public:
HRESULT Test() {
return static_cast<T*>(this)->IFirst_Test();
}
};
template <typename T>
class ISecondFwd : public ISecond {
public:
HRESULT Test() {
return static_cast<T*>(this)->ISecond_Test();
}
};
class CYourComClass : public IFirstFwd<CYourComClass>, public ISecondFwd<CYourComClass> {
public:
HRESULT IFirst_Test() {
...
}
HRESULT ISecond_Test() {
...
}
}; There is another way - although not very pretty IMHO. It will only work well once the interfaces have finalized. I.e., this is very bad during development, because you lose all the help from the type system, and the bugs you may potentially have will be less than fun to figure out:
class ISecondFake {
virtual __stdcall HRESULT ISecond_Test() = 0;
};
class CYourComClass : public IFirst, public ISecondFake {
public:
HRESULT Test() {
...
}
HRESULT ISecond_Test() {
...
}
}; This'll work as long as your ISecondFake is vtable-compatible with ISecond. But should you change the vtable layout or method signature of ISecond in any way, don't forget to update ISecondFake or you'll be in for quite the ride..
--
Gott weiß ich will kein Engel sein.
|
|
|
|
|
Actually i am developing a class in which it will take any com object and will be able to set and get the properties. Now i have taken the clsid of the component. Now how can i get its properties as GetIdsofNames function of IDispatch takes names. Please Guide me briefly with a little example or tell me some article
Thanx in advance
Regards
minamkhan
Inam
|
|
|
|
|
|
Hello everyone
I have a wtl7.1 project and a mfc(VC6.0) dll.
Is there any way to use CString data to be transfered rightly between wtl project and mfc dll?
Thank you.
-Freehawk
|
|
|
|
|
freehawk wrote:
Is there any way to use CString data to be transfered rightly between wtl project and mfc dll?
Yes, if you pass LPCTSTR between them, then you have nothing to worry about.
I.e. in WTL project:
CString strYourString = "data";
Vc6Function(strYourString); in MFC project:
void Vc6Function(LPCTSTR lpszString) {
CString strLocalString = lpszString;
...
} This is one way to do it.
--
Gott weiß ich will kein Engel sein.
|
|
|
|
|
Hello everyone:
In a wtl project, there is a CListViewCtrl in a dialog.
After clicked one row of list, could you teach me how to get the double-click message?
Thank you
-Freehawk
|
|
|
|
|
You get a WM_COMMAND with LBN_DBLCLK.
/Magnus
- I don't necessarily agree with everything I say
|
|
|
|
|
Thank you for the reply
I have known how to get just as the following :
NOTIFY_HANDLER(IDC_LIST, NM_DBLCLK, OnDblClkList)
-Freehawk
|
|
|
|
|
That's the correct way to do it if you're using a list view control (CListCtrl in MFC and CListViewCtrl in WTL). Magnus gave you the solution for a list box (CListBox).
--
Gott weiß ich will kein Engel sein.
|
|
|
|
|
LBN_DBLCLK is for ListBoxes, not list view controls.
--
Gott weiß ich will kein Engel sein.
|
|
|
|
|
Thank you and Magnus very much.
You let me understand clearly.
-Freehawk
|
|
|
|
|
Ofcourse..
Mental note: *Dont answer even simple questions when yor brain is fried*
/Magnus
- I don't necessarily agree with everything I say
|
|
|
|
|
hello everyone:
How to change title text of dialog in a wtl project?
Thank you.
-Freehawk
|
|
|
|
|
SetWindowText() ?
/Magnus
- I don't necessarily agree with everything I say
|
|
|
|
|
Thank you for the reply
I tried it in a docking window, but nothing was changed.
Maybe there is other problem.
-Freehawk
|
|
|
|
|
sir,
i am a student and doing my project as a part of my course in one of the firms.i am doing it by using VC++ with MFC.but if i try to execute stl data viewer code,i will be getting the following errors.kindly provide the solution for the same.
StLViewerView.obj : error LNK2001: unresolved external symbol "public: void __thiscall CView::OnFilePrintPreview(void)" (?OnFilePrintPreview@CView@@QAEXXZ)
StLViewerView.obj : error LNK2001: unresolved external symbol "public: void __thiscall CView::OnFilePrint(void)" (?OnFilePrint@CView@@QAEXXZ)
StLViewerView.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall CView::PostNcDestroy(void)" (?PostNcDestroy@CView@@UAEXXZ)
StLViewerView.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall CView::PreCreateWindow(struct tagCREATESTRUCTA &)" (?PreCreateWindow@CView@@UAEHAAUtagCREATESTRUCTA@@@Z)
StLViewerView.obj : error LNK2001: unresolved external symbol "public: int __thiscall CView::OnCreate(struct tagCREATESTRUCTA *)" (?OnCreate@CView@@QAEHPAUtagCREATESTRUCTA@@@Z)
StLViewerView.obj : error LNK2001: unresolved external symbol "public: void __thiscall CView::OnDestroy(void)" (?OnDestroy@CView@@QAEXXZ)
Debug/StLViewer.exe : fatal error LNK1120: 6 unresolved externals
--ramya
|
|
|
|
|
hello everyone:
I have a wtl project and need a help file like treeview to display, but I dont know how to do.
I want to create a treeview like the "index" of MSDN, Could you teach me?
Thank you.
-Freehawk
|
|
|
|
|
There are plenty of WTL code examples here on Code Project that you should be able to get an idea of how to go about doing this ...
As for "teaching you" how, that's probably not going to happen. Some suggestions off the top of my head, however, would be to:
1. Implement your help system as a set of web pages and just use a HTML view/pane in your application, see the Code Project WTL[^] area for code examples
2. Use HTML Help Workshop[^] to compile your HTML file and just hook it off a standard 'Help Menu' bar item (that builds "MSDN like" help files)
D.
|
|
|
|
|
I have a Browser Helper Object that I have created and I want it to create a Window using the API function CreateWindowEx so that I can using the window layering extended style described here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwui/html/layerwin.asp
My question is how do I create a window using this API in my ATL project? I have tried creating a class that inherates from CWindows and then using the http://www.codeproject.com/w2k/QDWndTransparency.asp?print=true
But this does not have the same effect. I really need a faded window using:
hwnd = CreateWindowEx(WS_EX_LAYERED | WS_EX_TRANSPARENT,
gszFade, gszFade, WS_POPUP | WS_VISIBLE, prc->left,
prc->top, 0, 0, NULL, (HMENU)0, ghinst, NULL);
My goal is to have a window placed over the browser main window that I can then draw on. Any suggestions?
Thank you much,
Mike
|
|
|
|
|
Try this:
typedef BOOL (__stdcall *PFUNCSETLAYEREDWINDOWATTR)(HWND, COLORREF, BYTE, DWORD);
PFUNCSETLAYEREDWINDOWATTR m_pfSetLayeredWindowAttributes;
HMODULE hUser32 = GetModuleHandle(_T("User32.dll"));
if (hUser32)
{
m_pfSetLayeredWindowAttributes =
(PFUNCSETLAYEREDWINDOWATTR)::GetProcAddress(hUser32, "SetLayeredWindowAttributes");
if (m_pfSetLayeredWindowAttributes)
{
::SetWindowLong(m_hWnd, GWL_EXSTYLE, GetWindowLong(GWL_EXSTYLE)^WS_EX_LAYERED);
// After the SetWindowLong call, the layered window will not become visible
// until the SetLayeredWindowAttributes function has been called for this window
m_pfSetLayeredWindowAttributes(m_hWnd, 0, (BYTE)255, LWA_ALPHA);
}
}
and then somewhere
// Sets the transparency of the window
void MakeTransparent(int nAlpha)
{
if (m_pfSetLayeredWindowAttributes)
m_pfSetLayeredWindowAttributes(m_hWnd, 0, (BYTE)nAlpha, LWA_ALPHA);
}
|
|
|
|
|
I hae a DLL made from ATL Com appwizard, supporting connection points...
<br />
<br />
void OnAParticularFunction() <br />
<br />
Fire_Event();<br />
<br />
}<br />
NOw the code fragment generates an exception..
Why does it generate an exception? is it because of the fact the function from where the event was fired, is running on a separate thread? If so, how could i work this thing out?
tnx inadvance
|
|
|
|
|
Maverick wrote:
is it because of the fact the function from where the event was fired, is running on a separate thread?
Yes. My guess is that your threads live in separate apartments.
Please see this[^] article for a discussion and solution on how to fire events across apartment boundaries.
--
Gott weiß ich will kein Engel sein.
|
|
|
|