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

📄 dialogs.c

📁 Dos6.0
💻 C
📖 第 1 页 / 共 4 页
字号:
/*********************************************************************
 * Microsoft Diagnostics Version 2.0
 *
 * A diagnostic utility to detect as much useful information about a
 *   customer's computer system as is possible.
 *
 * Microsoft Diagnostics:  We detect the World.
 *
 * DIALOGS.C - Source file for handling the various dialog boxes
 ********************************************************************/


/* Include Files */

#include "msd.h"


#ifdef CW_INCLUDED


// An example of how to call ADM to process your dialog.

//VOID CallReportsDialog()
//{
//  WORD wReturn;

  // Call with the address of the dialog template ( in dialog.adm ) and
  // the address of the app's dialog proc.
  // wReturn will contain the value passed to EndDialog () within the apps
  // dialog proc.

//  wReturn = DialogBox ( &dlgReport, ReportDlg );
//}


/* Global to this file */
char EditBuf[256];
char EditBuf2[256];
char EditBuf3[256];


/*********************************************************************
 * ReportDlg - Procedure to handle the Print Report dialog box.
 *********************************************************************/

LONG FAR PASCAL ReportDlg (PWND pwnd,
                           WORD message,
                           WORD wParam,
                           DWORD lParam)
{
  WORD i;                      /* Looping variable              */


  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;

          // It is the repsonsibility of the application to supply a buffer
          //  for the edit control. In the example below, EditBuf is the
          //  buffer declared in the source, somewhere. ( Don't make it a local
          //  variable in this proc!!! ). lParam has two values set, both equal
          //  to 255. These values are the size of the buffer. If your buffer
          //  is only 80 characters wide, then use MAKELONG(80,80).
          //
          SendMessage (GetDlgItem (pwnd, IDD_USER + 33), EM_SETBUF,
                       (WORD) EditBuf, MAKELONG (255, 255));


          /* Set the default edit text */
          SetEditText (GetDlgItem (pwnd, IDD_USER + 33), "REPORT.MSD", TRUE);

          // 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'.

          /* Set the default to what it was when we left (wReportToIndex) */
          CheckDlgRadioButton (pwnd, IDD_USER + 25, IDD_USER + 32,
                               wReportToIndex + IDD_USER + 25);

          /* Set the default items to report */
          for (i = 2; i < MAX_REPORT_ITEM_FLAGS; ++i)
            if (rgfReportItemFlag[i] == TRUE)
              {
                // CheckDlgButton (GetDlgItem (pwnd, IDD_USER + i),
                //                 bstOn, TRUE);

                SendMessage (GetDlgItem (pwnd, IDD_USER + i),
                                    BM_SETCHECK, TRUE, 0L);
                DrawWindow ((PWND_BTN) GetDlgItem (pwnd, IDD_USER + i));
              }

          break;
        }

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

      case WM_COMMAND:
        // For the 'Print To' radio group, we have to assume responsability for
        // checking/unchecking the buttons.
        if ( wParam >= IDD_USER + 25 &&
             wParam <= IDD_USER + 32 )
          {
            CheckDlgRadioButton (pwnd, IDD_USER + 25, IDD_USER + 32, wParam);

            /* Set the report filename to the correct item */
            wReportToIndex = wParam - (IDD_USER + 25);

            /* If this is the "File" radio button, set the focus */
            /*   to the edit box.                                */

            if (wParam == IDD_USER + 32)
              SetFocus (GetDlgItem (pwnd, IDD_USER + 33));

            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:
              {
                /* Set the filename for the report */
                if (wReportToIndex == 7)  /* File: */
                  {
                    CHAR chBuffer[256];  /* Holds the edit item's text */

                    GetEditText (GetDlgItem (pwnd, IDD_USER + 33),
                                 chBuffer, 255);

                    pszReportFilename = malloc (strlen (chBuffer) + 1);
                    if (pszReportFilename == NULL)
                      {
                        /* If there's insufficient memory, cancel */
                        //  EndDialog (pwnd, wParam);
                        ((PWND_DLG)pwnd)->wParamEnd = IDCANCEL;
                        break;
                      }

                    strcpy (pszReportFilename, chBuffer);
                  }

                /* Set the default items to report */
                for (i = 1; i < MAX_REPORT_ITEM_FLAGS; ++i)
                  {
                    if (SendMessage (GetDlgItem (pwnd, IDD_USER + i),
                                     BM_GETCHECK, 0, 0L))
                      rgfReportItemFlag[i] = TRUE;
                    else
                      rgfReportItemFlag[i] = FALSE;
                  }

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

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

            // The 'Report All' checkbox was clicked on. If it is now 'on', we
            // want to turn on all the other checkbox's. That is what this little
            // piece of code is doing.

            case IDD_USER + 1:
              if (SendMessage (GetDlgItem (pwnd, IDD_USER + 1),
                               BM_GETCHECK, 0, 0L))
                {
                  i = IDD_USER + 2;

                  for (i = IDD_USER + 2; i <= IDD_USER + 23; ++i)
                    {
                      // CheckDlgButton (GetDlgItem (pwnd, i), bstOn, TRUE);

                      SendMessage (GetDlgItem (pwnd, i),
                                   BM_SETCHECK, TRUE, 0L);
                      DrawWindow ((PWND_BTN) GetDlgItem (pwnd, i));
                    }
                }
              break;

            case IDD_USER +  2:
            case IDD_USER +  3:
            case IDD_USER +  4:
            case IDD_USER +  5:
            case IDD_USER +  6:
            case IDD_USER +  7:
            case IDD_USER +  8:
            case IDD_USER +  9:
            case IDD_USER + 10:
            case IDD_USER + 11:
            case IDD_USER + 12:
            case IDD_USER + 13:
            case IDD_USER + 14:
            case IDD_USER + 15:
            case IDD_USER + 16:
            case IDD_USER + 17:
            case IDD_USER + 18:
            case IDD_USER + 19:
            case IDD_USER + 20:
            case IDD_USER + 21:
            case IDD_USER + 22:
            case IDD_USER + 23:
              // CheckDlgButton (GetDlgItem (pwnd, IDD_USER + 1),
              //                 bstOff, TRUE);

              SendMessage (GetDlgItem (pwnd, IDD_USER + 1),
                           BM_SETCHECK, FALSE, 0L);
              DrawWindow ((PWND_BTN) GetDlgItem (pwnd, IDD_USER + 1));

              break;
          }

        break;

      case MY_EN_SETFOCUS:
        SendMessage (pwnd, WM_COMMAND, IDD_USER + 32, 0L);
        break;

      default:
        return (FALSE);
    }

  return (TRUE);
}


