Solved

Add text to CEdit

Posted on 2004-10-28
180 Views
Last Modified: 2013-11-20
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.








 
0
Question by:the_hood00
    23 Comments
     
    LVL 13

    Expert Comment

    by:SteH
    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.
    0
     
    LVL 13

    Expert Comment

    by:SteH
    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.
    0
     
    LVL 43

    Expert Comment

    by:AndyAinscow
    SetDlgItemText(IDC_MYEDIT, "some text");

    Thats all you require.  No headers etc.
    0
     

    Author Comment

    by:the_hood00
    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
    0
     
    LVL 43

    Expert Comment

    by:AndyAinscow
    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.
    0
     

    Author Comment

    by:the_hood00
    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
    0
     
    LVL 13

    Expert Comment

    by:SteH
    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.
    0
     

    Author Comment

    by:the_hood00
    this is my last question: how do i put the copied file in a folder on the current users desktop
    0
     

    Author Comment

    by:the_hood00
    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
    0
     
    LVL 43

    Expert Comment

    by:AndyAinscow
    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);


    0
     

    Author Comment

    by:the_hood00
    is there a tag or something that would allow me to make a directory on the curremt users desktop
    0
     
    LVL 43

    Expert Comment

    by:AndyAinscow
    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.

    0
     
    LVL 43

    Expert Comment

    by:AndyAinscow
    Sorry wrong thread.
    0
     
    LVL 43

    Expert Comment

    by:AndyAinscow
    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) ;



    0
     

    Author Comment

    by:the_hood00
    cant figure it out i cant get the link to work either
    0
     

    Author Comment

    by:the_hood00
    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
    0
     
    LVL 43

    Expert Comment

    by:AndyAinscow
    yes.
    0
     

    Author Comment

    by:the_hood00
    do you know it ill give you 80 points 40 now and 40 when it works
    0
     
    LVL 43

    Expert Comment

    by:AndyAinscow
    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.
    0
     
    LVL 43

    Accepted Solution

    by:
         //remove all .asc files in the target directory
          {
                TCHAR szTrgt[MAX_PATH];
                ::ZeroMemory(szTrgt, sizeof(szTrgt));

                _tcscpy(szTrgt, szPath);
                _tcscat(szTrgt, _T("\\*.asc"));

                SHFILEOPSTRUCT fileOp;
                fileOp.hwnd = GetSafeHwnd();
                fileOp.wFunc = FO_DELETE;
                fileOp.pFrom = szTrgt;
                fileOp.pTo = _T("");
                fileOp .fFlags = FOF_NOCONFIRMATION | FOF_SILENT  | FOF_NOERRORUI;
                fileOp.hNameMappings = NULL;
                fileOp.lpszProgressTitle = NULL;

                SHFileOperation(&fileOp);
          }
    0
     
    LVL 13

    Expert Comment

    by:SteH
    unsubscribing
    0
     

    Author Comment

    by:the_hood00
    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.

    0
     

    Author Comment

    by:the_hood00
    i think i got it thankyou for your assistance you will get all 290 points
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone. Privacy Policy Terms of Use

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Suggested Solutions

    Title # Comments Views Activity
    Motorola device cold boot 3 301
    Generic progress indicator 6 103
    List out all word 7 158
    tripleUp challenge 7 45
    Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
    Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
    This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
    Want to pick and choose which updates you receive? Feel free to check out this quick video on how to manage your email notifications.

    875 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now