Solved

Handle cut & paste in a dialog window

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
windows 10 how make picture as desktop background 2 72
sumNumber challenge 16 145
Detect file exist or not 3 215
Can not remove SSL certificate on iPhone 6 - iOS10.2 12 1,653
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.

734 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