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

📄 showinfo.c

📁 Dos6.0
💻 C
字号:
/*********************************************************************
 * 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.
 *
 * SHOWINFO.C - Source file for displaying information
 ********************************************************************/


/* Include Files */

#include "msd.h"


#ifdef CW_INCLUDED

/********************************************************************
 * ShowInfo - Displays the appropriate record in the info window.
 *
 * wRecordType - Record to display
 *
 * Returns: PWND of the info window, NULL if an error condition
 *          occured.
 ********************************************************************/

PWND ShowInfo (WORD wRecordType)
{
  VOID *pStructForInfo = NULL;  /* Pointer to structure with data   */
  WORD wStructSize;             /* Stores memory requirements for   */
                                /*   GetInfo record                 */
  QSZ  *pqszStrings;            /* Array of strings to print        */
  BOOL fReturnValue;            /* Stores return value from GetInfo */
  PWND pwndInfo = NULL;         /* Info Window's PWND               */


  /* Determine the memory required to store the record */
  wStructSize = GetInfoSize (wRecordType, 0);

  if (wStructSize == 0)
    {
#if HEAP_DEBUG
      CHAR chBuff1[80];   /* String for error message */

      sprintf (chBuff1, "%s, line %d\n", __FILE__, __LINE__);

      ShowError (MB_BEEP | MB_OK | 0x8000, "Invalid Record Type", "", "");
#endif
      return (NULL);
    }

  /* Allocate memory for the structure */
  pStructForInfo = malloc (wStructSize);
#if HEAP_DEBUG
  HeapCheck ("In ShowInfo, After malloc (wStructSize)");
#endif

  if (pStructForInfo == NULL)
    {
      OutOfMemory();
      return (NULL);
    }

  /* Zero out the structure */
  memset (pStructForInfo, '\0', wStructSize);

  /* If /I was used, set the flag stating that this information */
  /*   is now available for reporting.                          */
  rgfReportItemFlag[wRecordType] = TRUE;
  rgfReportItemFlag[IDI_SUMMARY_SCREEN] = TRUE;

  /* Fill it with the GetInfo data */
  fReturnValue = GetInfo (wRecordType,
                          pStructForInfo,
                          FALSE,    /* Do not obtain minimum info */
                          FALSE,    /* No include header record   */
                          TRUE);    /* We are doing a report      */

#if HEAP_DEBUG
  HeapCheck ("In ShowInfo, After GetInfo()");
#endif

  if (fReturnValue)
    {
      free (pStructForInfo);
      return (NULL);
    }

  /* Get the information into displayable strings */
  pqszStrings = SprintInfo (wRecordType,
                            pStructForInfo,
                            NULL,
                            FALSE);  /* We are not doing a report */
#if HEAP_DEBUG
  HeapCheck ("In ShowInfo, After SprintInfo()");
#endif

  /* Update the summary strings */
  SprintInfo (wRecordType, pStructForInfo,
              &(pSum->szSumStrings[wRecordType * 2]), TRUE);

#if HEAP_DEBUG
  HeapCheck ("In ShowInfo, After update of summary strings");
#endif

  /* PostMessage (pwndMainFrame, WM_PAINT, NULL, NULL); */

  /* Display the strings in the window */
  if (pqszStrings != NULL)
    pwndInfo = CreateInfoWnd (paszButtonNames[wRecordType],
                              pqszStrings,
                              FALSE);

#if HEAP_DEBUG
  HeapCheck ("In ShowInfo, After CreateInfoWnd()");
#endif

  free (pStructForInfo);

#if HEAP_DEBUG
  HeapCheck ("In ShowInfo, After free (pStructForInfo)");
#endif

  return (pwndInfo);
}


BOOL fVisibleFlag;            /* Set if scroll bar should be visible    */

