|
Hi,
In theory the responsible of freeing memory/objects is the one who created it ( so like that should be Ok, VBasic created it VBasic must free it)... but with all this ATL/COM stuff ... no one really knows
On test could be take that PNRInf, and free it in the com server, then try to use it after that from the VBasic Code, if it crashes you shouldn't use that
Good Luck
Braulio
|
|
|
|
|
Here are the simple rules for COM:
[in] - Caller creates, Callee uses but cannot modify, Caller frees
[in,out] - Caller creates, Callee deallocates/allocates new, Caller frees
[out] - Caller invokes uninitialized,Callee creates, Caller frees
In any case, VB is designed to handle the memory according to the rules. It can do nothing else.
If you are having a memory leak problem then you probably have the following situation:
GetPNRInf takes [in] *PNRInf
Forgets to call ::SysFreeString on it
Then does a ::SysAllocString on it
Then returns to pass it back [out]
The memory leak happens during the call. Since VB knows the call is [in,out] it knows the string may have a different address upon return. What it cannot know is that the callee moved the address, but did not free the old string.
Someone please correct me if I overstated something here.
|
|
|
|
|
Hi! It's me again!
I'm trying to insert a DropdownButton in my Outlook plugin...a msoControlButtonDropdown button, but I just don't know how!
Here is (a piece of)my code:
CComVariant vToolBarType2(msoControlDropdown);
CComPtr < Office::CommandBarControl> spNewBar;
spNewBar = spBarControls->Add(vToolBarType,vEmpty,vEmpty,vEmpty,vShow);
ATLASSERT(spNewBar2);
The problem is that the Add Method only accepts as the first parameter msoControlButton, msoControlEdit, msoControlDropdown, msoControlComboBox, or msoControlPopup; and I want to use msoControlButtonDropdown.
Any ideas how should I do this, or how should I go around it?
As you see, the code is written in C++, but even if you have a VB sample, I guess it should do the trick.
Thanks a lot,
Doru K.
|
|
|
|
|
Hi!
I have a question for you, older & more skilled (then me ) COM programmers. I have an ATL Addin for MSOutlook2k. For now, it only displays some buttons in outlook (thanks Amit Dey! great tutorial!), but I would like to send an e-mail when pressing one of them(with some content set by me). Any ideas, tutorials, examples, Office APIs(if there is such a thing) or something like that?
BTW, I'm using VC++, NOT VB(I kind of had enough of VB tutorials
Thanks!
Doru K.
|
|
|
|
|
The easiest way (IMO) to work out how to do something using the Office object models is to prototype it in VBA (sorry...), then translate to VC++. It's not too tricky - you need to translate GetObject & CreateObject calls and work out how to call methods and access properties
Hmmm - I found this page[^] on Google - that might help?
<edit> This[^] might help even more - it converts VB automation code (i.e. what all the Outlook samples are written in) to C...
</edit>
Stuart Dootson
'Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p'
|
|
|
|
|
Thanks a lot! I hope it will work out...the code convertor is such a great ideea! Thanks again,
Doru
|
|
|
|
|
I'm tearing my hair out looking for atltypes.h. I've downloaded the WTL library, searched online, I'm stumped. Could someone tell me where this file lives please.
|
|
|
|
|
|
I downloaded and installed WTL70.exe from Microsoft. I did a search on my HD afterwards, no atltypes.h.
|
|
|
|
|
No, not a WTL file, an ATL file, ie it comes with VC++.NET
It's in the vc7/atlmfc/include folder.
Steve S
|
|
|
|
|
|
i am using the machine generated Code for the MS Command button (ActiveX).
When developing under WinNT4.0 there was no problem in Setting the Picture Path in the Properties to a BMP File and é voila, the dialog showed up with a bitmap button.
Now i am developing under Win2k, and everytime the dialog with the buttons intialises, the code crashes. Without the Bitmaps it works perfectly. Checking the Source i would manually load the bitmaps to the buttons (hoping that this might work).. i would like to load bitmaps from an Resource ID.
My Problem right now is that it needs an IDispatch*. I guess that i need a CPicture Object (casting it to an IDispatch*), but i can't find any constructor which would take an id, or a CBitmap or sthing like that.
Can anybody help?
Thanks in advance,
Bernhard
"I'm from the South Bronx, and I don't care what you say: those cows look dangerous." U.S. Secretary of State Colin Powell at George Bush's ranch in Texas
|
|
|
|
|
See my article "PixView". You may be able to use some of the code I have in the pix.h header for the second part of your problem.
|
|
|
|
|
thanks.. this really helped.. never knew about the CPictureHolder Class.
"I'm from the South Bronx, and I don't care what you say: those cows look dangerous." U.S. Secretary of State Colin Powell at George Bush's ranch in Texas
|
|
|
|
|
Is the following safe?
{<br />
map<CComBSTR, CComBSTR> mp;<br />
<br />
{<br />
CComBSTR& bstrNew = mp[L"1"];<br />
bstrNew = "Hello";<br />
}<br />
<br />
wprintf(mp[L"1"]);<br />
}
Will bstrNew get destroyed, thus invalidating the "Hello" string?
Jeremy Pullicino
C++ Developer
Homepage
|
|
|
|
|
Yes, this is safe. A reference is an alias for an object that exists elsewhere - in the map, in this case. When a reference goes out of scope, the referenced object still exists and no destructor call is made. In this respect, references work like pointers.
Brad
|
|
|
|
|
Jeremy Pullicino wrote:
map<CComBSTR, CComBSTR> mp;
I'd be careful, mixing non standard-library components with standard components could be dangerous. If you can afford to convert and store std::string's / std::wstring's, or boost::shared_ptr's to BSTR's prefer that to using the microsoft wrappers.
From MSDN
CComBSTR::operator &
BSTR* operator &( );
Modern C++ Design (7.6) - Alexandrescu
"Overloading unary operator& makes the Smart Pointer unusable with STL containers."
He then goes on to suggest never overloading operator& for components that are going to be used generically.
If you can keep you head when all about you
Are losing theirs and blaming it on you;
If you can dream - and not make dreams your master;
If you can think - and not make thoughts you aim;
Yours is the Earth and everything that's in it.
Rudyard Kipling
|
|
|
|
|
|
Cool, thanks mike didn't even know it existed.
When did this get added? for .NET
If you can keep you head when all about you
Are losing theirs and blaming it on you;
If you can dream - and not make dreams your master;
If you can think - and not make thoughts you aim;
Yours is the Earth and everything that's in it.
Rudyard Kipling
|
|
|
|
|
|
How to resize the client rect of the control when designing?
The sample from the msdv is so complex that I can not understand, Thank you for the hlep!
|
|
|
|
|
I've been writing a DHTML control and have noticed it flickers a lot when resized with 'Show window contents while moving/resizing' on.
This happens even with the unmodified wizard-generated DHTML control (using vs.net, add atl control, dhtml control). The control works by using CAxWindow as an activex container window and creating a control (IWebBrowser2) inside it. For an example, create the dhtml control with the wizard, compile, then drop the control onto a form in vb/c# and make it fill the form. Then compile that and resize it.
Although I've read up a bunch about flicker, I'm not quite sure how I'm supposed to extend or modify CAxWindow to remove this flickering. Any ideas?
|
|
|
|
|
I think this is an issue with the DHTML control (MSHTML). I see the same problem in an app I'm working on which uses CHtmlView.
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|
|
not too sure about the WebBrowser activex control, but if you're using CWindow or it's classes, the following can help...
Insert a message handler as follows
MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBackground)
then implement the handler...
<br />
LRESULT OnEraseBackground(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)<br />
{<br />
return 1;<br />
}<br />
Ryan
|
|
|
|
|
Can't Register atl com in chinese(unicode) path!
How Can I do it?
ZHANGYIFEI
|
|
|
|