|
Thanx much appriciated I know so little of c++!
[] /\ () X
|
|
|
|
|
Ive recently coded a graphics control using ATL where all my draw code is performed using setPixelV directly to the HDC (device context). The problem is Iam trying to change the height and width of the control using the HEIGHT & WIDTH parameters that are declared in the HTML page (My control is IE deployed) upon object declaration. This seems to have some effect because instead of simply giving me a larger draw area it just tiles the existing draw across the screen in the specified height & width!?! Ive tried changing the m_sizeExtent.cx & m_sizeExtent.cy in the actually control code and this seems to be ok in the activeX test container but yet again fails in Internet explorer. Does anyone know how to solve this horrid problem .pretty please
[] /\ () X
|
|
|
|
|
i have the following problem, if i declare a variable in a local function and then assign a value in a try block under release min dependency the value is corrupt or the same as it was before the try block upon entering the catch. Please what am i doing wrong?? The code is below:
STDMETHODIMP CCMI_BioWrapper::QueryTemplate(BSTR Badge,BSTR *Response)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
int nRetCode;
CString strVal;
nRetCode = 0;
try
{
nRetCode = 99;
return S_OK;
}
catch(...)
{
// I would expect nRetCode to be 99 here
// however it is always 0, unless i do a debug build
// then it always works
strVal.Format("Q0 %d",nRetCode);
*Response = strVal.AllocSysString();
return S_OK;
}
}
|
|
|
|
|
I don't understand how you can ever be in the catch block. If you 'throw' before or during the code to set 'nRetCode' then its value in the catch block will be indeterminate. But your code cannot throw in its try block...
Paul
|
|
|
|
|
Sorry i left out the following line before returning from the try
RaiseException(0,0,0,0);
This is just a sample that creates the problem
Thanks for your reply
If i raise the exception manually i don't understand why the variable is corrupted.
|
|
|
|
|
AFAIK direct use of the 'RaiseException' API isn't really appropriate to throw a C++ exception, which is what catch (...) will catch.
This function always prints 'nRetCode = 99'.
void TestFn ()
{
int nRetVal = 0 ;
try
{
nRetVal = 99 ;
throw 0 ;
nRetVal = 1 ;
std::cout << "nRetVal = " << nRetVal << std::endl ;
}
catch ( ... )
{
std::cout << "nRetVal = " << nRetVal << std::endl ;
}
}
Perhaps your problem is down to a conflict between some Structured Exception Handling boilerplate in ATL and C++ exceptions?
Paul
|
|
|
|
|
Never knew that, thanks got rid of RaiseException and replaced with a throw, and the problem went away.
Thanks Again
|
|
|
|
|
I Have created an IE ToolBand, NON MFC, and I careted Owner Drawn Menu,
now my problem is, When I click on Owner-Drawn menu, I happen to see that my address bar dosent open the desired URL , It shows DONE on LHS and Progress bar is set to zero, DID any one encountered such problem, How to solve it..
regards
Balkrishna Talele
|
|
|
|
|
Hello everyone:
I made a combo box in a WTL tree view, when the WM_LBUTTONDOWN happened , how can i know whether the list box of combo box is clicked?
Thank you.
-Freehawk.
|
|
|
|
|
hi
Did you try by subclassing the listbox and editctrl on OnCtlColor . chk the MSDN knwoledge base article with id Q174667 for more details.
rgds..mil10
|
|
|
|
|
Hi!,
I want to create a read-only view of excel,word or powerpoint file using the ole techonology.
I use the default object handler provided in ole32.dll
I dont know what steps to follow after creating the object using:
hr=CoCreateInstance(clsid,NULL,CLSCTX_INPROC_HANDLER,
IID_IUnknown,(PVOID*)&pUkwn);
the object handler basically implements IDataObject,IOleCache and IViewObject.
IViewObject::Draw will draw on the specified device.
but before that I want to pass data to the object.
which interface shall I use?
thanks
Anshuman
|
|
|
|
|
I am using ATL with Visual Studio.NET 2003. I seem to be having a problem
with template member specialization involving the CComPtr<> class declared
in atlcomcli.h. In the declaration for CComPtr<> the last entry for a
member function is:
template <>
T* operator=(const CComPtr<T>& lp) throw()
{
return static_cast<T*>(AtlComPtrAssign((IUnknown**)&p, lp));
}
The code I am working with declares a template member specialization similar
to this:
CFoo* CComPtr<CFoo>::operator=(const CComPtr<CFoo> & lp)
{
...
}
In VS.NET 2002 this works just fine. However, in VS.NET 2003 I get compiler
error C2511 (overloaded member function not found ...). I can remove the
line 'template <>' from the CComPtr<> class declaration in atlcomcli.h
(shown above) and the code will then compile just fine. Is this a bug in
ATL or is there something I am not seeing?
Since I don't want to modify the original ATL files, I have made special
modified copies of atlcomcli.h and, by necessity, atlbase.h and I have
included them in the project in order to do a workaround. Is there a better
way?
Thank you,
Ray Gregory
|
|
|
|
|
In standard C++, you can't just specialize a single member function of a template class. You have to specialize the whole class template. Earlier versions of Visual C++ erroneously allowed this.
Why do you need to specialize CComPtr ? You should normally be using this class with COM interfaces; if you're trying to use it with something else, I suggest writing a smart pointer template of your own. Using CComPtr with something that isn't a COM object will just confuse people.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
I have found that I can specialize the single member function just by removing the line 'template <> ' that immediately precedes the declaration of the operator= function in the delcaration for CComPtr in atalcomcli.h.
I have to specialize the operator= member function of CComPtr to avoid a compiler error about ambiguous conversions. The specialized function does the same thing as the default function with the exception of some typecasting.
|
|
|
|
|
The class CFoo is a COM interface. It inherits multiply from, among other things, IDropSource and IDropTarget . In fact this is the reason I need to specialize the asignment operator for CComPtr<CFoo> . If I don't, then the compiler signals ambiguous conversions between CFoo* and IUnknown* because both IDropSource and IDropTarget derive from IUnknown .
Unfortunately, the specialized copy asignment operator breaks in VS 2003 but not in VS 2002.
|
|
|
|
|
Could you show the lines that give the ambiguous conversion error?
Thank You
Bo Hunter
|
|
|
|
|
Hi,
warning: this is sort of a newbie question!!!
I've got a list of pointers in a class which I often need to clear, I've tried the clear and remove methods but these only clear the entries from the list and dont actually delete the objects that the pointers point to. The way that I'm currently deleting these objects is by iterating through the list assigning the iterator to a local variable which is of the same type of the list variables. I then remove the iterator from the list and then delete the local variable ( delete ( *it ) ; doesnt work hence local variable). I then set the iterator to the beginning of the list and start the process all over again (assuming I havent reached the end of the list).
Is this the correct way of doing this? (it just seems very long winded and overly complex for something which must be common in most programs).
many thanks,
|
|
|
|
|
delete( *it ) should work, but you should probably do it in two stages: first delete the objects pointed to, then delete the list elements (the pointers themselves). My RemoveAll would probably look something like:
for ( list<int*>::iterator it = l.begin();
it < l.end();
++it )
{
delete( *it );
}
l.erase( l.begin(), l.end() ); where l is a list<int*>
[EDIT] To make it clear, I think the problem you're having is that you're deleting the current element, pointed to by this iterator, before moving to the next element, so the iterator can't get the next element. You could handle this in the classic linked-list fashion, by retrieving the next value of the iterator before deleting this one. [/EDIT]
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
cheers,
I'll give your code example a try tonight (knew there had to be an easier way ).
|
|
|
|
|
|
|
I've used this approach in the past,
struct DeleteObjectHelper
{
template< typename T>
void operator ()( const T* p ) const
{
delete p ;
}
template< typename K, typename T>
void operator ()( const std::pair< K, T>& p ) const
{
delete p.second ;
}
} ;
template <class C> EmptyContainer ( C& c )
{
std::for_each ( c.begin (), c.end (), DeleteObjectHelper ) ;
c.clear () ;
}
then it's used thus,
std::list<MyClass *> MyList ;
EmptyContainer ( MyList ) ;
std::map< std::string, MyClass * > MyMap ;
EmptyContainer ( MyMap ) ;
Paul
|
|
|
|
|
Not surprisingly, I suggest my little functor[^]
for_each(myList.begin(), myList.end(), free_ptr<MyClass>());
myList.clear();
|
|
|
|
|
I am confused and why I can not store information in an object. If I want to save this information what I have to do?
#include <list> std::list<rect> MyList;
RECT rc = {0,0,0,0};
MyList.push_back(rc);
std::list<rect>::iterator it = MyList.begin();
RECT& RectOne = (RECT) *it;
RectOne.left = -1;
RECT& RectTwo = (RECT) *it;
int left = RectTwo.left;
RectOne is reference to first element of the RECT container. I changed the value of the first element of the container, and look the value in RectTwo, but it didn’t change the value. Real confused.
Agha Khan
|
|
|
|
|
What appears to be happening is that due to the cast
RECT& RectOne = (RECT) *it; the compiler is generating a temporary object which is a copy of the object referred to by the return value of *it , then binding the reference RectOne to that temporary RECT object. Similarly, RectTwo is bound to a different temporary object.
The answer is simple: remove the casts. The compiler no longer generates temporaries, and both references are bound to the original object.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|