|
At me such problem:
When the standard page of properties (Property Page) is created - that everything is all right,
And when I try to create it manually - it is not displayed.
I hands finish such in CoClass.h:
BEGIN_PROP_MAP (COpenGL)<br />
PROP_DATA_ENTRY ("_cx", m_sizeExtent.cx, VT_UI4)<br />
PROP_DATA_ENTRY ("_cy", m_sizeExtent.cy, VT_UI4)<br />
PROP_ENTRY ("FillColor", DISPID_FILLCOLOR, CLSID_StockColorPage)<br />
<br />
PROP_ENTRY ("Dialog", 2, CLSID_PropDlg)
<br />
END_PROP_MAP ()
And in a result the Property Page created in manual is not displayed (and that standard "FillColor" - is displayed)......... (are displayed only standard - FillColor, and one more)
What to make, that it worked?
And all over again I received the message, that CLSID_PropDlg is in general a unknown piece (but then itself has passed)
That I receive in a idl-file:
import "E:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\include\prsht.idl";
import "E:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\include\mshtml.idl";
import "e:\program files\microsoft visual studio .net 2003\vc7\platformsdk\include\dimm.idl";
import "E:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\include\mshtmhst.idl";
import "e:\program files\microsoft visual studio .net 2003\vc7\platformsdk\include\docobj.idl";
import "E:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\include\exdisp.idl";
import "E:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\include\objsafe.idl";
[
object,
uuid(BB2EEEBB-B474-4CBC-9B70-697E4ECC1EE8),
dual,
helpstring("IOpenGL Interface"),
pointer_default(unique)
]
#line 49 "d:\\d\\c7\\com\\atlgl\\atlgl\\opengl.h"
interface IOpenGL : IDispatch {
#line 52 "d:\\d\\c7\\com\\atlgl\\atlgl\\opengl.h"
[propput,bindable,requestedit,id((-510))] HRESULT FillColor([in] OLE_COLOR clr);
#line 54 "d:\\d\\c7\\com\\atlgl\\atlgl\\opengl.h"
[propget,bindable,requestedit,id((-510))] HRESULT FillColor([out,retval] OLE_COLOR *pclr);
[id(1),helpstring("method GetLightParams")] HRESULT GetLightParams([out] int *pPos);
[id(2),helpstring("method SetLightParam")] HRESULT SetLightParam([in] short lp, [in] int nPos);
[id(3),helpstring("method ReadData")] HRESULT ReadData();
[id(4),helpstring("method GetFillMode")] HRESULT GetFillMode([out] DWORD *pMode);
[id(5),helpstring("method SetFillMode")] HRESULT SetFillMode([in] DWORD *nMode);
[id(6),helpstring("method GetQuad")] HRESULT GetQuad([out] BOOL *bQuad);
[id(7),helpstring("method SetQuad")] HRESULT SetQuad([in] BOOL bQuad);
};
[ version(1.0), uuid(4CA16C3B-D4B6-434D-9648-2E419FF79F15), helpstring("ATLGL 1.0 Type Library") ]
library ATLGL
{
importlib("stdole2.tlb");
importlib("olepro32.dll");
[
uuid(9D2FB6B9-6797-45D0-A331-A6DE808F9A82),
helpstring("_IOpenGLEvents Interface")
]
#line 72 "d:\\d\\c7\\com\\atlgl\\atlgl\\opengl.h"
dispinterface _IOpenGLEvents {
properties:
methods:
};
[
version(1.0),
uuid(35435006-DA95-4B34-9988-5A0A512E3F3C),
helpstring("OpenGL Class")
]
#line 88 "d:\\d\\c7\\com\\atlgl\\atlgl\\opengl.h"
coclass COpenGL {
interface IOpenGL;
[default, source] interface _IOpenGLEvents;
};
[
version(1.0),
uuid(F2FBEB23-A2C0-4C9D-B049-6E14D8A3E8CF),
helpstring("PropDlg Class")
]
#line 19 "d:\\d\\c7\\com\\atlgl\\atlgl\\propdlg.h"
coclass CPropDlg {
[default] interface IUnknown;
};
[
version(1.0),
uuid(CD2867E6-F4C7-48A6-8D06-D1856D501B2E),
helpstring("tMy Class")
]
#line 19 "d:\\d\\c7\\com\\edf\\atlgl\\tmy.h"
coclass CtMy {
[default] interface IUnknown;
};
}
|
|
|
|
|
Do not pay attention to this post, I have already found a mistake
|
|
|
|
|
Hi,
if I use e.g.
CComPtr<imy> pMy;
...
pMy->Advise(...)
who calls the UnAdvise? Or is it enough if the pMy is released? Cause I think if no one calls the UnAdvise the server doesn't know that the sink will not exist any more!?
thx&greets
|
|
|
|
|
I guess you have to. See MSDN for AtlAdvise and AtlUnadvise docs.
AFAIK the server holds a reference to the sink until the Unadvise is called - so even if you release pMy, the object will still remain with refcount == 1
(but it's long time I did something with com events, so I might be easily wrong)
|
|
|
|
|
I am creating a static control and trying to change the font being used. Right now I am doing this:
<br />
m_TextWindow.SetFont(static_cast<HFONT>(GetStockObject(DEFAULT_GUI_FONT)));<br />
How would I create a new font and set it?
|
|
|
|
|
Nevermind all. I figured it out. I just create a variable of type HFONT, then use the CreateFont method to create a font. and then set the font:
<br />
HFONT hFont = CreateFont (8,0,0,0,FW_LIGHT, 0, 0, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS,<br />
CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, "Tahoma");<br />
<br />
m_TextWindow.SetFont(hFont);<br />
|
|
|
|
|
Tell me it look like this MFC question and you have posted it in worng Forum.
any way if it MFC you can use CFont and it member function i.e. (CreateFont) to create your own font.
or you can directly use Win32Api function CreateFont to create your own font and set in the static Ctrl.
here is small code listing for your problem
CFont fnt;
fnt.CreateFont(12,0,0,0,FW_BOLD,FALSE,FALSE,FALSE,
DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,
DEFAULT_PITCH ,"Arial");
m_TextWindow.SetFont(&fnt);
"I Think this Will Help"
<h5
alok="" gupta="" <br=""> visit me at http://www.thisisalok.tk
|
|
|
|
|
ThatsAlok wrote:
Tell me it look like this MFC question and you have posted it in worng Forum.
No, it was not MFC code. It was straight ATL.
--
My name in Katakana is ヨルゲン.
My name in German is Jörgen.
I blog too now[^]
|
|
|
|
|
Window Api so vast, That it can be use in any thing from Old Win32 api based project to new ATL/COm Project, Dunno know abt Visual C++.net
that why, it's some time confused programmer,that in which project he/she is programming.
"I Think this Will Help"
<h5
alok="" gupta="" <br=""> visit me at http://www.thisisalok.tk
|
|
|
|
|
hi,
I am looking for articles / sites to learn ATL and COM. Could you please help me. I am a beginner in using MFC.
thanks,
suri
|
|
|
|
|
The ATL (Active Template Library) is a library to make COM programming easier.
The WTL (Windows Template Library) extendes the ATL for more GUI support (for example splitter windows ect.)
So the WTL is something like MFC to make windows GUI programming easiert and somehow object oriented
You find here at codeproject some good tutorials how to use ATL/WTL especially if you have a background in MFC at
http://www.codeproject.com/wtl
Search for the articles "WTL for MFC programmers" from Michael Dunn.
Constantin
|
|
|
|
|
Hi suri,
Try http://www.funducode.com[^] this site ! OR offcourse search Codeproject itself, it has rich information about ATL/COM OR Search the online MSDN at http://msdn.microsoft.com/library
Cheers,
Vishal
|
|
|
|
|
Hi suren,
No personal mails please !
Should keep the discussion in the same thread, so that others can benifit form this.
Nways, you can refer to the books such as "Inside ATL - George Shepherd" OR "Inside COM - Dale Rogerson" etc...
All the very best !!!
Cheers,
Vishal
|
|
|
|
|
Hi,
I have a small console application using C structure, vector and std::sort().
The application crashes in the sort() function with memory corruption. Purify reports many ABW (Array Bound Write) and other illegal usage done by the sort function. Is there a known bug in the sort of stl vectors? Any help is appreciated.
Thanks,
Ron.
(Code sample)
// xx.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "xx.h"
#include <vector>
#include <algorithm>
#include <functional>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
CWinApp theApp;
using namespace std;
#define LENGTH 1000
struct TTT
{
int d;
int h;
int n;
};
class ItemCompare : std::binary_function<TTT&, TTT&, bool>
{
public:
bool operator()(const TTT& t1, TTT& t2)
{
if (t1.d > t2.d)
return true;
else if (t1.h > t2.h)
return true;
else if (t1.n > t2.n)
return true;
else
return false;
}
};
TTT makeTTT(int i)
{
TTT t;
t.d = 1 + (i % 29);
t.h = 1 + (i % 22);
t.n = 1 + (i % 59);
return t;
}
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
int nRetCode = 0;
// initialize MFC and print and error on failure
if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
{
// TODO: change error code to suit your needs
cerr << _T("Fatal Error: MFC initialization failed") << endl;
nRetCode = 1;
}
else
{
vector<TTT> t1;
t1.reserve(LENGTH);
for (int i=0;i<LENGTH;i++)
{
t1.push_back(makeTTT(i));
}
sort(t1.begin(), t1.end(), ItemCompare());
}
return nRetCode;
}
Ron.
|
|
|
|
|
I think the problem lies in that your ItemCompare class does not define a true order between TTT elements. Assuming you wanted to have a lexicographical order (order by d , else by h is d is the same, else by n if h is the same), you can write it like this:
class ItemCompare : std::binary_function<TTT,TTT,bool>
{
public:
bool operator()(const TTT& t1, TTT& t2) const
{
if (t1.d < t2.d)
return true;
if (t1.d > t2.d)
return false;
if (t1.h < t2.h)
return true;
if (t1.h > t2.h)
return false;
if (t1.n < t2.n)
return true;
return false;
}; Also, please note your implementation seemed to suggest you were trying to sort things in descending order. This formulation sorts just the opposite, flip the < s and > s is this is not what you want.
Hope this helps,
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
Want a Boost forum in Code Project? Vote here[^]!
|
|
|
|
|
Thanks. You were right, I had a bug in my compare function.
Thanks again,
ron.
Ron.
|
|
|
|
|
I was about to point that out, but since I figured it wouldn't produce memory corruption bugs, I didn't bother. This fix solved the memory corruption bugs, indicated by the original poster's reply.
How can a faulty predicate generate memory corruption? A screwy order would be expected, but memory corruption? I'm baffled.
--
My name in Katakana is ヨルゲン.
My name in German is Jörgen.
I blog too now[^]
|
|
|
|
|
Hi Jörgen,
How can a faulty predicate generate memory corruption? A screwy order would be expected, but memory corruption? I'm baffled.
Well, the problem with the OP's compare predicate is not that is does not induce an order, but rather that it is inconsistent, i.e, there exist elements t1 and t2 such that ItemCompare(t1,t2)==ItemCompare(t2,t1)==true . I guess the sorting algorithm might jump out of bounds when this assumed consistency is breached. Anyway, the sort source code is so complex that it's hard to elucidate what's going on inside.
Best,
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
Want a Boost forum in Code Project? Vote here[^]!
|
|
|
|
|
Hi,
I came up with a way how to call member functions directly so sending WM_NODIFY messages is no longer neccessary and I am interested in your opinions!
I have a MDI window (derived from CMDIFrameWindowImpl) that notifies the active MDI child (CChildFrame derived from CMDIChildWindowImpl) if its document should be opened/saved/reopened ect...
The only way I knew to do this was to send the MDI child a WM_NOTIFY message with different notification code and NMHDR*.
I thought it would be nice to call member function like Save(), Open(CString file),... directly on the CChildFrame object because it would be a lot easier to read and the casting of NMHDR* would no longer be neccessary.
So here is the code:
<br />
#define ATL_GET_THIS 100 <br />
<br />
template<typename T><br />
T* AtlGetObject(HWND hWnd) <br />
{<br />
NMHDR nmhdr = { hWnd, 0, ATL_GET_THIS };<br />
return (T*)(::SendMessage(hWnd, WM_NOTIFY, 0, (LPARAM)&nmhdr));<br />
}<br />
The CChildFrame must handle the ATL_GET_THIS notification:
<br />
BEGIN_MSG_MAP_EX(CChildFrame)<br />
...<br />
NOTIFY_CODE_HANDLER_EX(ATL_GET_THIS, _AtlOnNotifyGetThis) <br />
...<br />
END_MSG_MAP()<br />
<br />
LRESULT _AtlOnNotifyGetThis(NMHDR* ) { return (LRESULT)this; }
So the code in the parent to call some member function in the active MDI child would look like this:
<br />
CChildFrame* pWndChild = AtlGetObject<CChildFrame>(MDIGetActive());<br />
<br />
CString sFilename = pWndChild->GetFilename();<br />
CFileDialog dlg(FALSE, 0, sFilename);<br />
if (dlg.DoModal() == IDOK)<br />
{<br />
pWndChild->SaveAs(dlg.m_ofn.lpstrFile);<br />
} <br />
What do you say?
I know it works, but are there some traps I didn't see? And if this is a good idea, why is nothing like this in the ATL/WTL already? Or there is and I didn't see it?
Thanks for your time!
Constantin
|
|
|
|
|
hi,
im trying to open a document from the documents list but it always returns null.
this is my code:
<br />
m_ActiveProject->get_FullName(&l_ProjectName);<br />
<br />
CComPtr<EnvDTE::Documents> l_pDocuments;<br />
m_pDTE->get_Documents(&l_pDocuments);<br />
<br />
CComPtr<EnvDTE::Document> l_pDocument;<br />
l_pDocuments->Open(l_ProjectName,L"Text",false,&l_pDocument);<br />
am i doing something wrong?
|
|
|
|
|
hi,
im trying to get the project's full name by iterating the projects array.
<br />
EnvDTE::Projects *l_pProjects;<br />
l_pSolution->get_Projects(&l_pProjects);<br />
long *l_Count = new long;<br />
l_pProjects->get_Count(l_Count);<br />
<br />
for(long l = 0; l < *l_Count; l++)<br />
{<br />
EnvDTE::Project *l_pPrj;<br />
VARIANT v;<br />
v.lVal = 0;<br />
l_pProjects->Item(v,&l_pPrj);<br />
BSTR fullname;<br />
l_pPrj->get_FullName(&fullname);
}<br />
the problem is where the comment "// PROBLEM!" is. it just won't work?
what am i doing wrong?
|
|
|
|
|
I have created a button with a drop down arrrow with the following code:
<br />
TBBUTTON Button;<br />
TCHAR* pButSearchCaption = _T("Search Web");<br />
int iIndex0 = ::SendMessage(m_hWnd, TB_ADDSTRING, 0, (LPARAM)pButSearchCaption);<br />
Button.fsState = TBSTATE_ENABLED;<br />
Button.fsStyle = TBSTYLE_BUTTON | TBSTYLE_AUTOSIZE | TBSTYLE_DROPDOWN; <br />
Button.dwData = 0;<br />
Button.iString = iIndex0;<br />
Button.iBitmap = I_IMAGENONE;<br />
::SendMessage(m_hWnd, TB_INSERTBUTTON, 0, (LPARAM)&Button);<br />
I then add the following code to my message map to handle the TBN_DROPDOWN handler:
<br />
BEGIN_MSG_MAP(CMFToolbar)<br />
MESSAGE_HANDLER(WM_CREATE, OnCreate)<br />
MESSAGE_HANDLER(WM_SIZE, OnSize)<br />
ALT_MSG_MAP(1)<br />
NOTIFY_CODE_HANDLER(TBN_DROPDOWN, OnButDropDown)<br />
END_MSG_MAP()<br />
<br />
LRESULT OnButDropDown(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);<br />
However, whenever I click the arrown on the button, it seems as the OnButDropDown isn't being called. Anyone know why this is.
|
|
|
|
|
WM_NOTIFY messages are sent to the toolbar's parent window, just like with all child controls. You need to handle TBN_DROPDOWN in the parent and reflect it back to the toolbar.
Also, your TB_ADDSTRING call is wrong, you need to pass a double-null-terminated string.
--Mike--
LINKS~! Ericahist | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ | You Are Dumb
Strange things are afoot at the U+004B U+20DD
|
|
|
|
|
how can i use CString with ATL in Visual Studio .NET?
|
|
|
|
|
Avi Laviad wrote:
how can i use CString with ATL in Visual Studio .NET?
#include <atlstr.h> ... to use ATL::CString
or
#include <atlmisc.h> ... to use WTL::CString
Greetings, Ralph
|
|
|
|
|