Solved

Handle cut & paste in a dialog window

Posted on 1999-01-01
2
191 Views
Last Modified: 2013-12-26
how should I handle cut & paste in a dialog windows edit text controls?

void do_edit_cmds(short the_item)
{
 
  switch( the_item )
  {
     case editUNDO:
        if(SystemEdit( the_item - 1) )
         ;
        break;
     case editCUT:
        if(SystemEdit( the_item - 1) )
        ;//SysBeep(10);
        break;
     case editCOPY:
        if(SystemEdit( the_item - 1) )
        ;
        break;
    case editPASTE:
       if(SystemEdit( the_item - 1) )
       ;
       break;
    case editCLEAR:
       if(SystemEdit( the_item - 1) )
       ;
       break;
    case editSELECT_ALL:
       if(SystemEdit( the_item - 1) )
       ;
       break;
    case editPREFERENCE:
       Handle_Preferences();
       break;    
 }
}
0
Comment
Question by:gailp
2 Comments
 
LVL 3

Accepted Solution

by:
boonstra earned 50 total points
ID: 1291689
You want to use the routines DialogCut, DialogCopy, and DialogPaste, each of which takes a single parameter, a pointer to the dialog you want to cut/copy/paste from.

Without seeing more of your event loop, it is difficult to provide specific code.  Assuming you are talking about a modeless dialog, if you know that your dialog is the frontmost window when you enter do_edit_cmds, you can simply:

WindowPtr wind;

wind = FrontWindow();
switch (the_item) {
  case editCut:
    DialogCut(wind);
    break;
  case editCopy:
    DialogCopy(wind);
    break;
  case editPaste:
    DialogPaste(wind);
    break;
}

You do not need to provide the item being edited, as the DialogManager already knows that and does the right thing.

If it is possible that some other window is frontmost when you call do_edit_cmds, then you'll want to use something like:

  case editCut:
    if (IsMyDialogWindow(wind)) DialogCut(wind);
    break;

where IsMyDialogWindow is code you provide to determine whether wind is one of your dialogs.
0
 

Author Comment

by:gailp
ID: 1291690
This answer worked for me.

Thank You for your help.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Process filename extension 3 172
Define unique primary key 9 89
Smart Camera scanning and reading information 3 100
only14 challenge 19 68
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 …
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

910 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

21 Experts available now in Live!

Get 1:1 Help Now