|
Cedric Moonen wrote: all the strings in your array are empty, so it's normal that the buffer will be empty too
Sorry ... I forgot to mention that the string buffer has data in it. But I will try the snippet that you supplied.
Thanks Cédric
Regards,
The only programmers that are better that C programmers are those who code in 1's and 0's
Programm3r
My Blog: ^_^
|
|
|
|
|
Programm3r wrote: I have the following std::string array. How can I get hold of the first elements data? I have tried the following without success:
the code seems fine to me, but only thing seems problamatic to me, is if your first element contain the data more than 128 character. there could be overflow in strcpy call!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
|
What does the following produce:
cout << openDoorTags[0].c_str();
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
hello all,
i have a problem with creating a dialog inside a dialog and removing it . i mean by creating dialog is embedding the dialog with the help of a picture frame and i did that by doing this piece of code
m_GAUserEnteredOption.Create(this, IDC_S_VIEW_USERENTEREDOPTION,
IDR_F6CP_MAINFRAME,
RUNTIME_CLASS(CGADocument),
RUNTIME_CLASS(CGAMainFrame),
RUNTIME_CLASS(CDigitalUserOption),
WS_CHILD | WS_VISIBLE, 0L);
and i did this because on the original dialog i couldnt place anymore controls since it was overflowing (crossed 255) , but once i embedd this dialog i cant remove it. i tried using destroywindow() or closewindow() its not working . and i cant get to the original controls which are on this place before . how to remove this frame and dialog through code . if anybody knows it plz help me
"Men never do evil so completely and cheerfully as when they do it from religious conviction"
-Pascal
|
|
|
|
|
If you know that you will need it by all means, why dont you design it in your resource editor, stablish a class to it and use DoModal? It will be easier.
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
hi ,
its not supposed to be a child window but in the same dialog i need it . it doesnt have any ok or cancel button ,its just a formview class dialog attached to another dialog . like a patch of new set of controls it will attach to original dialog and it has another class also for that. but i cant remove through code once it is attached .
"Men never do evil so completely and cheerfully as when they do it from religious conviction"
-Pascal
|
|
|
|
|
And why dont u use a simple dialog and resize it to have more working surface?
I have more than one VariabledSize Dialog in one project, and more than one view (up to 28 CFormViews in 4 types with different sizes according to the type they belong).
But I didn't mix things, CFormViews are in independant frames, and Dialogs are "unique".
To make the Dialog with variable size, I designed it in my resource editor with ALL the controls I needed and set them to not visible, then according to the parameters that determined how many of the should be visible... I used the SetWindowPos / MoveWindow to change the size and made visible just the controls that must be shown.
does the idea help you?
If not... I ask you for a better explanation, im not english speaker and I have not understood what you need
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
Hi,
I am using a CListCtrl with check boxes for the row (using LVS_EX_CHECKBOXES). Now, my requirement is to use check box in column header of the CListCtrl so that I can "Select All" or "Deselect All" items in list on a single click.
Any help would be appreciated.
Regards,
Paresh.
|
|
|
|
|
Don't mind me, but I do that by placing a button control just under CListCtrl and I place icon (looking like checked box) on it and add some code on 'OnClick' member where I loop through list and set each row as checked. Add another icon button for deselecting all rows.
Glad if I could help!
|
|
|
|
|
Thanks for your prompt reply.
I am seeking an easier solution for this.
Regards,
Paresh.
|
|
|
|
|
Paresh Chitte wrote: I am seeking an easier solution for this.
What's hard about that? It seemed easy and straight forward to me.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
See Here[^]
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Thanks for your prompt reply.
Regards,
Paresh.
|
|
|
|
|
Found solution here[^].
Thank you all for your replies.
Regards,
Paresh.
|
|
|
|
|
The function ItemHasChildren (TreeItem) returns true for a perticular node but GetChildItem (TreeItem) doesnot return a valid node without expanding the node TreeItem . This expanding and shrinking is causing flicker in the tree. Could anyone provide a better solution ?
The sample code is following -
if (ItemHasChildren (TreeItem))
{
HTREEITEM tmpTreeItem = TreeItem;
Expand (tmpTreeItem, TVE_TOGGLE);
TreeItem = GetChildItem (TreeItem);
Expand (tmpTreeItem, TVE_TOGGLE);
}
|
|
|
|
|
NishantB++ wrote: expanding and shrinking is causing flicker in the tree.
Stop the tree from redrawing while you are tampering with it.
From my CTreeView I do:
GetTreeCtrl().SetRedraw( FALSE);<br />
...<br />
GetTreeCtrl().SetRedraw( TRUE);
Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all. Douglas Adams, "Dirk Gently's Holistic Detective Agency"
|
|
|
|
|
Thanks for your reply.
I have already tried this option, and it is not working.
By the way, have you seen this kind of behaviour that you have to expand the tree first to get the child node, or I am doing something wrong?
|
|
|
|
|
NishantB++ wrote: expand the tree first to get the child node
I have.
But then I use CWaitingTreeCtrl from Codeproject[^], and there things are much more complicated.
It might really be that the item does not know that it has children and how many of them.
Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all. Douglas Adams, "Dirk Gently's Holistic Detective Agency"
|
|
|
|
|
The below code is from MSDN. While their samples can be lacking sometimes, they're not usually wrong.
if (pmyTreeCtrl->ItemHasChildren(hmyItem))
{
HTREEITEM hNextItem;
HTREEITEM hChildItem = pmyTreeCtrl->GetChildItem(hmyItem);
while (hChildItem != NULL)
{
hNextItem = pmyTreeCtrl->GetNextItem(hChildItem, TVGN_NEXT);
pmyTreeCtrl->DeleteItem(hChildItem);
hChildItem = hNextItem;
}
}
The only thing I can think of that may mess it up is if your parent item does not actually have children in it, but you've manually set its item.cChildren to I_CHILDRENCALLBACK.
Can you check the return value from ItemHasChildren to make sure it's 0 or 1?
Iain.
|
|
|
|
|
hi i am new to c programming.
currently i am trying to do dynamic memory allocation to my struct so that i dont have to use a set number of array:
struct person ptr[10];//i dont want this
i have come up to this:
struct person ptr*;
could anyone show me how to do a dynamic memory allocation on struct which can free me of having to state the array size?
i read some ebook saying i could use malloc but so far they used malloc on the string instead of struct.
thanks.
|
|
|
|
|
...define person...
struct person *pPerson;
unsigned int count = 10;
pPerson = malloc( count * sizeof( person));
if( pPersion = NULL) {
printf( "Insufficient memory available\n" );
exit(0);
}
...use pPerson...
free( pPerson);
Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all. Douglas Adams, "Dirk Gently's Holistic Detective Agency"
|
|
|
|
|
i see where the code is going however could you show me how i shoudl go if i wanted to append to the pointer?
i am thinking if i should create a temp space and reallocated the memory againa dn stores it back in.
how do you think i should do it? and again i would like to say i am doing c programming.
thx
|
|
|
|
|
neodeaths wrote: i am thinking if i should create a temp space and reallocated the memory againa dn stores it back in.
yes, that is the way to go. But there is a function to do that for you:
Use realloc()
To double the size use
pPerson = realloc( pPerson, 2*count);
pPerson would be changed - be sure to not hold any pointers to the old location.
Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all. Douglas Adams, "Dirk Gently's Holistic Detective Agency"
|
|
|
|
|
so reallocate would do the work of allocating the new memory i want to use for me? what about the old one do i need to free the memory myself?
also would the reallocated memory contain my old infomation or do i still have to store it away into a temp and put it back?
|
|
|
|