|
Hi,
I have a Dialog based application. Dialog is having CDateTimeCtrl as well as some other controls. I put the tab order for all controls so as to navigate through keyboard tab.
When I clicked on CDateTimeCtrl drop down arrow it shows me Month calendar, when I do selection of other date or cancels on calendar control, focus gets disappear (OnSetFocus() function gets called but the selection gets disappears that makes feel like the focus is not on the control) . Now if I press tab the focus goes to next subsequent control and when come back to the same CDateTimeCtrl control through tab, it doesn't get selected. (Here also the OnSetFocus() function gets called but the control doesn’t get highlighted it appears like deselected )
Can anybody of you tell me, how can I select the Date inside the CDateTimeCtrl?
I tried to handle CDateTimeCtrl's OnKillFocus() OnCloseup(), OnSetfocus() etc. but the highlighting of date is not possible. Is there any function available by which date (day/month/year) can be highlight?
Thanks in advance,
- Vijay
God is Great
|
|
|
|
|
dear all,
i want to use CreateProcessAsUser function along with LogonUser func in my mfc dialog based app.
should i close the token after ceating process or will it be closed automatically when process ends.
what is the ideal scenario?
|
|
|
|
|
If you acquire a resource, you should also release it. The target process knows nothing about resources in your process.
|
|
|
|
|
|
If you use std::string, then you can write your own functor and use std::find. Hell, you can write a functor and use std::find with a char *, a pointer is a random access iterator.
Christian
No offense, but I don't really want to encourage the creation of another VB developer.
- Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael
P Butler 05-12-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not
as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
|
Because it's good advice ?
Christian
No offense, but I don't really want to encourage the creation of another VB developer.
- Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael
P Butler 05-12-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not
as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
i've always had to write my own. luckily, you can just grab the source for MS's own strstr and tweak it. (strstr itself is like 20 lines of C)
-c
I'm not the droid you're looking for.
|
|
|
|
|
|
Nishant S wrote:
Is there a case in-sensitive version of the CRT function strstr?
Unfortunately not, I always wondered why there is no strstri() or stristr() same like stricmp()
Possibly a good idea for a simple article. The aim is to have an optimised stristr().
Regards,
Victor
phpWebNotes is a page annotation system modelled after php.net.
http://webnotes.sourceforge.net/demo.php[^]
|
|
|
|
|
I guess that would be a Boyer-Moore[^] implementation
using a character test something like:
const int uc='a'-'A';
bool bMatch=c==d || c+uc==d && c>='A' && c<='Z' || c==d+uc && d>='A' && d<='Z';
|
|
|
|
|
|
|
Something I wrote a loooong time ago...
#ifdef UNICODE
#define _tcsustr wcsustr
#else
#define _tcsustr strustr
#endif
char* strustr(char *source, char *s);
wchar_t* wcsustr(wchar_t *source, wchar_t *s);
char* strustr(char *source, char *s)
{
char *csource = strdup(source);
char *cs = strdup(s);
strupr(csource);
strupr(cs);
char *result = strstr(csource, cs);
if (result != NULL)
{
int pos = result - csource;
result = source;
result += pos;
}
free(csource);
free(cs);
return result;
}
wchar_t* wcsustr(wchar_t *source, wchar_t *s)
{
wchar_t *csource = wcsdup(source);
wchar_t *cs = wcsdup(s);
wcsupr(csource);
wcsupr(cs);
wchar_t *result = wcsstr(csource, cs);
if (result != NULL)
{
int pos = result - csource;
result = source;
result += pos;
}
free(csource);
free(cs);
return result;
}
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
Here's mine (ANSI only) :-
char * stristr (const char * string , const char * strCharSet )
{
char *pstart = (char *) string ;
char *s1, *s2;
if ( !*strCharSet )
return((char *)string );
while (*pstart)
{
s1 = pstart;
s2 = (char *) strCharSet ;
char c1, c2;
while ( *s1 && *s2 )
{
c1 = *s1;
c2 = *s2;
if( __isascii(c1) && isupper(c1) )
c1 = islower(c1);
if( __isascii(c2) && isupper(c2) )
c2 = islower(c2);
if(c1 - c2)
break;
s1++;
s2++;
}
if (!*s2)
return(pstart);
pstart++;
}
return(NULL);
}
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Review by Shog9
Click here for review[NW]
|
|
|
|
|
Nishant S wrote:
s2 = (char *) strCharSet ;
Why all that casting?
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
strstr returns a non-const pointer. Sooner or later he has to cast.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
|
c1 = *s1;
c2 = *s2;
if( __isascii(c1) && isupper(c1) )
c1 = islower(c1);
if( __isascii(c2) && isupper(c2) )
c2 = islower(c2);
That won't work as is. You should have tolower and not islower. Also, the other tests are redundant.
c1 = tolower (*s1);
c2 = tolower (*s2);
The docs in MSDN aren't totally correct. They say to use isascii and isupper, but that is only true for _tolower, not tolower. However, if you want to keep that code in there, then you can switch to using _tolower which is just a blind macro to add the proper value to convert the case.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
|
Converting both characters to lower case is wasteful though.
You can get better performance using a test like so:
const int uc='a'-'A';
bool bMatch=c==d || c+uc==d && c>='A' && c<='Z' || c==d+uc && d>='A' && d<='Z';
This usually short-circuits to three comparisons in the majority case of no match. Where this code is located, every bit counts..
|
|
|
|
|
Cute...
stricmp uses some assembler tricks to do the following:
if (c1 != c2)
{
c1 = tolower (c1);
c2 = tolower (c2);
}
With the assebler tricks, it can avoid all the "jumps" associated with short cicuiting.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
yeah, there's something to be said for going back to
assembly at really crucial places. Just so long as it
is easy little jobs, it shouldn't make the whole too
unreadable.
|
|
|
|
|
Check my new post, the assembler version was slower than a stricmp version using your code.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Very interesting...
I just made a stricmp with your clause and compared it to MS's __ascii_stricmp and your version won by around 25-30%.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|