home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / addins / replall / replacedlg.cpp < prev    next >
C/C++ Source or Header  |  1998-04-02  |  19KB  |  835 lines

  1. // ReplaceDlg.cpp : implementation file
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "ReplAll.h"
  6. #include "ReplaceDlg.h"
  7.  
  8. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #undef THIS_FILE
  11. static char THIS_FILE[] = __FILE__;
  12. #endif
  13.  
  14. /////////////////////////////////////////////////////////////////////////////
  15. // CReplaceDlg dialog
  16.  
  17.  
  18. CReplaceDlg::CReplaceDlg(CWnd* pParent /*=NULL*/)
  19.     : CDialog(CReplaceDlg::IDD, pParent)
  20. {
  21.     //{{AFX_DATA_INIT(CReplaceDlg)
  22.     //}}AFX_DATA_INIT
  23. }
  24.  
  25.  
  26. void CReplaceDlg::DoDataExchange(CDataExchange* pDX)
  27. {
  28.     CDialog::DoDataExchange(pDX);
  29.     //{{AFX_DATA_MAP(CReplaceDlg)
  30.     DDX_Control(pDX, IDC_REPLTEXT, m_ReplaceText);
  31.     DDX_Control(pDX, IDC_FINDTEXT, m_FindText);
  32.     DDX_Control(pDX, IDC_WHOLEWORD, m_MatchWholeWord);
  33.     DDX_Control(pDX, IDC_REGEXP, m_RegularExpression);
  34.     DDX_Control(pDX, IDC_MATCHCASE, m_MatchCase);
  35.     //}}AFX_DATA_MAP
  36. }
  37.  
  38.  
  39. BEGIN_MESSAGE_MAP(CReplaceDlg, CDialog)
  40.     //{{AFX_MSG_MAP(CReplaceDlg)
  41.     ON_BN_CLICKED(IDC_REGEXPFIND, OnRegexpfind)
  42.     ON_BN_CLICKED(IDC_REGEXPREPLACE, OnRegExpReplace)
  43.     ON_COMMAND(ID_OPTIONS_QUOTEDSTRING, CommandQuotedString)
  44.     ON_COMMAND(ID_OPTIONS_ANYCHARACTER, CommandAnyChar)
  45.     ON_COMMAND(ID_OPTIONS_CHARACTERINRANGE, CommandInRange)
  46.     ON_COMMAND(ID_OPTIONS_CHARACTERNOTINRANGE, CommandNotInRange)
  47.     ON_COMMAND(ID_OPTIONS_BEGINNINGOFLINE, CommandBeginOL)
  48.     ON_COMMAND(ID_OPTIONS_ENDOFLINE, CommandEOL)
  49.     ON_COMMAND(ID_OPTIONS_TAGGEDEXPRESSION, CommandTaggedExp)
  50.     ON_COMMAND(ID_OPTIONS_NOT, CommandNot)
  51.     ON_COMMAND(ID_OPTIONS_OR, CommandOr)
  52.     ON_COMMAND(ID_OPTIONS_0ORMOREMATCHES, Command0OrMore)
  53.     ON_COMMAND(ID_OPTIONS_1ORMOREMATCHES, Command1OrMore)
  54.     ON_COMMAND(ID_OPTIONS_GROUP, CommandGroup)
  55.     ON_COMMAND(ID_OPTIONS_WHITESPACE, CommandWhitespace)
  56.     ON_COMMAND(ID_OPTIONS_ALPHANUMERICCHARACTER, CommandAlphaNumericCharacter)
  57.     ON_COMMAND(ID_OPTIONS_ALPHABETICCHARACTER, CommandAlphaCharacter)
  58.     ON_COMMAND(ID_OPTIONS_DECIMALDIGIT, CommandDecDigit)
  59.     ON_COMMAND(ID_OPTIONS_HEXADECIMALNUMBER, CommandHexNumber)
  60.     ON_COMMAND(ID_OPTIONS_NUMBER, CommandNumber)
  61.     ON_COMMAND(ID_OPTIONS_INTEGER, CommandInteger)
  62.     ON_COMMAND(ID_OPTIONS_CCIDENTIFIER, CommandCIdentifier)
  63.     ON_COMMAND(ID_OPTIONS_ALPHABETICSTRING, CommandAlphabeticString)
  64.     ON_COMMAND(ID_OPTIONS2_FINDWHATTEXT, CommandFindWhatText)
  65.     ON_COMMAND(ID_OPTIONS2_TAGGEDEXPRESSION1, CommandTaggedExpression1)
  66.     ON_COMMAND(ID_OPTIONS2_TAGGEDEXPRESSION2, CommandTaggedExpression2)
  67.     ON_COMMAND(ID_OPTIONS2_TAGGEDEXPRESSION3, CommandTaggedExpression3)
  68.     ON_COMMAND(ID_OPTIONS2_TAGGEDEXPRESSION4, CommandTaggedExpression4)
  69.     ON_COMMAND(ID_OPTIONS2_TAGGEDEXPRESSION5, CommandTaggedExpression5)
  70.     ON_COMMAND(ID_OPTIONS2_TAGGEDEXPRESSION6, CommandTaggedExpression6)
  71.     ON_COMMAND(ID_OPTIONS2_TAGGEDEXPRESSION7, CommandTaggedExpression7)
  72.     ON_COMMAND(ID_OPTIONS2_TAGGEDEXPRESSION8, CommandTaggedExpression8)
  73.     ON_COMMAND(ID_OPTIONS2_TAGGEDEXPRESSION9, CommandTaggedExpression9)
  74.     //}}AFX_MSG_MAP
  75. END_MESSAGE_MAP()
  76.  
  77. void CReplaceDlg::CommandAnyChar(WPARAM, LPARAM)
  78. {
  79.     switch (m_lEmulation)
  80.     {
  81.         case dsDevStudio:
  82.             m_FindText.ReplaceSel(_T("."));
  83.             break;
  84.         case dsVC2:
  85.             m_FindText.ReplaceSel(_T("."));
  86.             break;
  87.         case dsBrief:
  88.             m_FindText.ReplaceSel(_T("?"));
  89.             break;
  90.         case dsEpsilon:
  91.             m_FindText.ReplaceSel(_T("."));
  92.             break;
  93.         case dsCustom:
  94.             m_FindText.ReplaceSel(_T("."));
  95.             break;
  96.     }
  97.     m_RegularExpression.SetCheck(1);
  98. }
  99.  
  100. void CReplaceDlg::CommandInRange(WPARAM, LPARAM)
  101. {
  102.     switch (m_lEmulation)
  103.     {
  104.         case dsDevStudio:
  105.             m_FindText.ReplaceSel(_T("[]"));
  106.             break;
  107.         case dsVC2:
  108.             m_FindText.ReplaceSel(_T("[]"));
  109.             break;
  110.         case dsBrief:
  111.             m_FindText.ReplaceSel(_T("[]"));
  112.             break;
  113.         case dsEpsilon:
  114.             m_FindText.ReplaceSel(_T("[]"));
  115.             break;
  116.         case dsCustom:
  117.             m_FindText.ReplaceSel(_T("[]"));
  118.             break;
  119.     }
  120.     m_RegularExpression.SetCheck(1);
  121. }
  122.  
  123. void CReplaceDlg::CommandNotInRange(WPARAM, LPARAM)
  124. {
  125.     switch (m_lEmulation)
  126.     {
  127.         case dsDevStudio:
  128.             m_FindText.ReplaceSel(_T("[^]"));
  129.             break;
  130.         case dsVC2:
  131.             m_FindText.ReplaceSel(_T("[^]"));
  132.             break;
  133.         case dsBrief:
  134.             m_FindText.ReplaceSel(_T("[~]"));
  135.             break;
  136.         case dsEpsilon:
  137.             m_FindText.ReplaceSel(_T("[^]"));
  138.             break;
  139.         case dsCustom:
  140.             m_FindText.ReplaceSel(_T("[^]"));
  141.             break;
  142.     }
  143.     m_RegularExpression.SetCheck(1);
  144. }
  145.  
  146. void CReplaceDlg::CommandBeginOL(WPARAM, LPARAM)
  147. {
  148.     switch (m_lEmulation)
  149.     {
  150.         case dsDevStudio:
  151.             m_FindText.ReplaceSel(_T("^"));
  152.             break;
  153.         case dsVC2:
  154.             m_FindText.ReplaceSel(_T("^"));
  155.             break;
  156.         case dsBrief:
  157.             m_FindText.ReplaceSel(_T("%"));
  158.             break;
  159.         case dsEpsilon:
  160.             m_FindText.ReplaceSel(_T("^"));
  161.             break;
  162.         case dsCustom:
  163.             m_FindText.ReplaceSel(_T("^"));
  164.             break;
  165.     }
  166.     m_RegularExpression.SetCheck(1);
  167. }
  168.  
  169. void CReplaceDlg::CommandEOL(WPARAM, LPARAM)
  170. {
  171.     switch (m_lEmulation)
  172.     {
  173.         case dsDevStudio:
  174.             m_FindText.ReplaceSel(_T("$"));
  175.             break;
  176.         case dsVC2:
  177.             m_FindText.ReplaceSel(_T("$"));
  178.             break;
  179.         case dsBrief:
  180.             m_FindText.ReplaceSel(_T("$"));
  181.             break;
  182.         case dsEpsilon:
  183.             m_FindText.ReplaceSel(_T("$"));
  184.             break;
  185.         case dsCustom:
  186.             m_FindText.ReplaceSel(_T("$"));
  187.             break;
  188.     }
  189.     m_RegularExpression.SetCheck(1);
  190. }
  191.  
  192. void CReplaceDlg::CommandTaggedExp(WPARAM, LPARAM)
  193. {
  194.     switch (m_lEmulation)
  195.     {
  196.         case dsDevStudio:
  197.             m_FindText.ReplaceSel(_T("\\(\\)"));
  198.             break;
  199.         case dsVC2:
  200.             m_FindText.ReplaceSel(_T("\\(\\)"));
  201.             break;
  202.         case dsBrief:
  203.             m_FindText.ReplaceSel(_T("{}"));
  204.             break;
  205.         case dsEpsilon:
  206.             m_FindText.ReplaceSel(_T("()"));
  207.             break;
  208.         case dsCustom:
  209.             m_FindText.ReplaceSel(_T("\\(\\)"));
  210.             break;
  211.     }
  212.     m_RegularExpression.SetCheck(1);
  213. }
  214.  
  215. void CReplaceDlg::CommandNot(WPARAM, LPARAM)
  216. {
  217.     switch (m_lEmulation)
  218.     {
  219.         case dsDevStudio:
  220.             m_FindText.ReplaceSel(_T("\\~"));
  221.             break;
  222.         case dsVC2:
  223.             m_FindText.ReplaceSel(_T("\\~"));
  224.             break;
  225.         case dsBrief:
  226.             m_FindText.ReplaceSel(_T("~"));
  227.             break;
  228.         case dsEpsilon:
  229.             m_FindText.ReplaceSel(_T("~"));
  230.             break;
  231.         case dsCustom:
  232.             m_FindText.ReplaceSel(_T("\\~"));
  233.             break;
  234.     }
  235.     m_RegularExpression.SetCheck(1);
  236. }
  237.  
  238. void CReplaceDlg::CommandOr(WPARAM, LPARAM)
  239. {
  240.     switch (m_lEmulation)
  241.     {
  242.         case dsDevStudio:
  243.             m_FindText.ReplaceSel(_T("\\!"));
  244.             break;
  245.         case dsVC2:
  246.             m_FindText.ReplaceSel(_T("\\!"));
  247.             break;
  248.         case dsBrief:
  249.             m_FindText.ReplaceSel(_T("|"));
  250.             break;
  251.         case dsEpsilon:
  252.             m_FindText.ReplaceSel(_T("|"));
  253.             break;
  254.         case dsCustom:
  255.             m_FindText.ReplaceSel(_T("\\!"));
  256.             break;
  257.     }
  258.     m_RegularExpression.SetCheck(1);
  259. }
  260.  
  261. void CReplaceDlg::Command0OrMore(WPARAM, LPARAM)
  262. {
  263.     switch (m_lEmulation)
  264.     {
  265.         case dsDevStudio:
  266.             m_FindText.ReplaceSel(_T("*"));
  267.             break;
  268.         case dsVC2:
  269.             m_FindText.ReplaceSel(_T("*"));
  270.             break;
  271.         case dsBrief:
  272.             m_FindText.ReplaceSel(_T("@"));
  273.             break;
  274.         case dsEpsilon:
  275.             m_FindText.ReplaceSel(_T("*"));
  276.             break;
  277.         case dsCustom:
  278.             m_FindText.ReplaceSel(_T("*"));
  279.             break;
  280.     }
  281.     m_RegularExpression.SetCheck(1);
  282. }
  283.  
  284. void CReplaceDlg::Command1OrMore(WPARAM, LPARAM)
  285. {
  286.     switch (m_lEmulation)
  287.     {
  288.         case dsDevStudio:
  289.             m_FindText.ReplaceSel(_T("+"));
  290.             break;
  291.         case dsVC2:
  292.             m_FindText.ReplaceSel(_T("+"));
  293.             break;
  294.         case dsBrief:
  295.             m_FindText.ReplaceSel(_T("+"));
  296.             break;
  297.         case dsEpsilon:
  298.             m_FindText.ReplaceSel(_T("+"));
  299.             break;
  300.         case dsCustom:
  301.             m_FindText.ReplaceSel(_T("+"));
  302.             break;
  303.     }
  304.     m_RegularExpression.SetCheck(1);
  305. }
  306.  
  307. void CReplaceDlg::CommandGroup(WPARAM, LPARAM)
  308. {
  309.     switch (m_lEmulation)
  310.     {
  311.         case dsDevStudio:
  312.             m_FindText.ReplaceSel(_T("\\{\\}"));
  313.             break;
  314.         case dsVC2:
  315.             m_FindText.ReplaceSel(_T("\\{\\}"));
  316.             break;
  317.         case dsBrief:
  318.             m_FindText.ReplaceSel(_T("{}"));
  319.             break;
  320.         case dsEpsilon:
  321.             m_FindText.ReplaceSel(_T("()"));
  322.             break;
  323.         case dsCustom:
  324.             m_FindText.ReplaceSel(_T("\\{\\}"));
  325.             break;
  326.     }
  327.     m_RegularExpression.SetCheck(1);
  328. }
  329.  
  330. void CReplaceDlg::CommandWhitespace(WPARAM, LPARAM)
  331. {
  332.     switch (m_lEmulation)
  333.     {
  334.         case dsDevStudio:
  335.             m_FindText.ReplaceSel(_T("\\:b+"));
  336.             break;
  337.         case dsVC2:
  338.             m_FindText.ReplaceSel(_T("\\:b+"));
  339.             break;
  340.         case dsBrief:
  341.             m_FindText.ReplaceSel(_T("[ \x09]+"));
  342.             break;
  343.         case dsEpsilon:
  344.             m_FindText.ReplaceSel(_T("[ <tab>]+"));
  345.             break;
  346.         case dsCustom:
  347.             m_FindText.ReplaceSel(_T("\\b:+"));
  348.             break;
  349.     }
  350.     m_RegularExpression.SetCheck(1);
  351. }
  352.  
  353. void CReplaceDlg::CommandAlphaNumericCharacter(WPARAM, LPARAM)
  354. {
  355.     switch (m_lEmulation)
  356.     {
  357.         case dsDevStudio:
  358.             m_FindText.ReplaceSel(_T("\\:a"));
  359.             break;
  360.         case dsVC2:
  361.             m_FindText.ReplaceSel(_T("\\:a"));
  362.             break;
  363.         case dsBrief:
  364.             m_FindText.ReplaceSel(_T("[a-zA-Z0-9]"));
  365.             break;
  366.         case dsEpsilon:
  367.             m_FindText.ReplaceSel(_T("[a-zA-Z0-9]"));
  368.             break;
  369.         case dsCustom:
  370.             m_FindText.ReplaceSel(_T("\\:a"));
  371.             break;
  372.     }
  373.     m_RegularExpression.SetCheck(1);
  374. }
  375.  
  376. void CReplaceDlg::CommandAlphaCharacter(WPARAM, LPARAM)
  377. {
  378.     switch (m_lEmulation)
  379.     {
  380.         case dsDevStudio:
  381.             m_FindText.ReplaceSel(_T("\\:c"));
  382.             break;
  383.         case dsVC2:
  384.             m_FindText.ReplaceSel(_T("\\:c"));
  385.             break;
  386.         case dsBrief:
  387.             m_FindText.ReplaceSel(_T("[a-zA-Z]"));
  388.             break;
  389.         case dsEpsilon:
  390.             m_FindText.ReplaceSel(_T("[a-zA-Z]"));
  391.             break;
  392.         case dsCustom:
  393.             m_FindText.ReplaceSel(_T("\\:c"));
  394.             break;
  395.     }
  396.     m_RegularExpression.SetCheck(1);
  397. }
  398.  
  399. void CReplaceDlg::CommandDecDigit(WPARAM, LPARAM)
  400. {
  401.     switch (m_lEmulation)
  402.     {
  403.         case dsDevStudio:
  404.             m_FindText.ReplaceSel(_T("\\:d"));
  405.             break;
  406.         case dsVC2:
  407.             m_FindText.ReplaceSel(_T("\\:d"));
  408.             break;
  409.         case dsBrief:
  410.             m_FindText.ReplaceSel(_T("[0-9]"));
  411.             break;
  412.         case dsEpsilon:
  413.             m_FindText.ReplaceSel(_T("[0-9]"));
  414.             break;
  415.         case dsCustom:
  416.             m_FindText.ReplaceSel(_T("\\:d"));
  417.             break;
  418.     }
  419.     m_RegularExpression.SetCheck(1);
  420. }
  421.  
  422. void CReplaceDlg::CommandHexNumber(WPARAM, LPARAM)
  423. {
  424.     switch (m_lEmulation)
  425.     {
  426.         case dsDevStudio:
  427.             m_FindText.ReplaceSel(_T("\\:h"));
  428.             break;
  429.         case dsVC2:
  430.             m_FindText.ReplaceSel(_T("\\:h"));
  431.             break;
  432.         case dsBrief:
  433.             m_FindText.ReplaceSel(_T("[0-9a-fA-F]+"));
  434.             break;
  435.         case dsEpsilon:
  436.             m_FindText.ReplaceSel(_T("[0-9a-fA-F]+"));
  437.             break;
  438.         case dsCustom:
  439.             m_FindText.ReplaceSel(_T("\\:h"));
  440.             break;
  441.     }
  442.     m_RegularExpression.SetCheck(1);
  443. }
  444.  
  445. void CReplaceDlg::CommandNumber(WPARAM, LPARAM)
  446. {
  447.     switch (m_lEmulation)
  448.     {
  449.         case dsDevStudio:
  450.             m_FindText.ReplaceSel(_T("\\:n"));
  451.             break;
  452.         case dsVC2:
  453.             m_FindText.ReplaceSel(_T("\\:n"));
  454.             break;
  455.         case dsBrief:
  456.             m_FindText.ReplaceSel(
  457.                     _T("{[0-9]+.[0-9]@}|{[0-9]@.[0-9]+}|{[0-9]+}"));
  458.             break;
  459.         case dsEpsilon:
  460.             m_FindText.ReplaceSel(_T("([0-9]+.[0-9]*|[0-9]*.[0-9]+|[0-9]+)"));
  461.             break;
  462.         case dsCustom:
  463.             m_FindText.ReplaceSel(_T("\\:n"));
  464.             break;
  465.     }
  466.     m_RegularExpression.SetCheck(1);
  467. }
  468.  
  469. void CReplaceDlg::CommandInteger(WPARAM, LPARAM)
  470. {
  471.     switch (m_lEmulation)
  472.     {
  473.         case dsDevStudio:
  474.             m_FindText.ReplaceSel(_T("\\:z"));
  475.             break;
  476.         case dsVC2:
  477.             m_FindText.ReplaceSel(_T("\\:z"));
  478.             break;
  479.         case dsBrief:
  480.             m_FindText.ReplaceSel(_T("[0-9]+"));
  481.             break;
  482.         case dsEpsilon:
  483.             m_FindText.ReplaceSel(_T("[0-9]+"));
  484.             break;
  485.         case dsCustom:
  486.             m_FindText.ReplaceSel(_T("\\:z"));
  487.             break;
  488.     }
  489.     m_RegularExpression.SetCheck(1);
  490. }
  491.  
  492. void CReplaceDlg::CommandCIdentifier(WPARAM, LPARAM)
  493. {
  494.     switch (m_lEmulation)
  495.     {
  496.         case dsDevStudio:
  497.             m_FindText.ReplaceSel(_T("\\:i"));
  498.             break;
  499.         case dsVC2:
  500.             m_FindText.ReplaceSel(_T("\\:i"));
  501.             break;
  502.         case dsBrief:
  503.             m_FindText.ReplaceSel(_T("[a-zA-Z_$][a-zA-Z0-9_$]@"));
  504.             break;
  505.         case dsEpsilon:
  506.             m_FindText.ReplaceSel(_T("[a-zA-Z_$][a-zA-Z0-9_$]*"));
  507.             break;
  508.         case dsCustom:
  509.             m_FindText.ReplaceSel(_T("\\:i"));
  510.             break;
  511.     }
  512.     m_RegularExpression.SetCheck(1);
  513. }
  514.  
  515. void CReplaceDlg::CommandAlphabeticString(WPARAM, LPARAM)
  516. {
  517.     switch (m_lEmulation)
  518.     {
  519.         case dsDevStudio:
  520.             m_FindText.ReplaceSel(_T("\\:w"));
  521.             break;
  522.         case dsVC2:
  523.             m_FindText.ReplaceSel(_T("\\:w"));
  524.             break;
  525.         case dsBrief:
  526.             m_FindText.ReplaceSel(_T("[a-zA-Z]+"));
  527.             break;
  528.         case dsEpsilon:
  529.             m_FindText.ReplaceSel(_T("[a-zA-Z]+"));
  530.             break;
  531.         case dsCustom:
  532.             m_FindText.ReplaceSel(_T("\\:w"));
  533.             break;
  534.     }
  535.     m_RegularExpression.SetCheck(1);
  536. }
  537.  
  538. void CReplaceDlg::CommandQuotedString(WPARAM, LPARAM)
  539. {
  540.     switch (m_lEmulation)
  541.     {
  542.         case dsDevStudio:
  543.             m_FindText.ReplaceSel(_T("\\:q"));
  544.             break;
  545.         case dsVC2:
  546.             m_FindText.ReplaceSel(_T("\\:q"));
  547.             break;
  548.         case dsBrief:
  549.             m_FindText.ReplaceSel(_T("\"[~\"]@\""));
  550.             break;
  551.         case dsEpsilon:
  552.             m_FindText.ReplaceSel(_T("\"[~\"]*\""));
  553.             break;
  554.         case dsCustom:
  555.             m_FindText.ReplaceSel(_T("\\:q"));
  556.             break;
  557.     }
  558.     m_RegularExpression.SetCheck(1);
  559. }
  560.  
  561. void CReplaceDlg::CommandFindWhatText(WPARAM, LPARAM)
  562. {
  563.     switch (m_lEmulation)
  564.     {
  565.         case dsDevStudio:
  566.             m_ReplaceText.ReplaceSel(_T("\\0"));
  567.             break;
  568.         case dsVC2:
  569.             m_ReplaceText.ReplaceSel(_T("\\0"));
  570.             break;
  571.         case dsBrief:
  572.             m_ReplaceText.ReplaceSel(_T("\\0"));
  573.             break;
  574.         case dsEpsilon:
  575.             m_ReplaceText.ReplaceSel(_T("\\0"));
  576.             break;
  577.         case dsCustom:
  578.             m_ReplaceText.ReplaceSel(_T("\\0"));
  579.             break;
  580.     }
  581.     m_RegularExpression.SetCheck(1);
  582. }
  583. void CReplaceDlg::CommandTaggedExpression1(WPARAM, LPARAM)
  584. {
  585.     switch (m_lEmulation)
  586.     {
  587.         case dsDevStudio:
  588.             m_ReplaceText.ReplaceSel(_T("\\1"));
  589.             break;
  590.         case dsVC2:
  591.             m_ReplaceText.ReplaceSel(_T("\\1"));
  592.             break;
  593.         case dsBrief:
  594.             m_ReplaceText.ReplaceSel(_T("\\1"));
  595.             break;
  596.         case dsEpsilon:
  597.             m_ReplaceText.ReplaceSel(_T("\\1"));
  598.             break;
  599.         case dsCustom:
  600.             m_ReplaceText.ReplaceSel(_T("\\1"));
  601.             break;
  602.     }
  603.     m_RegularExpression.SetCheck(1);
  604. }
  605. void CReplaceDlg::CommandTaggedExpression2(WPARAM, LPARAM)
  606. {
  607.     switch (m_lEmulation)
  608.     {
  609.         case dsDevStudio:
  610.             m_ReplaceText.ReplaceSel(_T("\\2"));
  611.             break;
  612.         case dsVC2:
  613.             m_ReplaceText.ReplaceSel(_T("\\2"));
  614.             break;
  615.         case dsBrief:
  616.             m_ReplaceText.ReplaceSel(_T("\\2"));
  617.             break;
  618.         case dsEpsilon:
  619.             m_ReplaceText.ReplaceSel(_T("\\2"));
  620.             break;
  621.         case dsCustom:
  622.             m_ReplaceText.ReplaceSel(_T("\\2"));
  623.             break;
  624.     }
  625.     m_RegularExpression.SetCheck(1);
  626. }
  627. void CReplaceDlg::CommandTaggedExpression3(WPARAM, LPARAM)
  628. {
  629.     switch (m_lEmulation)
  630.     {
  631.         case dsDevStudio:
  632.             m_ReplaceText.ReplaceSel(_T("\\3"));
  633.             break;
  634.         case dsVC2:
  635.             m_ReplaceText.ReplaceSel(_T("\\3"));
  636.             break;
  637.         case dsBrief:
  638.             m_ReplaceText.ReplaceSel(_T("\\3"));
  639.             break;
  640.         case dsEpsilon:
  641.             m_ReplaceText.ReplaceSel(_T("\\3"));
  642.             break;
  643.         case dsCustom:
  644.             m_ReplaceText.ReplaceSel(_T("\\3"));
  645.             break;
  646.     }
  647.     m_RegularExpression.SetCheck(1);
  648. }
  649. void CReplaceDlg::CommandTaggedExpression4(WPARAM, LPARAM)
  650. {
  651.     switch (m_lEmulation)
  652.     {
  653.         case dsDevStudio:
  654.             m_ReplaceText.ReplaceSel(_T("\\4"));
  655.             break;
  656.         case dsVC2:
  657.             m_ReplaceText.ReplaceSel(_T("\\4"));
  658.             break;
  659.         case dsBrief:
  660.             m_ReplaceText.ReplaceSel(_T("\\4"));
  661.             break;
  662.         case dsEpsilon:
  663.             m_ReplaceText.ReplaceSel(_T("\\4"));
  664.             break;
  665.         case dsCustom:
  666.             m_ReplaceText.ReplaceSel(_T("\\4"));
  667.             break;
  668.     }
  669.     m_RegularExpression.SetCheck(1);
  670. }
  671. void CReplaceDlg::CommandTaggedExpression5(WPARAM, LPARAM)
  672. {
  673.     switch (m_lEmulation)
  674.     {
  675.         case dsDevStudio:
  676.             m_ReplaceText.ReplaceSel(_T("\\5"));
  677.             break;
  678.         case dsVC2:
  679.             m_ReplaceText.ReplaceSel(_T("\\5"));
  680.             break;
  681.         case dsBrief:
  682.             m_ReplaceText.ReplaceSel(_T("\\5"));
  683.             break;
  684.         case dsEpsilon:
  685.             m_ReplaceText.ReplaceSel(_T("\\5"));
  686.             break;
  687.         case dsCustom:
  688.             m_ReplaceText.ReplaceSel(_T("\\5"));
  689.             break;
  690.     }
  691.     m_RegularExpression.SetCheck(1);
  692. }
  693. void CReplaceDlg::CommandTaggedExpression6(WPARAM, LPARAM)
  694. {
  695.     switch (m_lEmulation)
  696.     {
  697.         case dsDevStudio:
  698.             m_ReplaceText.ReplaceSel(_T("\\6"));
  699.             break;
  700.         case dsVC2:
  701.             m_ReplaceText.ReplaceSel(_T("\\6"));
  702.             break;
  703.         case dsBrief:
  704.             m_ReplaceText.ReplaceSel(_T("\\6"));
  705.             break;
  706.         case dsEpsilon:
  707.             m_ReplaceText.ReplaceSel(_T("\\6"));
  708.             break;
  709.         case dsCustom:
  710.             m_ReplaceText.ReplaceSel(_T("\\6"));
  711.             break;
  712.     }
  713.     m_RegularExpression.SetCheck(1);
  714. }
  715. void CReplaceDlg::CommandTaggedExpression7(WPARAM, LPARAM)
  716. {
  717.     switch (m_lEmulation)
  718.     {
  719.         case dsDevStudio:
  720.             m_ReplaceText.ReplaceSel(_T("\\7"));
  721.             break;
  722.         case dsVC2:
  723.             m_ReplaceText.ReplaceSel(_T("\\7"));
  724.             break;
  725.         case dsBrief:
  726.             m_ReplaceText.ReplaceSel(_T("\\7"));
  727.             break;
  728.         case dsEpsilon:
  729.             m_ReplaceText.ReplaceSel(_T("\\7"));
  730.             break;
  731.         case dsCustom:
  732.             m_ReplaceText.ReplaceSel(_T("\\7"));
  733.             break;
  734.     }
  735.     m_RegularExpression.SetCheck(1);
  736. }
  737. void CReplaceDlg::CommandTaggedExpression8(WPARAM, LPARAM)
  738. {
  739.     switch (m_lEmulation)
  740.     {
  741.         case dsDevStudio:
  742.             m_ReplaceText.ReplaceSel(_T("\\8"));
  743.             break;
  744.         case dsVC2:
  745.             m_ReplaceText.ReplaceSel(_T("\\8"));
  746.             break;
  747.         case dsBrief:
  748.             m_ReplaceText.ReplaceSel(_T("\\8"));
  749.             break;
  750.         case dsEpsilon:
  751.             m_ReplaceText.ReplaceSel(_T("\\8"));
  752.             break;
  753.         case dsCustom:
  754.             m_ReplaceText.ReplaceSel(_T("\\8"));
  755.             break;
  756.     }
  757.     m_RegularExpression.SetCheck(1);
  758. }
  759. void CReplaceDlg::CommandTaggedExpression9(WPARAM, LPARAM)
  760. {
  761.     switch (m_lEmulation)
  762.     {
  763.         case dsDevStudio:
  764.             m_ReplaceText.ReplaceSel(_T("\\9"));
  765.             break;
  766.         case dsVC2:
  767.             m_ReplaceText.ReplaceSel(_T("\\9"));
  768.             break;
  769.         case dsBrief:
  770.             m_ReplaceText.ReplaceSel(_T("\\9"));
  771.             break;
  772.         case dsEpsilon:
  773.             m_ReplaceText.ReplaceSel(_T("\\9"));
  774.             break;
  775.         case dsCustom:
  776.             m_ReplaceText.ReplaceSel(_T("\\9"));
  777.             break;
  778.     }
  779.     m_RegularExpression.SetCheck(1);
  780. }
  781.  
  782. /////////////////////////////////////////////////////////////////////////////
  783. // CReplaceDlg message handlers
  784.  
  785. void CReplaceDlg::OnOK() 
  786. {
  787.     m_FindText.GetWindowText(m_strFindString);
  788.     m_ReplaceText.GetWindowText(m_strReplaceString);
  789.  
  790.     m_bMatchCase = false;
  791.     m_bRegularExpression = false;
  792.     m_bMatchWholeWord = false;
  793.     
  794.     if (m_MatchWholeWord.GetCheck() == 1)
  795.         m_bMatchWholeWord = true;
  796.     if (m_RegularExpression.GetCheck() == 1)
  797.         m_bRegularExpression = true;
  798.     if (m_MatchCase.GetCheck() == 1)
  799.         m_bMatchCase = true;
  800.  
  801.     CDialog::OnOK();
  802. }
  803.  
  804. void CReplaceDlg::OnRegexpfind() 
  805. {
  806.     CMenu ContextMenu;
  807.     ContextMenu.LoadMenu(IDR_REGEXPMENU);
  808.     CMenu* hMenu = ContextMenu.GetSubMenu(0); 
  809.     POINT pt;
  810.     GetCursorPos(&pt);
  811.     hMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, 
  812.             pt.x, pt.y, this, NULL);
  813. }
  814.  
  815. void CReplaceDlg::OnRegExpReplace() 
  816. {
  817.     CMenu ContextMenu;
  818.     ContextMenu.LoadMenu(IDR_REGEXPMENU);
  819.     CMenu* hMenu = ContextMenu.GetSubMenu(1);
  820.     POINT pt;
  821.     GetCursorPos(&pt);
  822.     hMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, 
  823.             pt.x, pt.y, this, NULL);
  824. }
  825.  
  826. BOOL CReplaceDlg::OnInitDialog() 
  827. {
  828.     CDialog::OnInitDialog();
  829.     
  830.     m_FindText.SetWindowText(m_strFindString);
  831.     
  832.     return TRUE;  // return TRUE unless you set the focus to a control
  833.                   // EXCEPTION: OCX Property Pages should return FALSE
  834. }
  835.