|
I need a sample application for connecting to sql server database in ATL.
Thanks..
|
|
|
|
|
|
How can create I an ActiveX which can still active after close IExplorer?
|
|
|
|
|
I wrote a plugin for IE with ATL. Now my requirement is to pop up a modeless dialog in IE so that it can display some information extracted from the page of my IE explored.
When I use DoModal(), it works fine
But I need to show it modeless, so when I use (SW_SHOWNORMAL), my plug in crashed. it says error in atlwin.h 2815 line
Anyone can tell me why and do me a favor? Below is my code:
CMainDialog d;
HWND hIE;
HRESULT hr = m_pBrowser->get_HWND((long*)&hIE);
d.Create(hIE);
d.ShowWindow(SW_SHOWNORMAL);
//error code in atlwin.h
virtual ~CWindowImplRoot()
{
#ifdef _DEBUG
if(m_hWnd != NULL) // should be cleared in WindowProc
{
ATLTRACE(atlTraceWindowing, 0, _T("ERROR - Object deleted before window was destroyed\n"));
ATLASSERT(FALSE);
}
#endif //_DEBUG
}
|
|
|
|
|
Hi everyone,
Look at follow code:
UINT uFormat = DT_WORDBREAK|DT_EXTERNALLEADING;
CRect rect(10,30,200,60);
::DrawText(dc,"hi harry, how are you! there are no persons in the school fdsfdsfsd fsdfdsf",-1,rect,uFormat);
Run this code in the OnPaint(), the result is that there is no compelete string show in the region(CRect rect(10,30,200,60));
I want to add "..." into the end string display. If someone can help me, please tell me how.
Thanks.
|
|
|
|
|
Add DT_END_ELLIPSIS to your uFormat.
- S
50 cups of coffee and you know it's on!
A post a day, keeps the white coats away!
|
|
|
|
|
Hi Steve,
It's only one line for this case, I want to show string like this:
many of them virtual, to convert an object to and from other types. This conversion is mainly used by the property browser to convert...
Can you help me how show string in mutlti lines with '...'.
Thanks
|
|
|
|
|
Yeah, I don't think end ellipsis works with multiline. You might try DT_WORD_ELLIPSIS.
I saw some post about adjusting the height of the rect to make it an integral of the font size, but that seems like a pain.
- S
50 cups of coffee and you know it's on!
A post a day, keeps the white coats away!
|
|
|
|
|
DT_WORD_ELLIPSIS also is fit in this case.
|
|
|
|
|
I wanna implement a toolbar for Windows using WTL classes like CToolBarCtrl. For the toolbar to work I saw in numerous examples that you have to create a reflection window, that is essentially a hidden parent for the toolbar so you can fetch the commands send by the toolbar.
I wonder if you could implement a reflective toolbar using the CWindowWithReflectorImpl?
I never got it to work though. The created window did not repaint itself and the toolbar was not visible. Anyone here knows how to use CWindowWithReflectorImpl?
Thanks in advance!
Happy coding,
Philipp Kursawe
|
|
|
|
|
Some coding standards at my end says that, Do not use smart types in a container?
Does anyone know reason for this?
|
|
|
|
|
Any extra things that one has to consider while using this?
|
|
|
|
|
When copying container auto_ptr will incur problems.
No problem with shared_ptr .
I'm using shared_ptr in a vector now.
system
|
|
|
|
|
Thanks for the answer.
but my other question is e.g.
what care needs to be taken if i use _bstr_t in a vector?
|
|
|
|
|
_bstr_t is like shared_ptr, it can be copied,
but there is a problem about the semantic:
For example,
1. let vecotr a contain some _bstr_t pointers,
2. copy a to b
3. get some pointer in b, and changed the object through the pointer, think what about a.
I think it is not the semantic of copy.
system
|
|
|
|
|
Here is my test code.
class fig_line
{
public:
fig_line(ADO::_ConnectionPtr connection, const std::wstring &source_query);
virtual ~fig_line(void);
fig_line(){}
private:
fig_line(const fig_line &a_fig_line){}
fig_line & operator=(const fig_line &a_fig_line){return *this;}
}
std::vecotr<fig_line> m_lines;
m_lines.resize(10);
</fig_line>
class fig_line
{
public:
fig_line(ADO::_ConnectionPtr connection, const std::wstring &source_query);
virtual ~fig_line(void);
fig_line(){}
fig_line(const fig_line &a_fig_line){}
fig_line & operator=(const fig_line &a_fig_line){return *this;}
}
std::vecotr<fig_line> m_lines;
m_lines.resize(10);
</fig_line>
class fig_line
{
public:
fig_line(ADO::_ConnectionPtr connection, const std::wstring &source_query);
virtual ~fig_line(void);
fig_line(){}
}
std::vecotr<fig_line> m_lines;
m_lines.resize(10);
</fig_line>
Why can't case 1 be compiled?
system
|
|
|
|
|
Your class must have a public or default copy constructor and assignment operator. std::vector requires an accessible copy constructor and assignment operator in order to do operations such as resizing.
In case #1, both are private; thus, case #1 does not compile. In case #2, both are public; thus, this case compiles. In case #3, the class uses the default copy constructor and assignment operator (which are too public); thus, it compiles likewise.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
modified on Tuesday, September 16, 2008 1:24 PM
|
|
|
|
|
Thank you. I see.
But I got another question, it seems that
void resize(
size_type _Newsize
); only needs a default constructor, and
void resize(
size_type _Newsize,
Type _Val
);
may need a copy constructor or assignment operator, however one of them is enough.
Is that so?
system
|
|
|
|
|
If you need a copy constructor, most likely you need it to do a deep copy due to dynamically allocated memory. Thus, a destructor and a copy assignment operator would be needed to prevent memory leaks.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
modified on Wednesday, September 17, 2008 9:23 AM
|
|
|
|
|
I'd like to do serialization using file stream (coz I don't want an extra lib, eg. boost),
then what are there problems? It may be the reason why boost has the serialization libray.
system
|
|
|
|
|
The difficulty has nothing to do with file streams - open them in binary mode (so they're just a stream of bytes, with no interpretation of things like CR-LFs) and you can store anything in them.
The serialisation problem making sure that all the objects you want to serialize have some suitable mechanism for doing so. It's also nice to be able to get those mechanisms in place in a reasonably non-intrusive manner.
Other implementation issues:
- If an object is referenced from multiple places, making sure you recreate that object once when reading in a serialized object graph
- If you have a collection (e.g. array or vector) of pointers to some base class, but the objects pointed at are of derived classes, you need to make sure that the derived class serialization functions are called
- You need some way of identifying the type of objects you've serialized
- Constructors - you really need a default (no parameter) constructor for all serializable classes, even if you don't really want one
The Boost.Serialization requirements[^] and
rationale[^] give more information about the issues involved.
I've created my own serialization code before (it must have been about 1998/9?). It was painful enough that I have no desire to do so again, so would use an existing library to get serialization.
|
|
|
|
|
Thanks very much.
I will use boost.
system
|
|
|
|
|
When this event is called a second time, the MS Word Document closes. Don't know why. Am I missing something obvious here? Also, I can't get the SaveAs dialog to pop-up.
I'm developing on XP SP2 (professional) / visual studio 2005 / word 2003
void __stdcall CP3AddIn::DocumentBeforeSave(IDispatchPtr ptr, VARIANT_BOOL* pvtSaveAsUI, VARIANT_BOOL* pvtCancel )
{
CString msg;
CComQIPtr<word::_document xmlns:word="#unknown"> spDoc(ptr);
ATLASSERT(spDoc);
if( savesAllowed > 0 )
{
*pvtSaveAsUI = VARIANT_TRUE;
*pvtCancel = VARIANT_FALSE;
savesAllowed--;
msg.Format( _T("You may save %s %d more %s."),
spDoc->Name.GetBSTR(),
savesAllowed,
( savesAllowed == 1 ) ? _T("time"): _T("times") );
MessageBox( 0, (LPCWSTR)msg, _T("EVENT: DocumentBeforeSave"), 0 );
}
else
{
*pvtCancel = VARIANT_TRUE;
*pvtSaveAsUI = VARIANT_FALSE;
MessageBox( 0, _T("You have either exceeded your save limit\n")
_T("or you are not authorized to save a copy of this document."),
_T("EVENT: DocumentBeforeSave"), MB_OK );
}
}
|
|
|
|
|
It's probably because an exception's being thrown. Helps to attach a debugger to the add-in. The easiest way is probably to tell VS that the debug executable for the add-in is MS Word. Set a breakpoint on the DocumentBeforeSave entrypoint.
One other thing - how do you know that the add-in is instantiated once for each Word document? Strikes me that Word could instantiate the add-in globally and then you have a global save count?
|
|
|
|
|
Sorry, been away for a little bit.
I tend to agree with you about an exception being thrown. However, while I'm a whiz with try/catch statements in "every day" COM, I'm a fish out of water trying to trap an error in automation.
Word dispatches (or whatever the term is) the even DocumentBeforeSave, however, where would the try/catch go, or do I use that at all?
I currently have a try at the very start of DocumentBeforeSave and at the very end, but nothing's getting caught. I'm trying to capture _com_error; perhaps I'm mistaken. Your thoughts?
|
|
|
|