|
if i have to send the selected items to another listbox what functionality should be used?
|
|
|
|
|
If you got how to get the selected items from List box and how to add list box items then mix these functionality.
|
|
|
|
|
Guess i got a problem here...
i am sending u the code.. please help me in this.
say i have 10 items in the listbox. not if i i click the 4 to the 8th item in the listbox, the first 5 items are displaying the listbox.
<br />
CArray<int,int> aryListBoxSel;<br />
int nCount = m_listbox.GetSelCount();<br />
aryListBoxSel.SetSize(nCount);<br />
m_listbox.GetSelItems(nCount, aryListBoxSel.GetData());<br />
<br />
for(int i=0;i<m_listbox.getselitems(ncount,arylistboxsel.getdata());i++)><br />
{<br />
CString str,str2;<br />
int n;<br />
n=m_listbox.GetTextLen(i);<br />
m_listbox.GetText(i,str.GetBuffer(n));<br />
m_list.AddString(str);<br />
}<br />
<br />
what is the reason for that?<br />
<br />
<br />
</m_listbox.getselitems(ncount,arylistboxsel.getdata());i++)></int,int>
|
|
|
|
|
You got the selected indeces in aryListBoxSel; and you are using your own index, i for getting the selected text where i varies from 0 that i swhy you got the first 5 items. you have to use some thing like m_listbox.GetTextLen(aryListBoxSel[i]), m_listbox.GetText(aryListBoxSel[i],str.GetBuffer(n));
|
|
|
|
|
thanks a lot. a simple mistake costed me a lot of time.. better late than never.. thanks anyways.
|
|
|
|
|
Doubts again,
I was telling u that i have to merge the selected files. i know that i can use CFile to do the reading and writing of files. but when we select the file how do we store each file name? when i tried to use the array its giving me an assertion error.
|
|
|
|
|
Except DlgDirList you can use of FindFirstFile/FindNextFile.
|
|
|
|
|
I followed the tutorial here [^]:
create the driver service and start it if created successfully. After creating or open the service successfully,it start the service failed. I use GetLastError and find the error code is 2.
I don't know why,and how to fix it?
Regards.
|
|
|
|
|
Before asking a question here you should really spend some time trying to debug the problem.
What happens if you attempt to debug it ?
Error code 2 = The system cannot find the file specified.
regard,
Jonathan
|
|
|
|
|
Of course I did. I know what error code 2 means.
But the real problem is that,the file(example.sys) does exist.
Regards
|
|
|
|
|
Look in the registry and check what the entries added by the SCM look like. The ImagePath entry is probably not correct.
Judy
|
|
|
|
|
Hello everyone,
When we use OLESTR to allocate a variable from string literal, like OLESTR("Hello World"), the memory space for the string literal is on stack, right?
I can not find official document for this from MSDN.
thanks in advance,
George
|
|
|
|
|
George_George wrote: When we use OLESTR to allocate a variable from string literal, like OLESTR("Hello World"), the memory space for the string literal is on stack, right?
Nope, String literals don't follow the lifetime rules of the variables allocated on the stack. AFAIK they are always allocated on read-only memory.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Thanks CPallini,
So, we can feel free to pass the OLESTR pointer, which points to an OLESTR allocated in one function to another function (I mean passing the address of OLESTR string literal)?
regards,
George
|
|
|
|
|
Yes.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Cool, CPallini!
Question answered.
BTW: do you have any support document which declares OLESTR string literal is in global read-only memory other than stack memory?
regards,
George
|
|
|
|
|
technically, yes, with your VC compiler. however, you should know that it's only because of the optimizer, and some other compilers may not behave identically. so I'd say not to make such assumptions then...
|
|
|
|
|
Thanks toxcct,
1.
Do you mean when we enable string pooling, OLESTR string literal will be in global read-only memory, and it is safe to pass from one OLESTR pointer pointed to string allocated in one function to another function.
2.
If we do not enable string pooling, OLESTR string will be in stack, and above operation is not safe?
3.
You always treat OLESTR in stack? Other than in global accessible memory area?
regards,
George
|
|
|
|
|
I won't answer each specific question, because as I already said in my previous post, all this is compiler/optimizer specific, and the C++ standard does dictate a single behavior for that...
|
|
|
|
|
I am more interested in which option in MSVC could be used to control such optimization? The string pooling option?
regards,
George
|
|
|
|
|
George_George wrote: I am more interested in which option in MSVC could be used to control such optimization?
Why ?
|
|
|
|
|
Thanks toxcct,
Because I am reading code which pass pointer to string literal allocated in one function, to another function.
I want to know,
1. whether it is safe code?
2. If not, how to make it safe, by turning on string pooling? (I want to save my efforts to rewrite all such code if it is unsafe).
regards,
George
|
|
|
|
|
if you're sticking to MSVC, you can assume it is (as i said in my first post !!)
|
|
|
|
|
Thanks, toxcct!
Good to know you think I am correct this time.
regards,
George
|
|
|
|
|
I think it is always safe (i.e. it maybe unsafe only for not-standard compilers).
Only write access to string literal buffer gives unpredictable results, see, for instance,
[^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|