|
I wish to add single string to the start of a file.
I used:
_file.seekp(0); // move to start of file
_file << something << std::end;
It overrides the text in start of file, but I wish to insert before current text.
Does anyone know how to do it?
THANKS!
Keep it simple
|
|
|
|
|
SimpleProgramer wrote:
I wish to add single string to the start of a file.
I used:
_file.seekp(0); // move to start of file
_file << something << std::end;
It overrides the text in start of file, but I wish to insert before current text.
Does anyone know how to do it?
There is nothing before 0 (which is even a philosophical answer ). Hint: You can write a new file ....
|
|
|
|
|
Hi Guys.
I have a problem about the max dimension of an element that can be used with the container "deque" defined in STL.
I declare a deque typedef with elements of 2049 bytes (but could be everykind of data or class) :
typedef struct
{
char stringa[2049];
} t_Elem;
typedef deque <t_elem> t_Queue;
I populate an instance of this deque with 5 strings :
t_Queue stQueue;
t_Elem stElem;
//
strcpy (stElem.stringa, "Stringa1");
stQueue.push_back (stElem);
strcpy (stElem.stringa, "Stringa2");
stQueue.push_back (stElem);
strcpy (stElem.stringa, "Stringa3");
stQueue.push_back (stElem);
strcpy (stElem.stringa, "Stringa4");
stQueue.push_back (stElem);
strcpy (stElem.stringa, "Stringa5");
stQueue.push_back (stElem);
Then I try to navigate inside deque, using a standard iterator :
t_Queue::iterator p = stQueue.begin();
while (p != stQueue.end())
{
t_Elem localElem;
strcpy (localElem.stringa, ((t_Elem)(*p)).stringa);
p++;
}
But the stQueue.end() operator doesn't stop my loop after 5 cycles !!!! ... then an Access Violation occour when I use the sixth element of deque.
The strange thing is that if I DECLARE the ' t_Elem' string of 2048 bytes instead of 2049, everything's OK !!!
I know that I could solve the problem using string container instead of pure char[204?] data, but the problem occour even if I declare as element a class that has 2049 bytes of data.
I can navigate through deque using a "for (short i=0; i
|
|
|
|
|
Use a std::string (or even a std::vector<char> ) rather than an array of characters?
Stuart Dootson
'Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p'
|
|
|
|
|
The point of the problem is not "use another class to store string". The problem also occour if I use whatever else element 2049 bytes long. Think for example to a Class with members and methods bigger than 2049 bytes.
But I've got an update. Go to here :
http://www.dinkumware.com/vc_fixes.html
Download the new <deque> header and follow instructions. This fixes the problem. There are also many bug fixes about other STL containers... This Site has been signaled me by Paul McKenzie, Elite Member on the CodeGuru Forum Site.
Problem's now solved. Bye to all, Mirko.
|
|
|
|
|
Hi,
I have a toolbar where I dynamically create the buttons. It uses the TBSTYLE_EX_MIXEDBUTTONS style. Everything seems to work fine, however when I resize my window, there is no drop-down on the RHS ( ">>" ) to access the buttons that have been clipped.
Buttons without text work fine. Obviously I am missing something. Here is my code to create the rebar:
<br />
HWND hWndCustomToolBar = CreateSimpleToolBarCtrl(m_hWnd, IDR_CUSTOM, FALSE, ATL_SIMPLE_TOOLBAR_PANE_STYLE | TBSTYLE_LIST & ~TBSTYLE_TOOLTIPS);<br />
CToolBarCtrl = hWndCustomToolBar;<br />
m_customToolbar.SetImageList(*m_sysImageList.GetImageList());<br />
m_customToolbar.SetExtendedStyle(TBSTYLE_EX_MIXEDBUTTONS);<br />
m_customToolbar.SetMaxTextRows(1);<br />
m_customToolbar.AutoSize();<br />
CreateSimpleReBar(ATL_SIMPLE_REBAR_NOBORDER_STYLE);<br />
AddSimpleReBarBand(hWndCustomToolBar, NULL, TRUE);<br />
Then to add my buttons I use the following styles:
<br />
button.fsState |= TBSTATE_ENABLED;<br />
button.fsStyle |= TBSTYLE_AUTOSIZE | BTNS_SHOWTEXT;<br />
m_customToolbar.AddButtons(1, &button);<br />
Is there anything else I need to do?
Thanks in advance.
|
|
|
|
|
Is there a standard notation in use for STL containers/iterators? If not, what are you people using?
For example,
<br />
typedef vector<Blah> BlahArray;<br />
<br />
typedef vector<Blah>::iterator iBlahArray;<br />
typedef vector<Blah>::const_iterator ciBlahArray;<br />
typedef vector<Blah>::reverse_iterator riBlahArray;<br />
typedef vector<Blah>::const_reverse_iterator criBlahArray;<br />
Pssst. You see that little light on your monitor? That's actually a government installed spy camera. Smile and wave to big brother!
|
|
|
|
|
I don't use the typedef thing at all, I think it's ridiculous, and there are better ways to obsfucate ones code, if you really want to.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I don't typedef my STL containers, I typically declare them as one might a variable; encapsulated in a class.
<br />
class MyIntClass<br />
{<br />
....<br />
<br />
private:<br />
list<int> intList;<br />
list<int>::const_iterator intListIterator;<br />
<br />
....<br />
<br />
};<br />
Maybe a better question is what is the advantage of one over the other, then apply that to your programming situation ...
:..::. Douglas H. Troy ::..
Fold with us|Development Blogging|viksoe.dk's site
|
|
|
|
|
Sorry -I posted this to C++ forum but it may be more appropriate here.
Hi,
I've trying to create a browser helper object (BHO) for explorer. I've got a main "manager" class that initializes two objects. Each of these uses an simple XML parser (using MSXML). Now, when parsing XML files, I want to store the results to a struct array (not a class). The struct array is in turn comprised of a few other struct arrays. All mem allocation is static, only the topmost parent struct array is dynamically allocated. That's where the problem is: When I allocate (using new) the struct arr in the first object, its ok. Then when I init the second obj, the new fails and crushes the explorer. I did a simple test in the second obj:
int *i = new int[x];
when x is <255 it's ok. if x>=255 then it crashes (and of course, my struct arr is bigger than 255*sizeof(int) bytes). I don't think I have any serious mem leaks in the code before this.
Has anyone seen this before? Is there a memory limit imposed by explorer (unlikely as it sounds)? I would appreciate any comments.
Thanks,
Pete
|
|
|
|
|
|
I thought that it would be like this. Still, I can't understand why I cannot exceed a limit when allocating memory (except if I have a really serious leak -but when IE is loading, memory consumption looks normal).
Thanks.
|
|
|
|
|
I ported my VS2003 PocketPC WTL project to VS2005 and I have the problems
with resources.
When I modify a Dialog in my resource editor I get an error
Error 1 error RC2104 : undefined keyword or key name: DS_FIXEDSYS
Any idea?
Thanks
|
|
|
|
|
|
Winuser.h reveals:
#if(WINVER >= 0x0400)
#define DS_FIXEDSYS 0x0008L
Good music: In my rosary[^]
|
|
|
|
|
|
Hi,
I have to store 10 strcture in vector.
struct
{
int
int
int
int
};
Can you please help me. I am new to stl programming.
Thanks
|
|
|
|
|
use the <pre> tag to format your post correctly, b'cause we can't see anything on your question.
moreover, what is exactly your request ?
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Vectors can hold pretty much anything with a name, so if you have your struct defined like:
struct myStructure {<br />
int one;<br />
int two;<br />
int three;<br />
int four;<br />
};
then just define a vector of myStructs like so:
vector<myStructure> myVector;<br />
myVector.push_back(firstStructure);
then you can just access your data like you would with a basic array, ie
myStructure temp;<br />
temp=myVector[5];
or you can modify in place like
myVector[5].one=37;
Pretty cool stuff.
|
|
|
|
|
Hi, all!
I'm writing scatter plot program and it, uses function SetWorldTransform() to map coordinate space of whatever data I send to it onto coordinate space of the screen. The function works well, but as well as transforming coordinate space, it transforms objcects(which I draw using GDI+) in it, and I don't need that.
Is there a way to bypass transformation of graphics objects by means of GDI+ or is there any other function that does just that?
|
|
|
|
|
Hi,
I want to use templates to select one of the overloaded functions, basically I am looking for something like this
template<int v>
struct Int2Type
{
enum { value = v };
};
void Function(Int2Type<0>)
{
cout << "Function with Int2Type<0> selected"; -------------- (1)
}
void Function(Int2Type<1>)
{
cout << "Function with Int2Type<0> selected"; -------------- (2)
}
int main()
{
int iselect = GetValue();
Function(Int2Type<iselect>()); // selects (1) if iselect = 1 else selects (2)
// if iselect = 2
return 0;
}
My question is, Whether it is possible to write such a code? Or can someone suggest how to achieve the desired functionality.
Thanks in advance
|
|
|
|
|
You cannot do that: the basic problem is that overload selection takes place at compile time, whereas your iselect value is only known at run time.
So, you need some kind of dynamic dispatch framework to achieve what you're after. The following is a possibility (lacking the terseness of function overloading):
typedef void (* function_t)();
void function0(){...}
void function1(){...}
function_t function[]={&function0,&function1,...};
int main()
{
int iselect=GetValue();
function[iselect]();
} Hope this helps.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
Want a Boost forum in Code Project? Vote here[^]!
|
|
|
|
|
Hi,
I managed to implement some basic drag and drop support in my Tree Control by following the article: http://support.microsoft.com/default.aspx?scid=kb;en-us;214814 on the microsoft site.
However, I'd now like to implement automatic scrolling when the user moves the cursor to the top or end of the view. How would I go about doing this? Can anyone point me to some information?
Thanks in advance.
|
|
|
|
|
Hi guys, I wrote a ATL program (an addin) for MS Word using the article provided by Amit Dey on Outlook addins. It works fine. but the sink events only work for a single instance of Word. i want my application ( and the Sink Events) to function with multiple instances of Word. Can someone help me out? I'm not really sure what the problem is. My command bars are created on all instances of Word but nothing happens when i click them.
This how i implemented my sink event (just like Amit did it):
ATL_FUNC_INFO OnClickButtonInfo =
{CC_STDCALL,VT_EMPTY,2,{VT_DISPATCH,VT_BYREF | VT_BOOL}};
void __stdcall CAddin::OnClickButton(IDispatch*
/*Office::_CommandBarButton* */ Ctrl,
VARIANT_BOOL * CancelDefault)
{
USES_CONVERSION;
CComQIPtr<office::_commandbarbutton> pCommandBarButton(Ctrl);
//the button that raised the event. Do something with this...
MessageBox(NULL, "Clicked Button1", "OnClickButton", MB_OK);
}
Please help me with my difficulty.
Thanks
|
|
|
|
|
Hi,
I was wondering if anyone knows of a combined Tree and List view control for WTL?
The UI I want to create is a list view with three columns. The first column contains the Tree View items and the second and third columns contains properties of each tree item, which are displayed as check boxes.
Thanks in advance.
|
|
|
|