BOOL fDlgSearchFlags;

/*********************************************************************
 * FindFileDlg1 - Procedure to handle the Print Report dialog box.
 *********************************************************************/

LONG FAR PASCAL FindFileDlg1 (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:
        {
          CHAR chPath[_MAX_PATH];   /* Current path */


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

          /* Clear out EditBuf and EditBuf2 */
          EditBuf[0]  = '\0';
          EditBuf2[0] = '\0';

          SendMessage (GetDlgItem (pwnd, IDD_USER + 1),
                       EM_SETBUF, (WORD) EditBuf, MAKELONG(255, 255));

          SendMessage (GetDlgItem (pwnd, IDD_USER + 3),
                       EM_SETBUF, (WORD) EditBuf2, MAKELONG(255, 255));

          /* Put the current path into the "Search from" edit item */
          getcwd (chPath, _MAX_PATH - 1);
          SetEditText (GetDlgItem (pwnd, IDD_USER + 3), chPath, TRUE);

          break;
        }

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

      case WM_COMMAND:
        switch (wParam)
          {
            WORD wResult;
            // 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:
              {
                if (strlen (EditBuf) == 0)
                  {
                    MessageBox ("A filespec must be entered",
                                "in the \"Search for\" field",
                                NULL, MB_OK | 0x8000);
                    break;
                  }

                /* Check to see if a path was entered in "Search for" */
                if (strchr (EditBuf, '\\') || strchr (EditBuf, ':'))
                  {
                    PSZ pszLast;  /* Last path character */
                    CHAR chBuffer1[256];  /* Holds the edit item's text */
                    CHAR chBuffer2[256];  /* Holds the edit item's text */

                    GetEditText (GetDlgItem (pwnd, IDD_USER + 1),
                                 chBuffer1, 255);

                    /* A path was found, make it the "search from" string */
                    chBuffer2[0] = '\0';
                    strcpy (chBuffer2, chBuffer1);
                    pszLast = max (strrchr (chBuffer2, '\\'),
                                   strrchr (chBuffer2, ':'));
                    if (pszLast[0] == ':')
                      ++pszLast;

                    pszLast[0] = '\0';


                    /* Now, adjust the "search for" string */
                    pszLast = max (strrchr (chBuffer1, '\\'),
                                   strrchr (chBuffer1, ':')) + 1;

                    memmove (chBuffer1, pszLast, strlen (pszLast) + 1);
                    SetEditText (GetDlgItem (pwnd, IDD_USER + 1),
                                 chBuffer1, TRUE);
                    SetEditText (GetDlgItem (pwnd, IDD_USER + 3),
                                 chBuffer2, TRUE);
                  }

                /* Set the flags for the search */
		fDlgSearchFlags = SEARCH_VERSION;

                if (SendMessage (GetDlgItem (pwnd, IDD_USER + 4),
                                 BM_GETCHECK, 0, 0L))
                  fDlgSearchFlags |= RECURSE_INTO_SUB_DIRS;
		/*
                if (SendMessage (GetDlgItem (pwnd, IDD_USER + 5),
                                 BM_GETCHECK, 0, 0L))
                  fDlgSearchFlags |= SEARCH_BOOT_DRIVE;
		*/
		if (SendMessage (GetDlgItem (pwnd, IDD_USER + 5),
                                 BM_GETCHECK, 0, 0L))
                  fDlgSearchFlags |= SEARCH_FLOPPIES | SEARCH_LOCAL_DRIVES |
				  SEARCH_NET_DRIVES | SEARCH_ROOT;


                if ((wResult = DialogBox (&dlgFindFile2, FindFileDlg2))
                     != IDCANCEL)
                  {
                    //  EndDialog(pwnd, wParam );
                    ((PWND_DLG)pwnd)->wParamEnd = wResult;
                  }

                break;
              }

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

        break;

      default:
        return (FALSE);
    }

  return (TRUE);
}


