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

📄 dialogs.c

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

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

        break;

      default:
        return (FALSE);
    }

  return (TRUE);
}


/*********************************************************************
 * CustInfoCmdDlg - Procedure to handle the Customer Information
 *                  dialog box.
 *********************************************************************/

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

          DisplayStatus (ST_CUST_INFO);

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

          /* Set up the edit items */
          SendMessage (GetDlgItem (pwnd, IDD_USER + 2),
                       EM_SETBUF, (WORD) pCustInfoDlg->chCustInfo[0],
                       MAKELONG (MAX_CUST_INFO, MAX_CUST_INFO));
          SendMessage (GetDlgItem (pwnd, IDD_USER + 4),
                       EM_SETBUF, (WORD) pCustInfoDlg->chCustInfo[1],
                       MAKELONG (MAX_CUST_INFO, MAX_CUST_INFO));
          SendMessage (GetDlgItem (pwnd, IDD_USER + 6),
                       EM_SETBUF, (WORD) pCustInfoDlg->chCustInfo[2],
                       MAKELONG (MAX_CUST_INFO, MAX_CUST_INFO));
          SendMessage (GetDlgItem (pwnd, IDD_USER + 8),
                       EM_SETBUF, (WORD) pCustInfoDlg->chCustInfo[3],
                       MAKELONG (MAX_CUST_INFO, MAX_CUST_INFO));
          SendMessage (GetDlgItem (pwnd, IDD_USER + 10),
                       EM_SETBUF, (WORD) pCustInfoDlg->chCustInfo[4],
                       MAKELONG (MAX_CUST_INFO, MAX_CUST_INFO));
          SendMessage (GetDlgItem (pwnd, IDD_USER + 12),
                       EM_SETBUF, (WORD) pCustInfoDlg->chCustInfo[5],
                       MAKELONG (MAX_CUST_INFO, MAX_CUST_INFO));
          SendMessage (GetDlgItem (pwnd, IDD_USER + 14),
                       EM_SETBUF, (WORD) pCustInfoDlg->chCustInfo[6],
                       MAKELONG (MAX_CUST_INFO, MAX_CUST_INFO));
          SendMessage (GetDlgItem (pwnd, IDD_USER + 16),
                       EM_SETBUF, (WORD) pCustInfoDlg->chCustInfo[7],
                       MAKELONG (MAX_CUST_INFO, MAX_CUST_INFO));
          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:
              // Fall through to IDCANCEL.

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

        break;

      default:
        return (FALSE);
    }

  return (TRUE);
}


/*********************************************************************
 * AboutDlg - Procedure to handle the about box.
 *********************************************************************/

LONG FAR PASCAL AboutDlg (PWND pwnd,
                          WORD message,
                          WORD wParam,
                          DWORD lParam)
{
  switch (message)
    {
      case WM_INITDIALOG:
        {
#if HEAP_DEBUG
          {
            CHAR chBuffer[80];
            PSZ  pszPointer;
            pszPointer = malloc (_memmax() - 16);
            free (pszPointer);
            _heapset (0x50);
            sprintf (chBuffer, "_memavl = %u - _memmax = %u = %u, at = %04X",
                     _memavl(), _memmax(), _memavl() - _memmax(), pszPointer);
            ShowStatus (chBuffer);
          }
#endif
          // Gives the dialog box a border.
          SetWindowStyle ( pwnd, pwnd->style | WS_BORDER );
          break;
        }

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

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

      default:
        return (FALSE);
    }

  return (TRUE);
}


/*********************************************************************
 * MemoryBlockDisplayDlg - Procedure to handle the about box.
 *********************************************************************/

