⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dialogs.c

📁 Dos6.0
💻 C
📖 第 1 页 / 共 4 页
字号:

      default:
        return (FALSE);
    }

  return (TRUE);
}


/*********************************************************************
 * InsertCmdDlg3 - Procedure to handle the Insert Command file choice
 *                 dialog box.
 *********************************************************************/

LONG FAR PASCAL InsertCmdDlg3 (PWND pwnd,
                               WORD message,
                               WORD wParam,
                               DWORD lParam)
{
  FILE_INFO FAR *pfi;   /* Local file info structure */


  switch (message)
    {
      // WM_INITDIALOG is your chance to perform Dialog initialization before
      // before the dialog box is displayed.

      case WM_INITDIALOG:
        {
          // Gives the dialog box a border.
          SetWindowStyle ( pwnd, pwnd->style | WS_BORDER );

          // Gives the dialog box a shadow.
          //  pwnd->wExtStyle |= WS_SHADOW;

          DisplayStatus (ST_INSERT_DLG3);

          /* Clear out the listbox */
          SendMessage (GetDlgItem (pwnd, IDD_USER + 1),
                       LB_RESETCONTENT, NULL, NULL);

          /* Load the list box with the list of matching files */
          pfi = pfiDlg;

          while (pfi != NULL && pfi->fpNextFileInfo != NULL)
            {
              SendMessage (GetDlgItem (pwnd, IDD_USER + 1),
                           LB_ADDSTRING,
                           ((WORD) (isaNil) << 8) + TRUE,
                           (DWORD) (pfi->fpszPathToFile));

              pfi = (FILE_INFO FAR *) pfi->fpNextFileInfo;
            }

          if (SendMessage (GetDlgItem (pwnd, IDD_USER + 1),
                           LB_GETCOUNT, 0, 0L) > 0)
            {
              /* Highlight the first item in the list box */
              SendMessage (GetDlgItem (pwnd, IDD_USER + 1), LB_SETCURSEL, 0, 0L);
            }

          break;
        }

      case WM_DRAWITEM:
        {
          DrawPlateButton1 (pwnd, message, wParam, lParam);
          break;
        }

      case WM_COMMAND:
        switch (wParam)
          {
            // User pressed the Ok or the Cancel Button.
            //  At this point, you should retrieve any state info you need.
            //  The Edit buffer will contain any text you may need.
            //  EndDialog MUST be called if you intend to end the dialog.

            case IDOK:
              {
                /* Get the string from the listbox */
                SendMessage (GetDlgItem (pwnd, IDD_USER + 1), LB_GETTEXT,
                             255, (DWORD) ((CHAR FAR *) EditBuf));

                pszInsertFilename = EditBuf;

                // Fall through to IDCANCEL
              }

            case IDCANCEL:
              //  EndDialog(pwnd, wParam );
              ((PWND_DLG)pwnd)->wParamEnd = wParam;
              break;
          }

        break;

      default:
        return (FALSE);
    }

  return (TRUE);
}


/*********************************************************************
 * InsertCmdDlg4 - Procedure to handle the Insert Command line choice
 *                 dialog box.
 *********************************************************************/