/*********************************************************************
 * CreateInfoWnd - Procedure to create the info provider window.
 *
 * pwndParent     - Parent window for this window.
 * pszWindowTitle - Title for the info window.
 * pqszStrings    - Strings to be displayed in the info window.
 * fKeepFocus     - TRUE if this window should keep the focus.
 *
 * Returns:  PWND if creating Info Window was successful, NULL if an
 *           error occured.
 *********************************************************************/

STATIC PWND CreateInfoWnd (PSZ  pszWindowTitle,
                           QSZ  *pqszStrings,
                           BOOL fKeepFocus)
{
  PWND pwndInfoFrame = NULL;  /* Handle to the info window's frame      */
  PWND pwndInfoTxt = NULL;    /* Text window handle                     */
  PWND pwndScrollBar = NULL;  /* Handle to the scroll bar               */
  WORD wNmbrLines;            /* Number of lines in this string array   */
  WORD wLongestLine = 0;      /* The length of the longest line         */
  WORD wLength;               /* The length of the current line         */
  AX   axRight;               /* Coordinates for the upper left corner  */
  AY   ayTop;                 /*   of the info window.                  */
  AX   axWidth;               /* Size of the info window                */
  AY   ayHeight;
  PSZ  pszNewWindowTitle;     /* New location (malloc'ed) for the title */

  /* Determine the number of lines and the length of the longest line */

  for (wNmbrLines = 0; pqszStrings[wNmbrLines] != NULL; ++wNmbrLines)
    {
      if ((wLength = DisplayLen (pqszStrings[wNmbrLines])) > wLongestLine)
        wLongestLine = wLength;
    }

  /* Calculate the size of the window */

  if (wNmbrLines > (WORD) ayMac - 7)
    {
      ayHeight = ayMac - (AY) 2;
      axWidth  = (wLongestLine + 5> (WORD) axMac - 6) ?
                 axMac - (AX) 2 : (AX) wLongestLine + (AX) 5;
      fVisibleFlag = TRUE;
    }
  else
    {
      ayHeight = (AY) wNmbrLines + (AY) 5;
      axWidth  = (wLongestLine + 4> (WORD) axMac - 6) ?
                 axMac - (AX) 2 : (AX) wLongestLine + (AX) 4;
      fVisibleFlag = FALSE;
    }


  /* Calculate the coordinates of the info window */

  axRight = (AX) ((axMac / 2) - (axWidth / 2));
  ayTop   = (AY) ((ayMac / 2) - (ayHeight / 2));

  /* Copy the window title */

  pszNewWindowTitle = malloc (strlen (pszWindowTitle) + 1);
  if (pszNewWindowTitle == NULL)
    return (NULL);
  strcpy (pszNewWindowTitle, pszWindowTitle);


  /* Create the window */

  pwndInfoFrame = (PWND) CreateWindow (InfoWndCallID,
                                       NULL,
                                       WS_CLIPOUT | WS_BORDER |
                                         WS_OVERLAP /* | WS_VSCROLL */ ,
                                       WS_FRAME | WES_SHADOW |
                                         WES_OWNERREDRAW,
                                       axRight,
                                       ayTop,
                                       axWidth,
                                       ayHeight,
                                       (HWND) pwndMainFrame,
                                       (HMENU) NULL,
                                       NULL,
                                       1);

  if (pwndInfoFrame == NULL)
    return (NULL);

  /* Get the Info Text window's window handle */
  pwndInfoTxt = GetDlgItem (pwndInfoFrame, InfoTxtID);

  /* Set the pointer to the button's name */
  SetWindowWord (pwndInfoFrame, WEB_WINDOW_TITLE, (WORD) pszNewWindowTitle);

  /* Set the scroll bar's minimum value in the extra bytes */
  SetWindowWord (pwndInfoTxt, WEB_MIN_SCROLL, 0);

  /* Set the scroll bar's maximum value in the extra bytes */
  SetWindowWord (pwndInfoTxt, WEB_MAX_SCROLL, wNmbrLines - (ayHeight - 5));

  /* Set the total number of lines in this string array */
  SetWindowWord (pwndInfoTxt, WEB_NMBR_LINES, wNmbrLines);

  /* Set the number of scrollable lines in the window */
  SetWindowWord (pwndInfoTxt, WEB_SCROLLABLE_LINES, (WORD) ayHeight - 5);

  /* Set the pointer to the text to display */
  SetWindowWord (pwndInfoTxt, WEB_PQSZ_TEXT, (WORD) pqszStrings);

  /* Set the flag on wether this window should keep the focus or not */
  SetWindowWord (pwndInfoTxt, WEB_KEEP_FOCUS, (WORD) fKeepFocus);

  /* Set the ranges for the scroll bar */
  pwndScrollBar = GetDlgItem (pwndInfoTxt, InfoScrollID);

  SetScrollRange (pwndScrollBar,                /* Handle to scroll bar */
                  0,                            /* Minimum scroll value */
                  wNmbrLines - (ayHeight - 5),  /* Maximum scroll value */
                  FALSE);                       /* Redraws when TRUE */

  SetScrollPos (pwndScrollBar,     /* Handle to scroll bar */
                0,                 /* New scroll bar position */
                FALSE);            /* Redraws when TRUE */

  EnableWindow (pwndInfoFrame, TRUE);

  ShowWindow (pwndInfoFrame, SW_VISIBLE, TRUE);

  /* Hide the scroll bar if it is not necessary */

  if (fVisibleFlag == FALSE)
    ShowWindow (pwndScrollBar, SW_INVISIBLE, TRUE);

  /* Set the focus to the OK button */
  SetFocus (pwndInfoFrame);

  return (pwndInfoFrame);
}

