Solved

Handle cut & paste in a dialog window

Posted on 1999-01-01
2
187 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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

757 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

20 Experts available now in Live!

Get 1:1 Help Now