LONG FAR PASCAL InsertCmdDlg4 (PWND pwnd,
                               WORD message,
                               WORD wParam,
                               DWORD lParam)
{
  static CHAR szSearchString[80]; /* String to search for in command file */
  INT  i1, i2;                    /* Looping variables                    */
  BOOL fReturnValue;              /* Return value from various functions  */
  WORD wIndex;                    /* Index to the list box                */
  static WORD wReplaceAllIndex;   /* Index to the "REPLACE ALL" line      */
  FILE *fpIn;                     /* File handles for reading input file  */
  static PWND pwndList;           /* List box's PWND                      */


  switch (message)
    {
      // WM_INITDIALOG is your chance to perform Dialog initialization before
      // before the dialog box is displayed.

      case WM_INITDIALOG:
        {
          // Gives the dialog box a border.
          SetWindowStyle ( pwnd, pwnd->style | WS_BORDER );

          // Gives the dialog box a shadow.
          //  pwnd->wExtStyle |= WS_SHADOW;

          DisplayStatus (ST_INSERT_DLG4);

          /* Clear out the listbox */
          pwndList = GetDlgItem (pwnd, IDD_USER + 1);
          SendMessage (pwndList, LB_RESETCONTENT, 0, 0L);

          /* Add the "ADD LINE" string */
          SendMessage (pwndList, LB_ADDSTRING,
                       ((WORD) (isaNil) << 8) + TRUE,
                       (DWORD) ((CHAR FAR *) "ADD LINE"));


          /* Prepare search string by finding the primary part of the command. */
          /*   This is accomplished by searching for the first "=" character.  */
          /*   If found, extra whitespace behind the "=" sign is removed from  */
          /*   the search string.  If no "=" sign is found, search for the     */
          /*   first whitespace character, and call that the delimiter.        */
          /*                                                                   */
          /*   Examples:                                                       */
          /*             szCommand:                   szSearchString:          */
          /*             "EmmExclude = C000 - EFFF"   "EmmExclude"             */
          /*             "SET TEMP=?"                 "SET TEMP"               */
          /*             "PATH C:\;C:\DOS"            "PATH"                   */

          for (i1 = 0; pszInsertCommand[i1] != '\0' && 
                       pszInsertCommand[i1] != '=';  ++i1)
            ;

          /* Check for "=" sign */

          if (pszInsertCommand[i1] == '=')
            {
              /* Remove white space between command and the "=" sign */

              for (i2 = i1 - 1; i2 >= 0 &&
                                (pszInsertCommand[i2] == ' ' ||
                                 pszInsertCommand[i2] == '\t'); --i2)
                ;

              /* Put the information into the search string */

              for (i1 = 0; i1 <= i2; ++i1)
                szSearchString[i1] = pszInsertCommand[i1];

              szSearchString[i1] = '\0';
            }
          else
            {
              for (i1 = 0; pszInsertCommand[i1] != '\0' &&
                           pszInsertCommand[i1] != ' '  &&
                           pszInsertCommand[i1] != '\t';   ++i1)
                ;

              /* Put the information into the search string, up to, but not */
              /*   including, the white space character.                    */

              for (i2 = 0; i2 < i1; ++i2)
                szSearchString[i2] = pszInsertCommand[i2];

              szSearchString[i2] = '\0';
            }


          /* Open the file */
          fpIn = OpenFile (pszInsertFilename, "rb", TRUE);
          if (fpIn == NULL)
            {
              //  EndDialog(pwnd, wParam );
              ((PWND_DLG)pwnd)->wParamEnd = IDOK;

              return (TRUE);
            }


          /* Locate the section in the file */
          if (pszInsertSection[0] != '\0')
            {
              fReturnValue = FindSection (pszInsertSection, fpIn, NULL);

              if (fReturnValue == TRUE)
                {
                  if (MessageBox (pszInsertSection,
                                  "Was not found.",
                                  "Add this to the file?",
                                  MB_YESNO | 0x8000) == IDNO)
                    {
                      CloseFile (fpIn);

                      //  EndDialog(pwnd, wParam );
                      ((PWND_DLG)pwnd)->wParamEnd = IDOK;

                      return (TRUE);
                    }
                }
            }
          else
            fReturnValue = FALSE;


          /* Load the list box with the list of matching lines */
          if (fReturnValue == FALSE)
            HandleDuplicates (HD_SEARCH,
                              szSearchString,
                              NULL,
                              fpIn,
                              NULL,
                              pwndList);


          wIndex = (WORD) SendMessage (pwndList, LB_GETCOUNT, 0, 0L);

          /* If there is more than 1 add and 1 replace line, */
          /*   add "REPLACE ALL".                            */
          if (wIndex > 2)
            {
              SendMessage (pwndList, LB_ADDSTRING,
                           ((WORD) (isaNil) << 8) + TRUE,
                           (DWORD) ((CHAR FAR *) "REPLACE ALL"));

              wReplaceAllIndex = wIndex;
            }
          else
            wReplaceAllIndex = 2;

          CloseFile (fpIn);

          /* Highlight the first item in the list box */
          SendMessage (pwndList, LB_SETCURSEL, 0, 0L);

          break;
        }

      case WM_DRAWITEM:
        {
          DrawPlateButton1 (pwnd, message, wParam, lParam);
          break;
        }

      case WM_COMMAND:
        switch (wParam)
          {
            // User pressed the Ok or the Cancel Button.
            //  At this point, you should retrieve any state info you need.
            //  The Edit buffer will contain any text you may need.
            //  EndDialog MUST be called if you intend to end the dialog.

            case IDOK:
              {
                wIndex = (WORD) SendMessage (pwndList, LB_GETCURSEL, 0, 0L);

                if (wIndex == wReplaceAllIndex)
                  ChangeFile (pszInsertFilename,
                              pszInsertSection,
                              pszInsertCommand,
                              szSearchString,
                              (WORD) HD_REPLACE_ALL);
                else
                  ChangeFile (pszInsertFilename,
                              pszInsertSection,
                              pszInsertCommand,
                              szSearchString,
                              wIndex);

                // Fall through to IDCANCEL
              }

            case IDCANCEL:
              //  EndDialog(pwnd, wParam );
              ((PWND_DLG)pwnd)->wParamEnd = wParam;
              break;
          }

        break;

      default:
        return (FALSE);
    }

  return (TRUE);
}


