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

📄 dialogs.c

📁 Dos6.0
💻 C
📖 第 1 页 / 共 4 页
字号:
          /* Add the filenames to the listbox */
          if (ffi == NULL || ffi->fpNextFileInfo == NULL)
            {
              MessageBox ("No matching files", NULL, NULL, MB_OK | 0x8000);
	      //  EndDialog(pwnd, wParam );

	      /* Display the previous status line text */
	      DisplayStatus (midFind);

              ((PWND_DLG)pwnd)->wParamEnd = IDCANCEL;
              break;
            }

          while (ffi != NULL && ffi->fpNextFileInfo != NULL)
            {
              DATE_INFO FAR *fpDate;  /* For printing the date   */
              WORD      wLength;      /* Length of sprintfBuffer */
              WORD      wYear;        /* Adjusted year           */


              /* Clear out chBuffer */
              memset (chBuffer, ' ', FIND_FILE_LINE_LENGTH);
              chBuffer[FIND_FILE_LINE_LENGTH] = '\0';


              /* Put the text date into chBuffer */
              fpDate = (DATE_INFO FAR *) &(ffi->wDate);

              /* Adjust date if >= year 2000 */
              wYear = 80 + fpDate->Year;
              wYear = (wYear >= 100) ? wYear - 100 : wYear;

              wLength = sprintf (sprintfBuffer, "%2d/%02d/%02d",
                                 fpDate->Month,
                                 fpDate->Day,
                                 wYear);

              strncpy (&chBuffer[DATE_COLUMN],
                       sprintfBuffer,
                       wLength);


              /* Put the file size into chBuffer */
              wLength = sprintf (sprintfBuffer, "%15lu",
                                 ffi->dwSize);

              strncpy (&chBuffer[SIZE_COLUMN],
                       sprintfBuffer,
                       wLength);


              if ((ffi->dwFileVersionMS | ffi->dwFileVersionLS) != 0)
                {
                  wLength = sprintf (sprintfBuffer,
                                     "%u.%u.%u.%u ",
                                     FP_SEG (ffi->dwFileVersionMS),
                                     FP_OFF (ffi->dwFileVersionMS),
                                     FP_SEG (ffi->dwFileVersionLS),
                                     FP_OFF (ffi->dwFileVersionLS));

                  strncpy (&chBuffer[SIZE_COLUMN + 5 - wLength],
                           sprintfBuffer,
                           wLength);
                }


              /* Put the filename into chBuffer */
              wLength = _fstrlen (ffi->fpszPathToFile);

              if (wLength > FIND_FILE_LINE_LENGTH - 2)
                wLength = FIND_FILE_LINE_LENGTH - 2;

              _fstrncpy (chBuffer, ffi->fpszPathToFile, wLength);

              chBuffer[wLength] = ' ';


              /* Add the item to the listbox */
              SendMessage (GetDlgItem (pwnd, IDD_USER + 8),
                           LB_ADDSTRING,
                           ((WORD) (isaNil) << 8) + TRUE,
                           (DWORD) ((CHAR FAR *) (&chBuffer[0])));


              /* Point to the next File info structure */
              ffi = (FILE_INFO FAR *) (ffi->fpNextFileInfo);
            }

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

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

          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:           /* ENTER key    */
            case IDD_USER + 10:  /* Display File */
            case IDD_USER + 11:  /* File Info    */
              {
                INT   i;                    /* Looping variable     */


                /* Get the path */

                /* This gets the index of the item */
                i = (INT) SendMessage (GetDlgItem (pwnd, IDD_USER + 8),
                                       LB_GETCURSEL, 0, 0L);

                /* Find the i'th element of the list */
                ffi = ffi2;

                if (i != isaNil)
                  {
                    while (i-- && ffi != NULL && ffi->fpNextFileInfo != NULL)
                      {
                        /* Point to the next File info structure */
                        ffi = (FILE_INFO FAR *) (ffi->fpNextFileInfo);
                      }

                    if (++i != 0)
                      {
                        pqszBrowseStrings = NULL;
                        pszBrowseTitle = NULL;
                        wParam = IDCANCEL;
                      }
                    else
                      {
                        /* Put the path in a more permanent "home" */
                        _fstrcpy (EditBuf2, ffi->fpszPathToFile);

                        pszBrowseTitle = EditBuf2;
                      }
                  }
                else
                  {
                    pqszBrowseStrings = NULL;
                    pszBrowseTitle = NULL;
                    wParam = IDCANCEL;
                  }

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

                /* Set them back to NULL */
                ffi  = NULL;
                ffi2 = NULL;

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

            case IDCANCEL:
              {
                /* Clear out the previous FileInfo structure */
                FreeFileInfo (ffi2);

                /* Set them back to NULL */
                ffi  = NULL;
                ffi2 = NULL;

                /* Display the previous status line text */
                DisplayStatus (midFind);

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

        break;

      default:
        return (FALSE);
    }

  return (TRUE);
}


/*********************************************************************
 * InsertCmdDlg1 - Procedure to handle the Insert Command dialog box.
 *********************************************************************/

