|
Hi WhiteSky,
below is the function which i have used can u please what the error in it
<br />
void CSearchDlg::OnDblclkSout() <br />
{<br />
<br />
int d;<br />
d=m_SOUT.GetCurSel();<br />
CString FName;<br />
m_SOUT.GetText(d,FName); <br />
<br />
<br />
char str[100];<br />
int i,l,k,j,m;<br />
strcpy(str, FName);<br />
<br />
for (i=0;str[i]!='\0';i++)<br />
<br />
{<br />
<br />
if (str[i]=='\\')<br />
<br />
{<br />
<br />
l=i; k=0;<br />
char str1[100];<br />
if (str[l+1]=='\0')<br />
{<br />
str[l]='/';<br />
}<br />
else<br />
{<br />
for (j=l+1;str[j]!='\0';j++)<br />
{<br />
str1[k]=str[j];<br />
k++;<br />
<br />
}<br />
str1[k]='\0';<br />
str[l]='/';<br />
for (m=0;str1[m]!='\0';m++)<br />
{<br />
<br />
str[++l]=str1[m];<br />
<br />
}<br />
<br />
}<br />
<br />
str[++l]='\0';<br />
i=i++;<br />
<br />
}<br />
<br />
}<br />
m_ctrlEDIT.SetWindowText(str);<br />
<br />
ShellExecute(NULL, "open", str ,NULL, NULL, SW_SHOWNORMAL); <br />
<br />
<br />
}<br />
<br />
|
|
|
|
|
I can't follow code without formatting. Click the ignore HTML tags checkbox when you enter a message so we can see the formatting. Also give the types of all variables referred to. e.g. The type of the "m_SOUT" variable.
Steve
|
|
|
|
|
Hi Stephen Hewitt,
In list box i have items like
C:\folder\folder\filename1.txt
C:\folder\folder\filename2.txt
C:\folder\folder\filename3.txt
C:\folder\folder\filename4.txt
since by default i get the file name as c:\folder\folder\file.txt
i have char array to change it to c:/folder/folder/file.txt
final value of str will have C:/Folder/Folder/filename.txt
below code i have used to open
void CSearchDlg::OnDblclkSout()
{
// Code to open the selected file.
int d;
d=m_SOUT.GetCurSel();
CString FName;
m_SOUT.GetText(d,FName);
char str[100];
int i,l,k,j,m;
strcpy(str, FName);
for (i=0;str[i]!='\0';i++)
{
if (str[i]=='\\')
{
l=i; k=0;
char str1[100];
if (str[l+1]=='\0')
{
str[l]='/';
}
else
{
for (j=l+1;str[j]!='\0';j++)
{
str1[k]=str[j];
k++;
}
str1[k]='\0';
str[l]='/';
for (m=0;str1[m]!='\0';m++)
{
str[++l]=str1[m];
}
}
str[++l]='\0';
i=i++;
}
}
m_ctrlEDIT.SetWindowText(str);
ShellExecute(NULL, "open", str ,NULL, NULL, SW_SHOWNORMAL);
}
|
|
|
|
|
your code now open one text file
<br />
void CssDlg::OnBnClickedMybutton()<br />
{<br />
<br />
int d;<br />
CString FName;<br />
FName="c:\\code.txt";<br />
<br />
<br />
char str[100];<br />
int i,l,k,j,m;<br />
strcpy(str, FName);<br />
<br />
for (i=0;str[i]!='\0';i++)<br />
<br />
{<br />
<br />
if (str[i]=='\\')<br />
<br />
{<br />
<br />
l=i; k=0;<br />
char str1[100];<br />
if (str[l+1]=='\0')<br />
{<br />
str[l]='/';<br />
}<br />
else<br />
{<br />
for (j=l+1;str[j]!='\0';j++)<br />
{<br />
str1[k]=str[j];<br />
k++;<br />
<br />
}<br />
str1[k]='\0';<br />
str[l]='/';<br />
for (m=0;str1[m]!='\0';m++)<br />
{<br />
<br />
str[++l]=str1[m];<br />
<br />
}<br />
<br />
}<br />
<br />
str[++l]='\0';<br />
i=i++;<br />
<br />
}<br />
}<br />
m_Edit1.SetWindowText(str);
<br />
ShellExecute(NULL, "open", str ,NULL, NULL, SW_SHOWNORMAL); <br />
}<br />
whitesky
|
|
|
|
|
Hi WhiteSky,
The code will open only 1 file by default, how can we do it dynamically ??is there any solution for this problem..please let me know...
|
|
|
|
|
yes this code open only one file(text) because i dont know that you how to get files and paths, this code work for one file so maybe your path is wrong your files
whitesky
|
|
|
|
|
Hi WhiteSky,
ShellExecute(NULL, "open", str ,NULL, NULL, SW_SHOWNORMAL);
here i am passing str is of char str[100]; is this can be problem ???
have to change char array to CString ??? if i convert it will work ??
can u please tell me how to change char array to CString ..
char str[100];
CString Name;
|
|
|
|
|
I write your code and it work. I am not understanding your question what do you need you said this code will open only one file but i need to run dynamically for another files now you said is this problem(str[100])
if this code will work so you need to trace your code
can you explain exactly:
1-you can use ShellExecute or no
2-you need to change char array to CString or no if yes why
3-your code has problem or no
4-how to get files and paths
5-can you use from debugger(F9 and F5)for show str value
6-whats the meaning of change array to cstring
7-in your code you use from one loop why
whitesky
|
|
|
|
|
Hi WhiteSky,
The exact problem is in the list box i have list of file names with there complete path.
file names are added by other function which is adding correctly
ex
C:\Box01\00000304\00000034.txt
C:\Box01\00000304\00000035.txt
C:\Box01\00000304\00000036.txt
C:\Box01\00000304\00000037.txt
etc...
since i am using ShellExecute as it takes only file name like
C:/Box01/00000304/00000037.txt
i have used char array & changed the \ to /
i am using this stament just as a check point to find what data str has
m_ctrlEDIT.SetWindowText(str);
in the str i get the data as C:\Box01\00000304\00000037.txt
i also ued F5 and cheked str has proper data..
but still the file is not opening ...please tell me waht will be possible cause..
|
|
|
|
|
C:\Box01\00000304\00000034.txt it seems not problem
of course if is valid and i think if you use like this it work you can use CString instead char[100] and if these paths and files are valid so i think you can use ShellExecute that it should open notepad (I guess I'm not sure maybe your string concat to previous string for example you have c:\\1.txt then you want to open another file then c:\\1.txtc:\\2.txt Did you check for this case)
whitesky
|
|
|
|
|
Hi WhiteSky,
Thank you very much for the help.
got the solution, the problem was some junk character was getting added to the file name,so it was not able to open file,i just altered the file name removed the last junk character str[i-1]='\0';now the file open properly...
Since its in the list box user keep on cliking on items and open any number of files but i want only 1 file to be open at a time..
when the user clicks on the item i want the open file to closed(txt files) and slected file to be opened is there any way to close and then open a file ??
please let know if there any way
|
|
|
|
|
Hope I understood your question
you want to close notepad or anything that open your file
use FindWindow
...
...
ShellExecute(NULL, "open", str ,NULL, NULL, SW_SHOWNORMAL);
MessageBox("A");
HWND hWnd = ::FindWindow("Notepad", NULL);
::SendMessage(hWnd,WM_CLOSE,0,0);
whitesky
|
|
|
|
|
Hi WhiteSky,
Thank you very much ....U are simply great in VC++
Regards,
Vinay Charan.
|
|
|
|
|
if possibe can u tell me what are HWND hwnd ??? is it an handler ??
|
|
|
|
|
yes handle to window
whitesky
|
|
|
|
|
Hi !!!
Your sample:
------------
ShellExecute(NULL, "open", "str" ,NULL, NULL, SW_SHOWNORMAL);
My sample:
----------
ShellExecute(NULL, "open", str ,NULL, NULL, SW_SHOWNORMAL);
You cannot give it into the quotes.
I hope, I helped you.
By.
-:KNOX:-
|
|
|
|
|
Some condition:
1. in sync mode, just for simplification
2. TCP/IP stream mode
Peer A:
send 5 bytes
send another 5 bytes
wait until all the data is received at the buffer of Peer B, then Peer B:
case 1:
recv 20 bytes
Will Peer B get 5 or 10 bytes?
case 2:
recv 2 bytes
Will Peer B get the first 2 bytes of the first 5 byte?
If yes, what is going on by recving 2 bytes a time until all data is recved?
-- modified at 3:49 Tuesday 23rd May, 2006
|
|
|
|
|
followait wrote: For example in sync mode, just for simplification.
Peer A:
send 5 bytes
send another 5 bytes
wait until all the data is received at the buffer of Peer B, then Peer B:
case 1:
recv 20 bytes
Will Peer B get 5 or 10 bytes?
case 2:
recv 2 bytes
Will Peer B get the first 2 bytes of the first 5 byte?
If yes, what is going on by recving 2 bytes a time until all data is recved?
This is may due to the network traffic.
generally people uses the loop until you get whole data and after that process that data.
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
Suppose that all the data is received at the buffer of Peer B, just waiting for achiving. In this case, there is no network traffic problem, isn't it?
|
|
|
|
|
followait wrote: Suppose that all the data is received at the buffer of Peer B, just waiting for achiving. In this case, there is no network traffic problem, isn't it?
The network traffic is depends on max. bandwidth your network support and type of your connections (Dialup or Broadband).
You receive all the data, no matter but we can't sure that you can get all the data at a time.
So, As per my knowledge whatever you receive in case of PEER B: 2 bytes of 5 Bytes are 'first' 2 bytes of 5 bytes.
hope i understood your problem.
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
In case 1, peer B can get anything between 1 to 10 bytes. In case 2, B gets first 1 or 2 bytes. In either case, B must loop until all data is received.
|
|
|
|
|
|
Please sujjest me the related code or info regarding progress bar in SDK.
Thanks in advance..
Ashok.
|
|
|
|
|
Which SDK ? What kind of application are you doing exactly ? Is it pure win32 or with the MFC ?
Anyway, you can simply add a progress bar to your dialog resource and then how you use depends of the type of application.
Cédric Moonen
Software developer
Charting control
|
|
|
|
|
It is pure win32 application.please reply.....
Thanks in advance,
Ashok.
|
|
|
|
|