/*********************************************************************
 * TestPrinterDlg - Procedure to handle the "Test Printer" dialog box.
 *********************************************************************/

LONG FAR PASCAL TestPrinterDlg (PWND pwnd,
                                WORD message,
                                WORD wParam,
                                DWORD lParam)
{
  switch (message)
    {
      // WM_INITDIALOG is your chance to perform Dialog initialization before
      // before the dialog box is displayed.

      case WM_INITDIALOG:
        {
          // Gives the dialog box a border.
          SetWindowStyle ( pwnd, pwnd->style | WS_BORDER );

          // Gives the dialog box a shadow.
          //  pwnd->wExtStyle |= WS_SHADOW;

          // We should set a default value for the group of radio buttons
          // which indicate where we 'Print To'. Like under Windows,
          // The first parameter is the Dialog PWND, 2nd and third are the id's
          // of the first and last radio button in the group. The fourth paramter
          // is the ID of the radio button that is initally 'on'.

          CheckDlgRadioButton ( pwnd, IDD_USER + 1,
                         IDD_USER + 2,
                         IDD_USER + 1 );

          CheckDlgRadioButton ( pwnd, IDD_USER + 4,
                         IDD_USER + 5,
                         IDD_USER + 4 );

          CheckDlgRadioButton ( pwnd, IDD_USER + 7,
                         IDD_USER + 13,
                         IDD_USER + 7 );

          break;
        }

      case WM_DRAWITEM:
        {
          DrawPlateButton1 (pwnd, message, wParam, lParam);
          break;
        }

      case WM_COMMAND:
        // We have to assume responsability for checking/unchecking
        // radio buttons.

        if ( wParam >= IDD_USER + 1 &&
             wParam <= IDD_USER + 2 )
          {
            CheckDlgRadioButton (pwnd, IDD_USER + 1, IDD_USER + 2, wParam);
            return (TRUE);
          }

        if ( wParam >= IDD_USER + 4 &&
             wParam <= IDD_USER + 5 )
          {
            CheckDlgRadioButton (pwnd, IDD_USER + 4, IDD_USER + 5, wParam);
            return (TRUE);
          }

        if ( wParam >= IDD_USER + 7 &&
             wParam <= IDD_USER + 13 )
          {
            CheckDlgRadioButton (pwnd, IDD_USER + 7, IDD_USER + 13, wParam);
            return (TRUE);
          }

        switch (wParam)
          {
            // User pressed the Ok or the Cancel Button.
            //  At this point, you should retrieve any state info you need.
            //  The Edit buffer will contain any text you may need.
            //  EndDialog MUST be called if you intend to end the dialog.

            case IDOK:
              {
                WORD i;   /* Looping variable */


                /* Postscript Test */
                if (SendMessage (GetDlgItem (pwnd, IDD_USER + 2),
                                 BM_GETCHECK, 0, 0L))
                  tpValue.fPostscript = TRUE;
                else
                  tpValue.fPostscript = FALSE;


                /* Test Type (7 or 8 bit ASCII) */
                if (SendMessage (GetDlgItem (pwnd, IDD_USER + 5),
                                 BM_GETCHECK, 0, 0L))
                  tpValue.f8BitTest = TRUE;
                else
                  tpValue.f8BitTest = FALSE;


                /* Serial/Parallel and Port number */
                for (i =  IDD_USER +  7;
                     i <= IDD_USER + 13 &&
                     SendMessage (GetDlgItem (pwnd, i),
                                  BM_GETCHECK, 0, 0L)  == 0;
                     ++i)
                  ;

                i = i - (IDD_USER + 7);

                if (i < 3)
                  {
                    /* Parallel Port */
                    tpValue.fSerialTest = FALSE;
                    tpValue.wPort = i;
                  }
                else
                  {
                    /* Serial Port */
                    tpValue.fSerialTest = TRUE;
                    tpValue.wPort = i - 3;
                  }

                // Fall through to IDCANCEL.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -