|
Looks like we can only insert strings, so if i want to put in ints or floats, so I have to first atoi, atof them before inserting them? ?
Appreciate your help,
ns
|
|
|
|
|
Correct, but you need itoa or ltoa (ints to strs), not atoi (strs to ints)...
Not sure if there's a ftoa, so you may need to do an sprintf() or something similar...
Chris
"If at any time I announce that a nation or kingdom is to be uprooted, torn down and destroyed, and if that nation I warned repents of its evil, then I will relent and not inflict on it the disaster I had planned. And if at another time I announce that a nation or kingdom is to be built up and planted, and if it does evil in my sight and does not obey me, then I will reconsider the good I had intended to do for it." -- Jeremiah 18:7-10 (God, commenting on the value of the United Nations)
|
|
|
|
|
Hi,
It's possible to find a window by a incomplete name ??
Ex.: Finding a window that has the name "App Test", ::FindWindow ("App Tes?")
Other thing: How find a window by a class name ??
[]'s
Cris.
|
|
|
|
|
Cris wrote:
How find a window by a class name ?
According to MSDN, you should call FindWindow with lpszWindowName set to NULL.
rechi
|
|
|
|
|
But how I get the class name ??
I am using a dialg based app, how I registry the class name ??
|
|
|
|
|
Cris wrote:
how I registry the class name ?
This should be too complicated. Study RegisterClassEx for it.
Cris wrote:
But how I get the class name ??
Use Spy++.
rechi
|
|
|
|
|
You can use ::GetWindow() that will returns the HWND of the window, then you can use ::GetWindowText
Regards
Carlos Antollini.
Sonork ID 100.10529 cantollini
|
|
|
|
|
Can u enumerate all the windows (and child windows if needed) and get the text in the window, and check if u can find ur text in it??
see EnumWindows and strstr or CString::Find
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
But I don't have the complete name. I know that the name begin with "App Name Te...". Can I make anything like this ???
[]'s
|
|
|
|
|
EnumWindows(EnumProc, 0);
and the enum proc:
BOOL CALLBACK EnumProc(HWND hWnd, LPARAM lParam)
{
char szWindowText[256];
memset (szWindowText,0,256);
GetWindowText (hWnd,szWindowText, 255)
if(strstr(szWindowText,"The part u want to find"))
{
// hWnd is ur window
}
return TRUE;
}
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
You need to use the function that enumerate the window like your string...
The Funtion GetWindowText extract the complete name...
If you are asking if exists a function that enum window with title like a specific string, I need to say, I'm Sorry....
The only method is to enum all the window looking for the window that you want...
Regards...
Carlos Antollini.
Sonork ID 100.10529 cantollini
|
|
|
|
|
According to MSDN I am understanding that isDigit will recognise a number, but what if I want to find out that say char* abc = "1234.5678" is a number or not? THen if I'm stepping along the string checking each character, if I hit the decimal point, its not going to like that and it wil say its not a digit> so what can I use to figure out if my text is a double or float?
Appreciate your help,
ns
|
|
|
|
|
You can dig out using GetLocaleInfo, the regional versions of the decimal separator (and the thousands separator). You can then say if it's not a digit, is it one of those?
You might want to check out strtod (wcstod) as well.
Steve S
[This signature space available for rent]
|
|
|
|
|
Why can't you use atof (or the likes)?
If you want to parse the string yourself I'd check each char against a set of allowed characters (0-9, '.', ',') and break if an invalid character is met. You can check for multiple decimal points by setting a flag (a boolean) when the first '.' is met.
Of course, this would be dependent on the users choise of number representations. atof takes care of the locale-stuff for you.
Cheers
Steen.
"To claim that computer games influence children is ridiculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
|
|
|
|
|
simply modify your algorithm a smidge....
for each char in the string
{
if char is '.' then
{
if more than one '.' found
{
// invalid number format
}
else
{
// assumes '.' is decimal marker....other locales can use ','
continue
}
// note.... ',' could be valid too (but only to left of '.')
// note.... other locales will work differently here
}
else
if ( char is not digit )
{
// not a valid number....
}
}
Just trying to keep the forces of entropy at bay
|
|
|
|
|
atof would work, but it returns an ambiguous value of 0 if the text isnt numeric, and 0 if the text is 0....("0") as well. Besides, if its an int I'd have to use atoi and I dont know in advance which type it is. THe biggest problem is the ambiguity of the return value....
Appreciate your help,
ns
|
|
|
|
|
Yeah, I thought of that one too when looking atof i MSDN. Makes the function pretty useless, right?
Anyway, I'd still go for parsing the string myself, looking for digits, points and commas (used for thousand-separators), pluses and minuses. And other characters if you accept scientific representation. As someone suggested, get the characters used for decimal-point and thousand-delimiter from Windows, they can be set by the user individually.
I'd be happy to write you an example, but I'm out of time today.
Cheers
Steen.
"To claim that computer games influence children is ridiculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
|
|
|
|
|
I'm using MyStruct* f() like this:
if (f())
{
} MyStruct is an ordinary structure, containing basic types members.
If i modify the code above this way:
f();
f();
f();
if (f())
{
}
it doesn't crush but in the same place.
The error is about illegaly accessing 0x00000000 .
Do you know what should be wrong here?
rechi
|
|
|
|
|
Realy strange! How does the function f() look like?
Daniel
---------------------------
Never change a running system!
|
|
|
|
|
|
I'll show it but is a bit complicated. I wrote f in order to simplify the stuff. Look:
template<class V, class T>
T* StructFromVector(V *pvect,
string szName)
{
if (!pvect) return FALSE;
for (V::iterator it=pvect->begin();
it!=pvect->end(); it++)
if ((*it)->m_szName==szName)
return *it;
return NULL;
}
where string is the STL one and pvect will be a pointer to an STL vector containing pointers to some structures.
The real call looks like this:
if (!StructFromVector<RIGHTVECTOR2, RightStruct>(&(pUser->
m_vectRights), (char *)bstRight))
{
}
Please help!
If you can...
rechi
|
|
|
|
|
from you "Hungarian" I'd say bstRight is a bstr, can you really cast it to (char*)? And shouldn't you really cast it to a string ?
Cheers
Steen.
"To claim that computer games influence children is ridiculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
|
|
|
|
|
Steen Krogsgaard wrote:
bstRight is a bstr
Actually, is _bstr_t . But you're right, i could have cast it directly to string . Thanx for observation.
Unfortunatelly, it doesn't solve the crush problem...
rechi
|
|
|
|
|
I'm still not sure you can cast a _bstr_t to a string (at least not using an explicit cast), they have totally different binary representations, but then again, I'm no expert on either.
Anyway, how about stepping through your code, especially through the function, and find the offending line? I'm pretty sure it's not in the line calling the function, it must be somewhere within the function.
Cheers
Steen.
"To claim that computer games influence children is ridiculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
|
|
|
|
|
Steen Krogsgaard wrote:
how about stepping through your code
I did it before posting here.
I even stepped through the assembly lines; they look like this:
012DDBCF mov dword ptr [ebp-68h],eax
012DDBD2 cmp dword ptr [ebp-68h],0
012DDBD6 jne CRolesUsers2::UserHasRight+1C3h (012ddc53)
33: {
34: for (it=pUser->m_vectRoles.begin(); it!=pUser->m_vectRoles.
012DDBD8 mov ecx,dword ptr [ebp-1Ch]
It fails on jne when - very intersting! - tries to jump to 012DDBD8 and not to 012ddc53 .
rechi
|
|
|
|