LONG FAR PASCAL MemoryBlockDisplayDlg (PWND pwnd,
                                       WORD message,
                                       WORD wParam,
                                       DWORD lParam)
{
  static MEMORY_STRUCT *pMem;         /* Stores memory structure       */
  static TSR_PROGRAMS_STRUCT *pTsr;   /* Stores TSR Programs structure */
  static MEM_MAP *pmmMap = NULL;      /* Local copy of visual mem map  */
  INT  i, u;                          /* Looping variables             */
  WORD wSize;                         /* Size of various structs       */
  CHAR chBuffer[80];                  /* Local string buffer           */
  QSZ  *pqszStrings = NULL;           /* String buffer                 */


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


          /* Set the colors for the listbox */
          {
            PWND_LIST pwndList;

            pwndList = (PWND_LIST) GetDlgItem (pwnd, IDD_USER + 3);
            pwndList->isaHiliteColor = isaMemoryMap;
         /* pwndList->isaColor       = isaMemoryMap; */
          }


          /* Get the memory map */

          wSize = GetInfoSize (IDI_MEMORY_RECORD, FALSE);

          if (wSize == 0)
            break;


          /* Allocate enough room for the info structure */
          pMem = malloc (wSize);

          if (pMem == NULL)
            {
              OutOfMemory();
              break;
            }

          /* Zero out the structure */
          memset (pMem, '\0', wSize);

          /* Fill the structure with the information */
          if (GetInfo (IDI_MEMORY_RECORD, pMem, FALSE, FALSE, FALSE))
            {
              free (pMem);
              break;
            }


          /* Add the memory map to the memory listbox */

          /* Allocate a local copy of the visual mem map */
          pmmMap = malloc (sizeof (MEM_MAP));
          if (pmmMap == NULL)
            {
              free (pMem);
              break;
            }

          /* Clear the list box */
          SendMessage (GetDlgItem (pwnd, IDD_USER + 3),
                       LB_RESETCONTENT, NULL, NULL);

          /* Add all the strings */
          for (i = NUM_OF_ROWS - 1; i >= 0; --i)
            {
              /* Put the overlay over the memory map */
              strcat (chBuffer, pMem->abMemoryMap[i]);
              for (u = 0; u < NUM_OF_COLS - 1; ++u)
                if (pMem->abMemMapOverlay[i][u])
                  pMem->abMemoryMap[i][u] = pMem->abMemMapOverlay[i][u];

              /* Display hexadecimal equivilent of memory location */
              sprintf (chBuffer, "%04X %s", (WORD) i * 0x0400, 
                       pMem->abMemoryMap[i]);

              /* Put the string into the list box */
              SendMessage (GetDlgItem (pwnd, IDD_USER + 3),
                           LB_ADDSTRING,
                           ((WORD) (isaMemoryMap) << 8) + TRUE,
                           (DWORD) ((CHAR FAR *) (chBuffer)));

              /* Store this line of the visual mem map */
              strcpy (pmmMap->abMap[i], chBuffer);
            }


          /* Free up the memory info strcture */
          free (pMem);


          /* Get the TSR list */

          wSize = GetInfoSize (IDI_TSR_PROGRAMS_RECORD, FALSE);

          if (wSize == 0)
            break;


          /* Allocate enough room for the info structure */
          pTsr = malloc (wSize);

          if (pTsr == NULL)
            {
              OutOfMemory();
              break;
            }

          /* Zero out the structure */
          memset (pTsr, '\0', wSize);

          /* Fill the structure with the information */
          if (GetInfo (IDI_TSR_PROGRAMS_RECORD, pTsr, FALSE, FALSE, FALSE))
            {
              free (pTsr);
              break;
            }

          /* Convert the structure to strings */
          pqszStrings = SprintTsrInfo (pTsr, FALSE);


          /* Add the TSR list to the memory listbox */

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

          for (u = 2; pqszStrings[u] != NULL; ++u)
            ;

          /* Add all the strings */
          for (i = u - 1; i >= 2; --i)
            {
              /* Drop the command line parameters */
              pqszStrings[i][TSR_CMD_LINE_COL] = '\0';


              /* Put the string into the list box */
              SendMessage (GetDlgItem (pwnd, IDD_USER + 1),
                           LB_ADDSTRING,
                           ((WORD) (isaNil) << 8) + TRUE,
                           (DWORD) ((CHAR FAR *) (pqszStrings[i])));
            }

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

          /* Show where the initial item is stored */
          UpdateMemMap (pwnd, pmmMap);

          free (pTsr);
          FreeStringSpace (pqszStrings);

          break;
        }

      case WM_LISTBOX_COMMAND:
        {
          switch (HIWORD (lParam))
            {
              case LBN_SELCHANGE:
                {
                  /* Do nothing if the item was re-selected, or if it */
                  /*   came from the wrong listbox.                   */
                  if ((LOWORD (lParam) & flbrReselect) || wParam != IDD_USER + 1)
                    break;

                  UpdateMemMap (pwnd, pmmMap);
                }
            }

          break;
        }


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

      case WM_COMMAND:
        switch (wParam)
          {
            case IDCANCEL:
            case IDOK:
              free (pmmMap);
              //  EndDialog(pwnd, wParam );
              ((PWND_DLG)pwnd)->wParamEnd = wParam;
              break;
          }
        break;

      default:
        return (FALSE);
    }

  return (TRUE);
}