/*********************************************************************
 * FindFileDlg2 - Procedure to handle the Print Report dialog box.
 *********************************************************************/

LONG FAR PASCAL FindFileDlg2 (PWND pwnd,
                              WORD message,
                              WORD wParam,
                              DWORD lParam)
{
  static FILE_INFO FAR * ffi  = NULL;   /* File Information structure */
  static FILE_INFO FAR * ffi2 = NULL;   /* File Information structure (copy) */


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

      case WM_INITDIALOG:
        {
          BOOL fSearchFlags = 0;  /* Search flags for FindFile  */
          CHAR chBuffer[80];      /* String to hand to list box */
          CHAR sprintfBuffer[80]; /* Buffer for sprintf-ing     */


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

          /* Clear out the previous FileInfo structure */
          FreeFileInfo (ffi2);

          /* Inform the user that we are searching */
          DisplayStatus (ST_SEARCHING);


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


          /* Perform the search */
          if (EditBuf2[0] == '\0')
            ffi = FindFile (EditBuf, NULL, fDlgSearchFlags, '\0');
          else
            ffi = FindFile (EditBuf, EditBuf2, fDlgSearchFlags, '\0');

          /* Preserve the FindFile info */
          ffi2 = ffi;

          /* Redisplay the status line */
          PostMessage (pwndStatusLine, WM_PAINT, NULL, NULL);


⌨️ 快捷键说明

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