|
Yes, it works well. When you create a control on the fly, you can also use SetWindowPos to 'insert' it into a specific tab order.
You method will work, it is just overkill.
People that start writing code immediately are programmers (or hackers), people that ask questions first are Software Engineers - Graham Shanks
|
|
|
|
|
Yes, I also tested my idea yesterday, and it works. But as you said, it is just overkill. SetWindowPos() is much easier and simpler.
this is this.
|
|
|
|
|
Hi,
I want to compare two character arrays containing binary values.
For e.g. if m_Effects array contains 0001, string comparison does not return 0 even if binEffects contains binary equivalent of 1. Even if I do byte by byte comparison same problem occurs.
What does _ltoa exactly perform?
//---------------------------------------------------------------------
for(int i=0; i <16; i++)
{
_ltoa(i, binEffects, 2);
if(strcmp((char *)binEffects, (char *)m_Effects) == 0)
return i;
}
//---------------------------------------------------------------------
Thanks,
Kranti
|
|
|
|
|
u can directly use strcmp/memcmp to comapre two integer array
nave
|
|
|
|
|
when I check the values stored in both of the arrays, something like the following is observed ...
binEffects[3] = '0'
binEffects[2] = '0'
binEffects[1] = ''
binEffects[0] = '1'
and the source array contains ...
m_Effects[0] = '0'
m_Effects[1] = '0'
m_Effects[2] = '0'
m_Effects[3] = '1'
Even if i use memcmp(), it returns -1 if this example is concerned.
Hence, i've a doubt regarding _ltoa function since it sets the values in binEffects.
Kranti
|
|
|
|
|
Did you read my post ?
That is a standard behaviour. If you want to convert an integer (let's say 3) in binary string, you won't have the zeros in front of the number, that sounds logical isn't ?
So, when you convert 3 into a binary string, it's logical that you get '11' and not '0011' (how can the compiler knows that you want 2 zeros at the begining of the string). The same when you convert 1 into a string, you will get '1'.
|
|
|
|
|
I think you want to convert a binary string into its value ? Right ?
Maybe you can write a simple function to do that:
int BoolStringToVal(char* szString)<br />
{<br />
int Value = 0;<br />
for (int Index=strlen(szString)-1; Index>=0; Index--)<br />
{<br />
int BinValue = 1 << (Index - strlen(szString) + 1 );<br />
if (szString[Index])<br />
Value += BinValue ;<br />
}<br />
<br />
return Value;<br />
}
So, what it does is look for each char in the string and if this char is 1 then we add its corresponding value to the total value. The code has not been tested so I'm not sure if this will work, but you got the principle.
|
|
|
|
|
It would be better and faster to use the reverse function of _ltoa -> strtol. And now your code looks like that:
char* e;<br />
int iEffects = strtol((const char *)m_Effects,&e,2);<br />
for(int i=0; i <16; i++)<br />
{<br />
if(i==iEffects)<br />
return i;<br />
}
|
|
|
|
|
hey,
it worked!
Thanks a lot!
Kranti
|
|
|
|
|
How do I delete a file so that it goes to recycle bin, the following code doesnt seem to work?
<br />
static void delete_file()<br />
{<br />
SHFILEOPSTRUCT shf;<br />
int ret = 0;<br />
shf.wFunc = FO_DELETE;<br />
shf.pFrom = filename;<br />
shf.fFlags = FOF_ALLOWUNDO;<br />
<br />
<br />
if(0 != (ret = SHFileOperation(&shf)) {<br />
printf("could'nt delete \"%s\" to recycle bin (err=%d/%ld)\n", filename, ret, GetLastError());<br />
}<br />
}<br />
<br />
thanks!
|
|
|
|
|
pFrom must be double terminated.
pTo must be set to NULL if not used.
Paul DiLascia has a good article on using the Recycle Bin from
MSDN April 2001.
"My dog worries about the economy. Alpo is up to 99 cents a can. That's almost seven dollars in dog money" - Wacky humour found in a business magazine
|
|
|
|
|
This works.
char file[MAXPATH];<br />
int ok;<br />
int l;<br />
strncopy(file,filetodelete,sizeof(file));<br />
shfop.hwnd = GetDesktopWindow();<br />
shfop.wFunc = FO_DELETE;<br />
shfop.pFrom = file; l = strlen(shfop.pFrom);<br />
if((l+2)<sizeof(file)) file[l] = file[l+1] = 0;<br />
shfop.pTo = shfop.pFrom;<br />
shfop.fFlags = FOF_ALLOWUNDO|FOF_SILENT|FOF_NOERRORUI;<br />
shfop.fAnyOperationsAborted = 0;<br />
shfop.hNameMappings = 0;<br />
shfop.lpszProgressTitle = shfop.pFrom;<br />
<br />
ok = SHFileOperation(&shfop);<br />
ok = (ok==0) && !shfop.fAnyOperationsAborted;
|
|
|
|
|
Hi All,
Can anyone tell me how to programmatically search for a file in a specific directory?
Thanks and Regards,
Anil
|
|
|
|
|
i mean just to find out if the file exists or not...
|
|
|
|
|
|
|
The most simple version.
WIN32_FIND_DATA fd;<br />
HANDLE hf = FindFirstFile(fullfilename,&fd);<br />
if(hf==INVALID_HANDLE_VALUE) return 0;<br />
FindClose(hf);<br />
return (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY);
|
|
|
|
|
|
Sorry i forgot the neg (!) at the return line.
|
|
|
|
|
Hello,
Actually, am getting data from the machine as 0x03 0x10 0x82 0x10..... and length of the buffer is varying, as Length:108 or 256 or....so how to proceed further to parse the data and store the data in an array. do we have any Active X control for parsing the data?
|
|
|
|
|
srija wrote: do we have any Active X control for parsing the data?
how an activeX could help you there ???
well, you reposted your question, but you don't really say much once again.
srija wrote: am getting data from the machine as 0x03 0x10 0x82 0x10
this doesn't mean anything (or it could mean everything) depending on haw you want to interpret those bytes...
that's why i asked you the format of the datas supposed to be received...
please precise the type on how you receive those data, how you want to change them, tell also if there are some important thing to read from the stream...
help us or we won't be able to help you !!
TOXCCT >>> GEII power [toxcct][VisualCalc 2.24][3.0 soon...]
|
|
|
|
|
I would like to have the data in (Radius, Angle) i,e in polar coordinates, thats all the data what i could read from machine, i dont even have the header information also.
I think, you got my problem...
|
|
|
|
|
I would like to have the data in (Radius, Angle) i,e in polar coordinates, thats all the data what i could read from machine, i dont even have the header information also.
I think, you got my problem...
shirin
|
|
|
|
|
Use CArray for storing the data
nave
|
|
|
|
|
I hope to understand you right. The aim is to convert a variable length block of input data with hexadecimal numbers into an array to integers. If it' true try this:
<br />
void ParseBlock(const char* lp)<br />
{<br />
CArray<int,int> a;<br />
unsigned int i,n;<br />
int result;<br />
for(i=0;lp[i];i+=n)<br />
{<br />
if(!(n=ParseOneValue(lp+i,result)) break;<br />
a.Add( result );<br />
}<br />
}<br />
<br />
unsigned int ParseOneValue(const char* lp,int& result)<br />
{<br />
unsigned int i;<br />
char* e;<br />
while(lp[i] && !isdigit(lp[i])) ++i;
if(!lp[i]) return 0;<br />
if((lp[i]!='0')||(lp[i]!='x'))
{<br />
result = strtol(lp+i,&e,10);<br />
return e-lp;<br />
}<br />
i += 2;<br />
result = strtol(lp+i,&e,16);<br />
return e-lp;<br />
}
sorry the html won't take the tabs.
|
|
|
|