|
I have an ATl ActiveX control I am writing which has support for MFC. I want to add a CEdit in my control so that the user can enter values. How do I create this?
I have spent all yesterday (literraly) trying and no luck.
I construct by
CEdit myEdit;
Followed by
CWnd* parent = CWnd::FromHandle(this->m_hWnd);
myEdit.Create(ES_CENTER | ES_NUMBER | WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_BORDER,
CRect(10, 10, 100, 40), parent, 1);
This causes assertion...I cannot even find or understnad where the assertion is caused as when i look at the call stack in the debugger, there are no comments or ASSERT(...) around.
Has anybody sucessfully added a CEdit to an ATL ActiveX control which supports MFC? If so...how?
Thanks
|
|
|
|
|
Well...finally got this one figured out.
Must add [code]AFX_MANAGE_STATE(AfxGetStaticModuleState());[/code] before [code]CWnd* parent = CWnd::FromHandle(this->m_hWnd);
myEdit.Create(ES_CENTER | ES_NUMBER | WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_BORDER,
CRect(10, 10, 100, 40), parent, 1);[/code]
Ciao
|
|
|
|
|
Sorry,I tried this,but still can't work,IE crashed and error is "Debug Assertion Failed"
|
|
|
|
|
Can any one tell me how to check EOF/BOF status in a rowset?
Lisoft
|
|
|
|
|
Hey i had the same problem. Well there is no EOF or BOF.
Check for S_OK as till S_OK is returned EOF is not reached.
i solved it using that.
Gaurav Jain
K.K. Wagh Institue of Engineering Education and Research,
Nashik,
Maharashtra,
India.
gauravjain911@yahoo.com
|
|
|
|
|
I also found the OLE DB consumer templates does not have the EOF/BOF status like the ODBC(MFC) class which I used to access the database before. When CRowset class was first initialized by CCommand::Open method, the 'cursor' does not point to the first record like the ODBC(MFC) class. The only way to check if there is anything returned from the database is to call CRowset::MoveNext() method and check the return value to determine EOF status.
Anyway, thanks for your help.
Lisoft
|
|
|
|
|
Hallo,
I need please help to pass string from a dll to an nt service.
I’m also interesting in a way to pass string from a service (c++) to a vb application that not runs a form.
Thanks a lot for helping
dabayi
|
|
|
|
|
I am trying to write a application with string dialog resources in 2 languages(En and De). SetThreadLocale works fine in XP system, but not in 98.
How should i do to load and display an De dialog on 98 system
|
|
|
|
|
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[^]
|
|
|
|
|