/*********************************************************************
 * UpdateMemMap - Updates the memory map with the indication of where
 *                the currently selected item in the TSR list is
 *                located.
 *
 * pwnd   - Dialog box PWND
 * pmmMap - Pointer to the MEM_MAP structure.
 *********************************************************************/

VOID UpdateMemMap (PWND pwnd, MEM_MAP *pmmMap)
{
  CHAR  chBuffer[80];   /* Local string                       */
  WORD  wAddress;       /* Address of TSR/MCB                 */
  DWORD dwBlockSize;    /* Length of TSR/MCB                  */
  INT   iRow;           /* Row in mem map                     */
  INT   iCol;           /* Column in mem map                  */
  INT   iNumOfChars;    /* Number of marker characters to add */
  PWND  pwndMap;        /* PWND of mem map                    */
  INT   iIndex;         /* Character count of marker          */
  INT   i;              /* Looping variable                   */


  /* Get the visual memory map's PWND */
  pwndMap = GetDlgItem (pwnd, IDD_USER + 3);

  /* Determine which item has been selected */
  SendMessage (GetDlgItem (pwnd, IDD_USER + 1),
               LB_GETTEXT,
               79, (DWORD) ((CHAR FAR *) chBuffer));

  sscanf (&chBuffer[TSR_ADDRESS_COL], "%04X", &wAddress);
  dwBlockSize = atol (&chBuffer[TSR_SIZE_COL]);


  /* Find the place to begin marking the visual mem map */
  iRow        = (NUM_OF_ROWS - 1) - (wAddress / 0x400);
  iCol        = (wAddress % 0x400) / 0x40;
  iNumOfChars = (WORD) ((dwBlockSize + 1023) / 1024);


  /* Re-add the original lines to the listbox */
  SendMessage (pwndMap, LB_RESETCONTENT, NULL, NULL);

  for (i = NUM_OF_ROWS - 1; i >= 0; --i)
    {
      SendMessage (pwndMap, LB_ADDSTRING,
                   ((WORD) (isaMemoryMap) << 8) + FALSE,
                   (DWORD) ((CHAR FAR *) (pmmMap->abMap[i])));
    }

  /* Now change the lines in the list box */

  /* Set the selection to our item */
  SendMessage (pwndMap, LB_SETCURSEL, iRow, NULL);

  /* Get the line from the list box */
  SendMessage (pwndMap, LB_GETTEXT, 79,
               (DWORD) (CHAR FAR *) (chBuffer));

  iIndex = 0;

  while (iIndex < iNumOfChars)
    {
      /* Choose the appropriate character */
      if (iNumOfChars == 1)
        chBuffer[iCol + 5] = '

⌨️ 快捷键说明

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