|
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?
|
|
|
|
|
Hi
how can I Resize ActiveX Control ?
|
|
|
|
|
Hi,
In my application I have two button, one is for creating share button and other is for modifying the permission.
Creating the share folder there is no problem. When I select the shared folder and click the the permission button windows open its permission security dialog.This is works fine in all OS.
Now the problem is: In vista OS machine I have installed my application it working as usual but when I install MS office 2007 Japanese and run my application, Application is running and able to create share folder but when you select the shared folder and click the permission button the application hangs.This behavior is not occuring if I install MS office 2007 English.
Japanese 2007 IME is causing the problem. This problem is not occuring when you install the MS office 2007 Japanese without "Office feature and Tools" option.
When I analysis code
AtlGetSecurityDescriptor(pszObjectName,SE_LMSHARE,... )
SecDesc= assigining the security pointer variable
CSedurityDesc si(SecDesc)
EditSecurity(hWnd, &si)
Instead of SE_LMSHARE if you give any other SE_OBJECT_TYPE it opens permission dialog (rights are in japanese usually that will be in english). In the permission dialog if press OK it is showing popup stating it will change modify the permission...
As this an shared folder we normally set SE_OBJECT_TYPE as SE_LMSHARE.
Bool flag = EditSecurity(hWnd, &si) - This is the place where application hangs i.e because of si. Please let me know how to overcome this problem in vista OS machine having MS office 2007 Japanese.
Thanks & Regards,
Gnanaprakash
|
|
|
|
|
Please, help me to find tutorial or a samples how to do it
|
|
|
|
|
I am also trying to achieve same what you are trying to.
If you find any answer or any link please share.
|
|
|
|
|
NOTIFY_HANDLER (IDC_LISTVIEW, LVN_BEGINLABELEDIT, OnGridBeginEdit)
LRESULT OnGridBeginEdit(int idCtrl, LPNMHDR pnmh, BOOL& bHandled)
{
RECT rcpos;
// size rcpos to the subitem rect...
HWND hwnd_edit = m_lv.GetEditControl();
CComboBox combo;
combo.Create(m_lv,&rc_pos,_T("drop_list"),CControlWinTraits::GetWndStyle(0) | CBS_DROPDOWNLIST);
combo.AddString(_T("a"));
combo.AddString(_T("b"));
combo.AddString(_T("c"));
string sText="a";
combo.SelectString(-1,stext.c_str());
combo.ShowWindow(SW_SHOW);
run a local messageloop that exits on VK_CANCEL | VK_RETURN | WM_MOUSEDOWN on other windows
// read out the combo
combo.DestroyWindow();
return -1; // prevent the standard edit control
}
|
|
|
|
|
Hi. I'm working in a software wich has a system menu, an icon tool bar, and recently, i've added another tool bar just down the other.
I've been using AddSimpleReBarBand(...) to create them, but i would like to control this last tool bar to make it appear and disappear when i want.
I've tried to destroy it, and it does, but i can't make disappear the space made to place the menu.
Could anyone tell me the way to do it? It seems not to be very difficult, but a can't find the way.
Thank you in advance.
Ricard
|
|
|
|
|
Hi again! I still don't have the solution (maybe it's not as easy as i thought) and i've been thinking for another possibility.
Well, the main toolbar occupies half of the width, so it would be possible to place the second toolbar just next to the first one. Then, it would be ok to manipulate it without affecting any vetical spacing. But, of course, i've found another problem. When i place the second toolbar it is placed very far from the first one, and it falls out the menu. I've tried to fix the length with the AddSimpleReBarBand(...) parameters, but it doesn't seem to work.
I've been checking the 4th and 5th parameter. 4th seems to be a width (maybe the toolsbar's width?) and 5th is a boolean that seems to avoid minimizing the toolbar. Well, none of the them seems to change my toolbar separation. Any idea?
Let me know your experiences with atl toolbars. Any opinion will be very useful for me. Thank you all!
Ricard
|
|
|
|
|
I'm coding an ATL IE plugin as the article from msdn(below is the link)
http://msdn.microsoft.com/en-us/library/bb735853(VS.85).aspx
I did step by step as it describes in the dll part, but there is no responding of the Exec method which should run when I click my tool menu 'Image Download'. I can debug into the STDMETHODIMP CImageFetcher::SetSite(IUnknown* pUnkSite) method.
I have no idea where I made a mistake, any one can help?
Thanks previously!
|
|
|
|
|
|
Dude what is your damage? Why have you asked this question in this forum?
What do you do just pick a random forum?
That is an Operating Systems / SysAdmin[^] question.
Come on man at least make an effort. I mean you are asking people here to help you for free and you can't even make the effort to put your question in the correct forum, how lame is that?
led mike
|
|
|
|
|
Hi
I Create a ATL Dialog box and I host a Webpage on Dialog using CAxWindow and webpage having 1 close button, I want when user click that close button (Which call window.close()), My Dialog is Close without any Internet Explorer Alert Notification. What can I do in my Workspace to Remove this Notification.
Thanks in Advance.
|
|
|
|
|
I want to something like serialization using string , but don't know whether the string class in STL supports this any way.
Thanks.
system
|
|
|
|
|
Are you saying you want to save a string to a file? If so, then this code illustrates how to write a string to a file and the different mechanisms available when reading strings from a file.
None of them are totally satisfactory, as it's difficult to determine where the original string's end was after it's been written to a file. To be more reliable, I'd probably write the string length out first, as that will tell you how many characters to read in. Other approaches (e.g. quoting the string) would work, but would require you to process the string, escaping quote characters.
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
int main(int, char**)
{
{
std::ofstream a("a.a");
std::string s = " Hello World";
a << s << std::endl;
}
{
std::ifstream a("a.a");
std::string s;
a >> s;
std::cout << s << std::endl;
}
{
std::ifstream a("a.a");
std::string s;
a >> s;
std::cout << s << std::endl;
}
{
std::ifstream a("a.a");
std::string s;
getline(a, s);
std::cout << s << std::endl;
}
}
|
|
|
|
|
Well, the 2nd and 3rd parts are the same.
Do you know to do std::string serialization?
system
|
|
|
|
|
Whoops - the line a >> s; in the third part should have been a >> std::noskipws >> s;
followait wrote: Do you know to do std::string serialization?
What do you mean by serialization? If you want a generic serialization framework, then look at Boost.Serialization[^]. Otherwise....well, you need to define what you mean by serialization.
|
|
|
|
|
Stuart Dootson wrote: What do you mean by serialization?
save/load the object
It seems that I should learn Boost first.
system
|
|
|
|
|