[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Add text to CEdit

Posted on 2004-10-28
23
Medium Priority
?
194 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
Comment
Question by:the_hood00
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 10
  • 9
  • 4
23 Comments
 
LVL 13

Expert Comment

by:SteH
ID: 12434438
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
ID: 12434464
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 45

Expert Comment

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

Thats all you require.  No headers etc.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:the_hood00
ID: 12510225
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 45

Expert Comment

by:AndyAinscow
ID: 12512678
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
ID: 12524760
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
ID: 12524782
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
ID: 12527167
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
ID: 12527333
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 45

Expert Comment

by:AndyAinscow
ID: 12527426
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
ID: 12527764
is there a tag or something that would allow me to make a directory on the curremt users desktop
0
 
LVL 45

Expert Comment

by:AndyAinscow
ID: 12530601
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 45

Expert Comment

by:AndyAinscow
ID: 12530603
Sorry wrong thread.
0
 
LVL 45

Expert Comment

by:AndyAinscow
ID: 12530634
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
ID: 12549990
cant figure it out i cant get the link to work either
0
 

Author Comment

by:the_hood00
ID: 12551208
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 45

Expert Comment

by:AndyAinscow
ID: 12552520
yes.
0
 

Author Comment

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

Expert Comment

by:AndyAinscow
ID: 12555397
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 45

Accepted Solution

by:
AndyAinscow earned 1160 total points
ID: 12555413
     //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
ID: 12555696
unsubscribing
0
 

Author Comment

by:the_hood00
ID: 12556228
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
ID: 12556369
i think i got it thankyou for your assistance you will get all 290 points
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
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.
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

650 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