/*********************************************************************
 * InfoWndProc - Procedure for handling the "Information Provider"
 *               window.
 *********************************************************************/

STATIC LONG FAR PASCAL InfoWndProc (PWND  pwnd,
                                    WORD  message,
                                    WORD  wParam,
                                    DWORD lParam)
{
  switch (message)
    {
      case WM_CREATE:
        CreateInfoChildWindows (pwnd);
        break;

#if 0
      case WM_ACTIVATE:
        {
          PWND pwndInfoTxt = NULL;   /* Handle to the text window */

          /* Get the window handles */
          pwndInfoTxt   = GetDlgItem (pwnd, InfoTxtWndCallID);

          if (GetWindowWord (pwndInfoTxt, WEB_KEEP_FOCUS))
            return (rspActiveDecline);
          else
            return (rspActiveLive);
          break;
        }
#endif

      case WM_COMMAND:

        /* Close window when OK button clicked */

        if (HIWORD (lParam) == BN_CLICKED && wParam == OkButtonID)
          PostMessage (pwnd, WM_CLOSE, NULL, NULL);
        break;

      case WM_CLOSE:
        {
#if HEAP_DEBUG
          _heapset ('W');
#endif

          /* Free up the window title */
          free ((PSZ) GetWindowWord (pwnd, WEB_WINDOW_TITLE));

#if HEAP_DEBUG
          _heapset ('X');
#endif

          /* Inform the summary window that we are shutting down */
          SendMessage (pwnd->pwndParent, WM_INFO_WND_CLOSED, (WORD) pwnd,
                       NULL);

          /* Destroy this info window */
          DestroyWindow (pwnd);
          break;
        }

      case WM_FRAMEDRAW:
        {
          RRC rrc;  /* Relative rectangle of window */

          GetClientRrc (pwnd, &rrc);

          DrawBorderAlign (pwnd,
                           pboxInfoBox,
                           isaInfoActiveBorder,
                           isaInfoActiveBorder,
                           (PSZ) GetWindowWord (pwnd, WEB_WINDOW_TITLE),
                           TRUE);

          if (FIsTopWindow(pwnd))
            DrawOverlapShadow (pwnd);

          CharOutBorder (pwnd,
                         0,
                         (RY) (rrc.ryBottom - 2),
                         '

⌨️ 快捷键说明

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