|
No, delete[] should be called, since it's an array of TCHAR.
--
Futue te et ipsum caballum.
|
|
|
|
|
Then you should create your own deleter functor, much like the one in the example provided by Nemanja. The difference will be the actual call to delete. Since you have allocated an array of TCHAR, you should use delete[] when freeing it. delete will work for simple TCHARs - because there is no ~TCHAR to be called for each element in the array. However, make a habit or you might run into problems when you have code like this:
class Class {
OtherClass* pObj;
public:
Class() { pObj = new OtherClass(); }
~Class() { delete pObj; }
};
...
Class* arr = new Class[10];
...
delete arr;
Remember! delete for single objects, delete [] for arrays.
--
Futue te et ipsum caballum.
|
|
|
|
|
I guess I need another helper template. I like your approach better because then you don't have to know about your container and which STLDelete*** template to call.
struct STLDeleteObject
{
template<typename T>
void operator()(const T* ptr) const
{
delete ptr;
}
};
std::for_each(c.begin(), c.end(), STLDeleteObject())
struct STLDeleteArray
{
template<typename T>
void operator()(const T* ptr) const
{
delete[] ptr;
}
};
std::for_each(c.begin(), c.end(), STLDeleteArray())
Todd Smith
|
|
|
|
|
I am writing a custom-draw TreeView/ListView hybrid control similar to the one found in "A custom-drawn TreeList Control 18 Mar 2000 by Gerolf Kuehnel", found elsewhere on this site.
I am having relatively good success, except that while the custom-draw TreeView is scrolling quite well, the Header Control that is added in the OnInitDialog is not receiving the WM_WINDOWPOSCHANGING and other various messages, thus it does not scroll.
I used Spy++ to look at the messages received by Mr. Kuehnel’s project and my ATL control, and the Header control window in my control doesn’t receive any of the messages that I am sending (tried both to use a WTL CHeaderControl, as well as a CContainedWindow). I presume I’m missing something in my message map, or incorrectly creating the header control. The header generated messages are working fine (e.g. HDN_ENDTRACK). Although I am doing the exact same operation as Mr. Kuehnel, The messages aren't reaching their target.
Below is my Message Map for the composite control:
BEGIN_MSG_MAP(CTreeListViewCtrl)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
MESSAGE_HANDLER(WM_SIZE, OnSize)
MESSAGE_HANDLER(WM_HSCROLL, OnHScroll)
NOTIFY_HANDLER(IDC_TREE,NM_CUSTOMDRAW,OnCustomdrawTree)
NOTIFY_HANDLER(IDC_TREE,TVN_DELETEITEM,OnDeleteTree)
NOTIFY_HANDLER(IDC_HEADER,HDN_ENDTRACK,OnEndTrackHandler)
CHAIN_MSG_MAP(CComCompositeControl<ctreelistviewctrl>)
DEFAULT_REFLECTION_HANDLER()
END_MSG_MAP()
This is where the item is created in OnInitDialog.
m_Header.Attach(
::CreateWindow(WC_HEADER,"", WS_CHILD|WS_VISIBLE|WS_BORDER|HDS_HORZ, 0,0,r.right - r.left,0,m_hWnd ,(HMENU)IDC_HEADER, hInst,NULL));
Can anyone give me an idea why this is happening?
Mark D Henning
ITT Industries
mark.henning@ITT.com
mdh@gldnrtvr.com
|
|
|
|
|
I have one com component working fine until yesterday now its giving me this exception?
what does it mean?
%1 is not a valid Win32 application.
Thanx.
MSN Messenger.
prakashnadar@msn.com
|
|
|
|
|
|
humm, well i would have belived that if the component is from 3rd party. But the component,the .dll file is mine and i compiled and registered it before using it.
MSN Messenger.
prakashnadar@msn.com
|
|
|
|
|
I have an activeX control embeded in a HTML page, how can my activeX component know from which website is it being downloading from ?
i can pass values from html page to the component, and modify the html pages to give different values to the activeX control from different websites is this a good way or i can accomplish this without modifying the HTML page ?
thanks in advance
C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg
|
|
|
|
|
|
this post have been moved to the COM forum, oops
|
|
|
|
|
Hi...
i am very new to wtl and atl....first i was wondring if i have wtl libraries does it mean i have atl too?
second how can i display another dialog in application?
imagine i have a main dialog and with clicking on a button i want to show anoother dialog....how?
also why mostly ppl try to call createdlg and not createwindow for other dialog?any diffrence?
Sorry if very newbie questions...
Thanks
Roozbeh
|
|
|
|
|
ATL comes with Visual C++.
There's nothing special about showing a second dialog, it's the same as the first one. Create a class for it, create an object of that class and call its DoModal()
--Mike--
Personal stuff:: Ericahist | Homepage
Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt
CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ
----
"Just because the box has 2 gigabytes of memory doesn't mean you get to use it all!"
-- Rico Mariani, CLR perf guy
|
|
|
|
|
Hello everyone:
I want to use some XML functions in a WTL project.
Can XML be used in a wtl project?
Where is there any sample?
Thank you.
-Freehawk
|
|
|
|
|
Yes it can be used.
MSN Messenger.
prakashnadar@msn.com
|
|
|
|
|
Hello everyone:
I have a wtl program. It run ok on windows 2k, XP, but there are a bug when it run on window98 windowsMe and windows NT4.0. On the windows Me, the tool window moved to the back of main frame even if it is actived. It looks like having something to do with "SetFocus" and so on. But I dont know why?
who met some troubles like me? Could you help me?
Thank you.
-Freehawk
|
|
|
|
|
Hello everyone:
I have some big size text files, How to insert/delete some content of text file fastly in a WTL project?
Thank you.
-Freehawk
|
|
|
|
|
I have created a simple mfc activex control which works in the activex control test container.
Now I have have created an stl program and use #import to pull in definitions of the control and a wrapper class.
Next I have a function:
HRESULT hr;
_DMysearch *pSearch;
const IID IID_DMysearch = { 0x2887adc2, 0xeba1, 0x4ca9, { 0xb3, 0x58, 0x15, 0xae, 0xf, 0xd2, 0xb9, 0x6a } };
const CLSID CLSID_mysearch = {0x4ae8deda, 0xee97, 0x47ee,{ 0x9c, 0xcc, 0xd, 0x1b, 0x4b, 0x99, 0x6b, 0x88}};
::CoInitialize(NULL);
hr = CoCreateInstance (CLSID_mysearch, // CLSID of coclass
NULL, // not used - aggregation
CLSCTX_INPROC_SERVER, // type of server
IID_Dmysearch, // IID of interface
(void**) &pSearch ); // Pointer to our interface pointer
if ( SUCCEEDED ( hr ) )
{
long res = pSearch->test();
}
else
{
// Couldn't create the COM object. hr holds the error code.
}
I get as far as pSearch->test() which is a simple long function with no parameters and I get an exception from com_dispatch_method.
any ideas?
jema
|
|
|
|
|
I have created a ATL exe service and added a interface to it....
I registered it and run it.
But for somereason sometimes the atl service starts automatically on its own making multiple copies in the memory..
can any one explain why it happens ?
here is createservice that is called, i belive something is in here but not able to figure it out.
SC_HANDLE hService = ::CreateService(
hSCM, m_szServiceName, m_szServiceName,
SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS,
SERVICE_DEMAND_START, SERVICE_ERROR_NORMAL,
szFilePath, NULL, NULL, _T("RPCSS\0"), NULL, NULL);
Thanx in advance.
MSN Messenger.
prakashnadar@msn.com
|
|
|
|
|
The MFC CFormView is a view but using a dialog resource for UI, which makes modifying the UI layout very easy, I think this class is great(at least for me). But when shifted to WTL, I cannot find a class(or I missed?) like the CFormView. So anyone got a clue or has implemented such a class would mind to share with me?
I'm new in WTL(even in ), and I've searched this forum with keyword "FormView"/"Form View" but just got "no results". So if you think my question is stupid, please forgive me. ^_&
Thanks for any reply.
=================
Sorry for my poor English.
|
|
|
|
|
You can create a app with a form view with the WTL appwizard but there is no FormView class, the view uses CDialogImpl
/Magnus
- I don't necessarily agree with everything I say
|
|
|
|
|
Thanks for your reply, I'll try it later.
Thank you.
|
|
|
|
|
I've created a Connection Page (in the Data Source Object of my OLE DB Provider) to be displayed by the Data Link core component.
Now I'm trying to add a tab control on the page using CreateWindow with the WC_TABCONTROL class (being registered through InitCommonControlsEx(...).
But I can't get the Instance Handle needed by CreateWindow,
because
hInst = (HINSTANCE)::GetWindowLong(hwndParent, GWL_HINSTANCE);
always returns 0x0000000.
(I've received the hwndParent through the IPropertyPage::Activate Method, that's being called by the Data Link core component)
How can I get that Instance Handle? Or is there another way of using a tab control on my property page?
|
|
|
|
|
Hi All,
I have a COM component which supports outgoing interface IDataCallback,which calls OnDataChange event.
When client Get Connectionpoints and Call Advise for Server,i want to fire OnDataChange.Where should i Know that Client has called Advise so that i should send him OnDataChange callback,just to show that callback is working.
In normal working i am sending OnDataChange whenever data Changes in my server,but i want to send this first OnDataChange as soon as Client call Advise.
Where should i write the code for this?
Code for my server is like this:
class MyServer;
typedef IConnectionPointImpl <myserver,&iid_idatacallback,ccomdynamicunkarray> DataCallback;
class ATL_NO_VTABLE MyServer :
public IInterface1,
public IInterface2,
public IConnectionPointContainerImpl<myserver>,
public DataCallback,
public CComObjectRootEx<ccommultithreadmodel>
{
---
}
Thanks in advance
Tushar.
|
|
|
|
|
Because you're deriving from IConnectionPointContainerImpl, then it's doing all the hard work for you.
You might be able to provide your own implementation of Advise, but you'd need to make sure you called the templated implementation first, then fired the event (if successful). Don't know whether (a) this is possible or (b) it's allowed, since you're effectively firing an event before Advise has completed, so I don't know if there's COM runtime magic involved.
Steve S
|
|
|
|
|
Hi, i need an ADDin for Word 2000 ( XP and 2003 too) that has an dialog box
like a ATL Composite Control ( VC 7.1).
The problem is when this control is inserted in the Word (insert object) and lost focus,the dialog disapear (seems like the WM_PAINT don´t be triggered).
The control draws it self only when i "double click" the control.
I read some articles that this behavior is because the Word Container
don´t give us an Window to draw when the control is without the focus.
In VB, the control don´t disapear only in the Word.
Can anyone help me ?
thanks
|
|
|
|
|