|
in the name of allah
hello
i want to find all the files name in a directory and then delete all the files that are copies :
a.txt a(copy).txt: a(copy).txt must be deleted.
how i can find the name of files with c++ commands and how i can delete them .
also my os is linux if it is relative to os.i dont know that if i write in a correct thread?
valhamdolelah.
|
|
|
|
|
You can use SHFileOperation[^] with the FO_DELETE function and specifying a wild card like *(copy).* .
Is it enough that you determine that the file is a copy with the filename?
I could create a new file with the name a(copy).txt even though it would be a rare occurrence.
|
|
|
|
|
I am new with MFC and I have an dialog interface contains an button, input box(edit control), and output box(edit control or list control).
Mainly my problem is when I entered something in the input box(edit control) its remain there and I need after entering to delete the entered text or remove it (clear the input box)
And the second problem which i need help also is I used for the output box in the first time edit control and the output texts overrided the previous output text and I need to keep the both in the output box window because its like a chatting output window keep the both utterances the entered text and the output text.
And when I used the List control for the output box its works like list function there is an ordering happened for output texts.
I need the output texts appears like for example an real chatting via an MSN :
He says: hello there
You says:hello
and how I can make an automatic numbering for the output texts
2 :he says: i am fine.
2: you says : how are you?
1: he says: hello there
1: you says : hello
please anyone could help me and it will be appreciated.
Best Regards,
|
|
|
|
|
Since you're using MFC, you can associate a variable to the control.
Right click on the control in the dialog editor and select Add Variable .
Associate a CString variable with the edit boxes.
You do not need a variable for the button.
For your output text you can use a multi-line edit box.
For this you right click on the edit box and select properties.
Set the Multiline property to true .
Associate a CString variable with this edit box.
For automatic numbering keep a counter of type DWORD that you can increment.
In the button click handler to the following.
UpdateData();
outputCString.AppendFormat(_T("%u: %s\r\n", ++counter, inputCString);
inputCString = _T("");
UpdateData(FALSE);
|
|
|
|
|
Thank you for your help.
regarding the multiline its work when the output text its longer than one line,isn't it? thats what I noticed when I implemented it and I used the list control with no sorting property and work fine and the other works fine thank you very much again.
Regards,
|
|
|
|
|
moh.hijjawi wrote: ...I need after entering to delete the entered text or remove it (clear the input box)
Assuming you are using a CEdit control variable:
m_edit.SetWindowText("");
moh.hijjawi wrote: And when I used the List control for the output box its works like list function there is an ordering happened for output texts.
Sounds like its sorting.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
thank you for your help.
its works fine
|
|
|
|
|
You Can Use : GetDlgItem(Write Here "ID" For That Control You Want To Change Text )->SetWindowsText("");
|
|
|
|
|
abo_alise wrote: You Can Use : GetDlgItem...
I know that you can, but the issue is that you shouldn't.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
|
See here.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Can someone give me a link to implementing various control within a dialog dynamically. I need at times to replace existing controls in a dialog, with different controls depending on User selections.
A C++ programming language novice, but striving to learn
|
|
|
|
|
CreateWindow [^] function is the key to your success.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
You can either place all the controls that you will ever be using in the dialog template and hide/show them as required or use the CreateWindow[^] API with the predefined class names as described in the remarks section.
|
|
|
|
|
I understand what you are saying, I think. Ex. one useage requires a large listbox while another selection would require a large editbox. You are saying that while the dialog is displayed? I can change what is presented? Or must I close the dialog after the User made a selection and then reload it with the proper controls in place according to the User's previous selections?
A C++ programming language novice, but striving to learn
|
|
|
|
|
Yes, you can change what is displayed on the dialog without closing and reopening.
For example -
The following will hide the list box and show the edit box.
GetDlgItem(IDC_LIST1)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_EDIT1)->ShowWindow(SW_SHOW);
|
|
|
|
|
Thank you so much for your help. This really sovles my situation.
A C++ programming language novice, but striving to learn
|
|
|
|
|
I find the best way to handle this is to create all of the controls you'll need and then just enable/disable them at runtime.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Thanks again for the information.
A C++ programming language novice, but striving to learn
|
|
|
|
|
how can I use the code of c++ in a function (like checksum) as a string in the same project ?
in another way :
I want to apply a function on the cpp file as a text one to calculate its text value
|
|
|
|
|
your question is not clear.
I'm not even certain _you_ understand what you wan to achieve ?
- you want to copy/paste the code from one function to another one ?
- you want to have a textual representation of a function and call it ? (ie. a bit like an interpreter does ?)
- apply what ? to what ?
- you want to have a text representation of the output of a function like "checksum"? (ie. print the result?)
- ...
This signature was proudly tested on animals.
|
|
|
|
|
when I try to "restart system" or "turn off system" , I get error message "Socket Notification Sink" Dialog box.
And it didn't work reboot or turn off..
How can I avoid "Socket Notification Sink" error?
My main brief code as followings.
<br />
<br />
<br />
UINT _ThreadDoSomethingInfinite(LPVOID pParam)<br />
{<br />
<br />
char buf[100];<br />
CSocket h_sock;<br />
CMyDlg *p=(CMyDlg*)pParam;<br />
h_sock.Create( nPort , SOCK_DGRAM);<br />
while(1)<br />
{<br />
<br />
Sleep(5000); <br />
. <br />
.<br />
stcpy(buf, "some data..buffering..");<br />
<br />
h_sock.SendTo( buf , 1234 , "127.0.0.1" ); <br />
}<br />
<br />
h_sock.ShutDown(2);<br />
h_sock.Close();<br />
}<br />
<br />
<br />
CWinThread g_updsock;<br />
BOOL CMyDlg::OnInitDialog()<br />
<br />
g_updsock=AfxBeginThread(_ThreadSendAgentStatus,this,THREAD_PRIORITY_NORMAL);<br />
if(g_updsock==NULL) return;<br />
<br />
}<br />
<br />
|
|
|
|
|
Hi, I suggest to exit the endless loop when the application is signaled to terminate or an error occured. Add basic error handling to the socket methods, e.g. Create and SendTo return a status. Alternatively use a different socket class than MFC's CSocket or use plain sockets (Winsock).
/M
|
|
|
|
|
Can anyone help me how to convert a DAT file to a BMP file?I have created a DAT file.Now while converting it to a BMP file, how can i insert the bmp header?
|
|
|
|
|
What is in that DAT file? I presume it is an image, do you know the width, height and color depth?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|