|
Hi Guys,
Is there any way to change the tab orders for a controls programmatically.
|
|
|
|
|
SetWindowPos
Use wndTop for the first control, and the previous window for the remaining.
"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
|
|
|
|
|
I think you could try this:
1- Destroy all the controls you want to set the tab-order of.
2- Create them again in the order in which you would like the tab-order.
this is this.
|
|
|
|
|
NO!!!!!!!!!!!!!!!!
Use SetWindowPos to change the Z-Order - TAB order int he dialog merely follows the controls' Z-Order.
People that start writing code immediately are programmers (or hackers), people that ask questions first are Software Engineers - Graham Shanks
|
|
|
|
|
You have probably tested this technique, and I haven't tested my ideas, so I guess you are right.
Thanks for the correction.
this is this.
|
|
|
|
|
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?
|
|
|
|