Link to home
Start Free TrialLog in
Avatar of the_hood00
the_hood00

asked on

Add text to CEdit

how do i load a string of text to an edit box

give all necessary #includes and where they go and send source code only no links.








 
Avatar of Member_2_1001466
Member_2_1001466

CString csTmp; // assign a value to csTmp as you like
CEdit m_Edit1;
m_Edit1.SetWindowText (csTmp); // this sets the value.

If you create a SDI/MDI/dialog base application using the wizard you don't need to add any includes. They are added to stdafx.h automatically. Otherwise the includes depends on other parts you use. Try to copy and paste from a wizard base application.
The CEdit control can be easily cretaed using the class wizard. Go to the "Member variable" tab and select to create a variable of type "control" for the corresponding control ID.
Avatar of AndyAinscow
SetDlgItemText(IDC_MYEDIT, "some text");

Thats all you require.  No headers etc.
Avatar of the_hood00

ASKER

How do i copy a folder of .txt documents and subfolders quickly

if you want more points ill will add them upon request

send no links code only
You really ought to create a new question but

SHFileOperation
Copies, moves, renames, or deletes a file system object

SHFILEOPSTRUCT
Contains information that the SHFileOperation function uses to perform file operations.



typedef struct _SHFILEOPSTRUCT{
    HWND hwnd;
    UINT wFunc;
    LPCTSTR pFrom;
    LPCTSTR pTo;
    FILEOP_FLAGS fFlags;
    BOOL fAnyOperationsAborted;
    LPVOID hNameMappings;
    LPCTSTR lpszProgressTitle;
} SHFILEOPSTRUCT, *LPSHFILEOPSTRUCT;
 
Members
hwnd
Window handle to the dialog box to display information about the status of the file operation.
wFunc
Value that indicates which operation to perform. This member can be one of the following values:
FO_COPY
Copy the files specified in the pFrom member to the location specified in the pTo member.
also can i use SetDlgItemText(IDC_MYEDIT, "some text");
for a static text box as well if not what can i use to do that
Yes you can. It works for all CWnd derived controls which have a sensible text variable. Else the function will modify the title of the control.
this is my last question: how do i put the copied file in a folder on the current users desktop
also i cant figure out how to use

typedef struct _SHFILEOPSTRUCT{
    HWND hwnd;
    UINT wFunc;
    LPCTSTR pFrom;
    LPCTSTR pTo;
    FILEOP_FLAGS fFlags;
    BOOL fAnyOperationsAborted;
    LPVOID hNameMappings;
    LPCTSTR lpszProgressTitle;
} SHFILEOPSTRUCT, *LPSHFILEOPSTRUCT;
 
could you enlighten me a little
something like

     SHFILEOPSTRUCT sFileOp;
     ZeroMemory(&sFileOp, sizeof(SHFILEOPSTRUCT));

     sFileOp.wFunc = FO_COPY;
     sFileOp.pFrom = pszFrom;  <-------- source
     sFileOp.pTo = pszTo;          <-------- target
     sFileOp.fFlags = FOF_SILENT|FOF_NOCONFIRMATION|FOF_NOERRORUI;

     SHFileOperation(&sFileOp);


is there a tag or something that would allow me to make a directory on the curremt users desktop
Excerpt from help
CWnd::GetDlgItem  
CWnd* GetDlgItem( int nID ) const;

void CWnd::GetDlgItem( int nID, HWND* phWnd ) const;

Return Value

A pointer to the given control or child window. If no control with the integer ID given by the nID parameter exists, the value is NULL.

The returned pointer may be temporary and should not be stored for later use.     ***************************


You MUST NOT store the returned hwnd in the OnInitDialog.  You need to use that code to get it each time you intend to use it.

Sorry wrong thread.
This is a Basic code sample

http://support.microsoft.com/download/support/mslfiles/sfolder.exe


I have also found this snippet

 #include  <windows.h>
#include  <shlobj.h>

int  MyGetSpecialFolderPath (int nFolder, LPSTR lpszPath)
{
LPITEMIDLIST  pidl ;

if (SHGetSpecialFolderLocation(NULL,nFolder,&pidl) != NOERROR)
  return 0 ;

return SHGetPathFromIDList(pidl,lpszPath) ;
}


to find desktop try
char  szDesktopPath[MAX_PATH] ;
int iRet = MyGetSpecialFolderPath(CSIDL_DESKTOP,szDesktopPath) ;



cant figure it out i cant get the link to work either
is there a diffrent way to delete a folder of files and subdirectories other then with SHFileOperation() and the string of the path to the folder has variables in it
do you know it ill give you 80 points 40 now and 40 when it works
The alternative is to recursively move down the directory tree, deleting files as you go, when you come up a level the directory has been cleaned so you then delete that.
It's much simpler with SHFileOperation.
ASKER CERTIFIED SOLUTION
Avatar of AndyAinscow
AndyAinscow
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
unsubscribing
i cant get the code to work it still gives me the same error but i am not trying to copy anymore i got a different way for that but this time i want to delete a folder this is the path of the folder to delete

CString csfile=("c:\\Program Files\\Geoffism Studios\\np\\"+csMsg);

when the user pushes a button the folder is deleted

if you write the code for me with SHFileOperation. ill give you all 290 and if you want more i will change it to your desired amount and do i need to add any #inlcudes for SHFileOperation.

i think i got it thankyou for your assistance you will get all 290 points