LONG FAR PASCAL InsertCmdDlg1 (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;

          /* Display the help string */
          DisplayStatus (ST_INSERT_DLG1);

          ReadCommands (GetDlgItem (pwnd, IDD_USER + 3));

          if (SendMessage (GetDlgItem (pwnd, IDD_USER + 3),
                           LB_GETCOUNT, 0, 0L) > 0)
            {
              /* Highlight the first item in the list box */
              SendMessage (GetDlgItem (pwnd, IDD_USER + 3), 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:
              {
                static CHAR szCommand[256];    /* Stores the command string     */
                static CHAR szSection[256];    /* Stores the section to change  */
                static CHAR szFilename[256];   /* Stores the filename to change */
                CHAR szLbString[256];          /* Selected string stored here   */
                INT  i;                        /* Looping variable              */


                /* Get the string from the listbox */
                SendMessage (GetDlgItem (pwnd, IDD_USER + 3), LB_GETTEXT,
                             255, (DWORD) ((CHAR FAR *) szLbString));


                /* Extract the szCommand string */
                if (strlen (szLbString) < INI_SECTION_COL - 1)
                  i = strlen (szLbString);
                else
                  i = INI_SECTION_COL - 1;

                for (; i >= 0 && szLbString[i] == ' '; --i)
                  ;

                if (i > 0)
                  {
                    memcpy (szCommand, szLbString, ++i);
                    szCommand[i] = '\0';
                  }
                else
                  szCommand[0] = '\0';


                /* Extract the szSection string */
                if (strlen (szLbString) < INI_FILENAME_COL - 1)
                  i = strlen (szLbString);
                else
                  i = INI_FILENAME_COL - 1;

                for (; i >= INI_SECTION_COL && szLbString[i] == ' '; --i)
                  ;

                if (i > INI_SECTION_COL)
                  {
                    memcpy (szSection, &szLbString[INI_SECTION_COL],
                            ++i - INI_SECTION_COL);
                    szSection[i - INI_SECTION_COL] = '\0';
                  }
                else
                  szSection[0] = '\0';


                /* Extract the szFilename string */
                for (i = strlen (szLbString);
                     i >= INI_FILENAME_COL && szLbString[i] == ' '; --i)
                  ;

                if (i > INI_FILENAME_COL)
                  {
                    memcpy (szFilename, &szLbString[INI_FILENAME_COL],
                            ++i - INI_FILENAME_COL);
                    szFilename[i - INI_FILENAME_COL] = '\0';
                  }
                else
                  szFilename[0] = '\0';


                /* Bring up edit dialog box */
                pszInsertCommand  = szCommand;
                pszInsertSection  = szSection;
                pszInsertFilename = szFilename;
                if (DialogBox (&dlgInsertCmd2, InsertCmdDlg2) == IDOK)
                  ((PWND_DLG)pwnd)->wParamEnd = IDOK;
                else
                  DisplayStatus (ST_INSERT_DLG1);

                break;
              }

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

        break;

      default:
        return (FALSE);
    }

  return (TRUE);
}


/*********************************************************************
 * InsertCmdDlg2 - Procedure to handle the Insert Command editing
 *                 dialog box.
 *********************************************************************/

LONG FAR PASCAL InsertCmdDlg2 (PWND pwnd,
                               WORD message,
                               WORD wParam,
                               DWORD lParam)
{
  WORD wReturnValue;  /* Return value */


  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;

          /* Display the help string */
          DisplayStatus (ST_INSERT_DLG2);

          // 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 + 1),
                       EM_SETBUF, (WORD) EditBuf, MAKELONG(255, 255));
          SetEditText (GetDlgItem (pwnd, IDD_USER + 1), pszInsertCommand, TRUE);
          SendMessage (GetDlgItem (pwnd, IDD_USER + 3),
                       EM_SETBUF, (WORD) EditBuf2, MAKELONG(255, 255));
          SetEditText (GetDlgItem (pwnd, IDD_USER + 3), pszInsertSection, TRUE);
          SendMessage (GetDlgItem (pwnd, IDD_USER + 5),
                       EM_SETBUF, (WORD) EditBuf3, MAKELONG(255, 255));
          SetEditText (GetDlgItem (pwnd, IDD_USER + 5), pszInsertFilename, TRUE);
          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 updated strings */
              GetEditText (GetDlgItem (pwnd, IDD_USER + 1),
                           pszInsertCommand, 255);
              GetEditText (GetDlgItem (pwnd, IDD_USER + 3),
                           pszInsertSection, 255);
              GetEditText (GetDlgItem (pwnd, IDD_USER + 5),
                           pszInsertFilename, 255);

              /* Check for blank fields */
              if (strlen (pszInsertCommand)  == 0)
                {
                  wReturnValue = MessageBox ("A command must be entered in the Command field",
                                              NULL, NULL, MB_OKCANCEL | 0x8000);

                  if (wReturnValue == IDCANCEL)
                    ((PWND_DLG)pwnd)->wParamEnd = wParam;
                }
              else if (strlen (pszInsertFilename) == 0)
                {
                  wReturnValue = MessageBox ("A filename must be entered in the File field",
                                              NULL, NULL, MB_OKCANCEL | 0x8000);

                  if (wReturnValue == IDCANCEL)
                    ((PWND_DLG)pwnd)->wParamEnd = IDCANCEL;
                }
              else
                ((PWND_DLG)pwnd)->wParamEnd = IDOK;

              break;

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

        break;

⌨️ 快捷键说明

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