I'm trying to use input from a text edit box to delete a file. The input from the textbox will be the file location and the delete button will use DeleteFile() to delete the file.

[img]http://img436.imageshack.us/img436/5578/deleteboxvn0.png[/img]

Do you know what I mean?

Recommended Answers

All 10 Replies

Yes. We understand what you mean. But where do you have the problem?

Yes. We understand what you mean. But where do you have the problem?

I want to use the text that was put in the textbox(the file location) to be used in the DeleteFile function.

DeleteFile(FileName)

In FileName I want the text that the user input to be used. Just like I would use cin.

Use GetWindowText to copy the text in the edit box, and call DeleteFile for that text.

Thanks a lot man.

"The GetWindowText function copies the text of the specified window's title bar"

Thats not what I want.

If you read further it says that if it is a control it copies the text of the control.

If you read further it says that if it is a control it copies the text of the control.

You're right. lol. I over read. Sorry.

Okay, Im still confused. Can anyone else help?

Okay then. Try sending the EM_GETLINE Message. That surely ought to work.

Quan Chi2: Okay, Im still confused. Can anyone else help?

How about this :

     len = GetWindowTextLength(GetDlgItem(yourwindowhwnd, yourtextboxtID));
     if(len > 0)
     {
         int i;
         char* buf;
         buf = (char*)GlobalAlloc(GPTR, len + 1);
         GetDlgItemText(yourwindowhwnd, yourtextboxID, buf, len + 1);

         string filename = buf;
         GlobalFree((HANDLE)buf);
     }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.