|
Hello,
i use CListCtrl with virtual list, and i have a problem when i try to scroll down to see other items,
CListCtrl jumps to first, allways if i call .SetItemCount() to actualize list content!!!
Is there any way to solve this, that i can scroll down in CListCtrl?
Thank you for help!
termal
|
|
|
|
|
Hi
please put your code here, when you call setItemCount?
|
|
|
|
|
Hello,
ähm, there is no large code, here a sample:
pList->SetItemCount(hashmap.size());
that ist all!
Now if i want to scroll down to other items the focus jump allways to top of the list, or any other previous selected item, that means if i select item no. 15 and i croll down to item no. 2500, by SetItemCount list jumps again back to previous selected item no.15, if no selection jumps to top!
Now i try to catch a OnLvnBeginScrollListAll(NMHDR *pNMHDR, LRESULT *pResult) but i get a error:
"error C2065: 'LVN_BEGINSCROLL' : undeclared identifier"
The msdn say's that i need to include commctrl.h, i have that and the error is again there!
I use VS2005!
So that is my problem now, maybe you can help me here?
regards
termal
modified on Monday, December 17, 2007 9:38:26 AM
|
|
|
|
|
Solved,
with
SetItemState(iIndex, /*LVIS_SELECTED | */LVIS_FOCUSED, /*LVIS_SELECTED | */LVIS_FOCUSED );
termal
|
|
|
|
|
Hi!
for x64 windows, i don't use inline assembly code.
how do i use an external asm file, to use assembly code in my vc project.
what settings have need the .asm file, in project?
Zo.Naderi-Iran
|
|
|
|
|
Hi All,
Using VC++, i want to add integer value to date.
For example:
date is 17/12/2007, if i add 365 days to this date, the result should be 16/12/2008.
AddDays() function is available in .Net. How to do it using VC++ 6.0?
|
|
|
|
|
What is your date variable type?
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.
|
|
|
|
|
what about CTime and CTimeSpan ?
|
|
|
|
|
Thank you, i got the soln
I am using COleDateTime and COleDateTimeSpan.
COleDateTime d;
COleDateTimeSpan s(2,0,0,0);
d::GetCurrentTime();
d = d + s;
|
|
|
|
|
Can anybody suggest a light weight HTTP parser library(DLL) preferably open source?
|
|
|
|
|
Hi all,
I want to find the number of words in a string. That string only contain whitespace, tab space and the new line character. So I code it as follows.
int numberOfWords = 1;
string st(pBuffer);
for(int i = 0;i <= st.length(); i++)
{
if(pBuffer[i] == ' ')
{
numberOfWords ++;
}
if(pBuffer[i] == '\t')
{
numberOfWords ++;
}
if(pBuffer[i] == '\n')
{
numberOfWords ++;
}
}
cout << "\n" << numberOfWords;
But this code is odd. I mean say there is a whitespace and a tab space are occur with each other. Then the result is wrong. How can I avoid such odd points there.
I appreciate your help all the time...
Eranga
|
|
|
|
|
Eranga Thennakoon wrote: I mean say there is a whitespace and a tab space are occur with each other
Take a look if the character at i-1 and i+1 are valid before increasing the counter.
Eranga Thennakoon wrote: int numberOfWords = 1;
BTW... if you are asking about 2 spaces or 2 tabs together... then you should take care on empty buffer, so start in numberOfWords = 0 :P
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
|
|
|
|
|
Nelek wrote: Take a look if the character at i-1 and i+1 are valid before increasing the counter.
Or should I check i and i+1. I'll use it and failed.
Nelek wrote: if you are asking about 2 spaces or 2 tabs together
I've change my code as this.
bool isLastCharBlank = true;
int iWordCount = 0;
char * szTemp = szInputString;
while(*szTemp)
{
if ((*szTemp == ' ') || (*szTemp == '\n'))
{
isLastCharBlank = true;
}
else if (isLastCharBlank)
{
iWordCount++;
isLastCharBlank = false;
}
szTemp++;
}
cout << iWordCount;
Since I've use a pointer to the string I can avoid such instances (I mean 2 spaces, 2 tabs, a tab and a space etc)
But now my question is how to avoid multiple new line characters at the end.
I appreciate your help all the time...
Eranga
|
|
|
|
|
What about:
int count=0;
int len = strlen(pBuffer);
int i =0;
for ( ; ; )
{
while (pBuffer[i]==' ' || pBuffer[i] == '\t' || pBuffer[i] == '\n' && i < len)
{
i++;
}
if (i ==len ) break;
count++;
while (!( pBuffer[i]==' ' || pBuffer[i] == '\t' || pBuffer[i] == '\n') && i < len)
{
i++;
}
if (i == len) break;
}
It is odd, but has a chance to work
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.
|
|
|
|
|
Yes, it's work. But how can I avoid the multiple newline characters at the end.
Say my string is "One Two Three", and I've enter two times the enter key. So the the result is not 3, that is because of the additional new line characters. How can I avoid it. When I take the length it gives the length more than the original length.
I appreciate your help all the time...
Eranga
|
|
|
|
|
Do you mean CR-LF pair? I f the answer is yes, then you have to handle the carriage return '\r' character too, for instance
...
while(pBuffer[i]==' ' || pBuffer[i] == '\t' ||
pBuffer[i] == '\n' || pBuffer[i] == '\r' && i < len)
...
and so on
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.
|
|
|
|
|
Oki, I got your point. But now I'm really confusing, if I've not take the definition in wrong way. That is, carriage return can be occur within a string? My initial code detect only the final newline characters, not within the string.
Can you explain it little more.
I appreciate your help all the time...
Eranga
|
|
|
|
|
Eranga Thennakoon wrote: That is, carriage return can be occur within a string?
In fact, any caratter can.
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.
|
|
|
|
|
That is interesting, and I found that another thing also. When I use your code line that multiple newline at the end avoided.
Ok, say I type a word then any number of spaces, tabs the answer is right. If I add a newline after all those things, the answer is added one more. Only one and it is happened within the string. That mean carriage return can't avoid within the string???? or...??
I appreciate your help all the time...
Eranga
|
|
|
|
|
AS I suggested you can augment my code to intercept and discard carriage returns ('\r' ) as well as any other character.
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.
|
|
|
|
|
Yep, I think so. It is the easiest way to do it. I'll work it out and if I got any issue back to here..
I appreciate your help all the time...
Eranga
|
|
|
|
|
you could use a string tokenizer[^], and then just count the occurences (that mean, is the example above, count the vector size)...
|
|
|
|
|
Ok, I've read that page. But little bit difficult to me, because vectors and stuff in C++ are new topics for me. Anyway thanks for the link again, I'll try it after doing some works with vectors.
I appreciate your help all the time...
Eranga
|
|
|
|
|
Another option would be to use strtok.
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
How can I change the color of GridLines that appears when I use the EXTENDED STYLE for List Control.
m_ListCtrl.SetExtendedStyle(LVS_EX_CHECKBOXES | LVS_EX_GRIDLINES);
With Reagards
Vikas
|
|
|
|