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

📄 refermain.cpp

📁 《C++ Builder 5技术内幕》一书附带的程序源代码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
//  MB_SETFOREGROUND
//  The message box becomes the foreground window. Internally, Windows
//  calls the SetForegroundWindow function for the message box.

//  MB_TOPMOST
//  The message box is created with the WS_EX_TOPMOST window style.

//  MB_SERVICE_NOTIFICATION
//  Windows NT only: The caller is a service notifying the user of an event.
//  The function displays a message box on the current active desktop,
//  even if there is no user logged on to the computer.
//  If this flag is set, the hWnd parameter must be NULL. This is
//  so the message box can appear on a desktop other than the desktop
//  corresponding to the hWnd.
//  For Windows NT version 4.0, the value of MB_SERVICE_NOTIFICATION has
//  changed. See WINUSER.H for the old and new values. Windows NT 4.0
//  provides backward compatibility for pre-existing services
//  by mapping the old value to the new value in the implementation of
//  MessageBox and MessageBoxEx. This mapping is only done for executables
//  that have a version number, as set by the linker, less than 4.0.

//  To build a service that uses MB_SERVICE_NOTIFICATION, and can run on
//  both Windows NT 3.x and Windows NT 4.0, you have two choices.

//  1.	At link-time, specify a version number less than 4.0; or
//  2.	At link-time, specify version 4.0. At run-time,
//  use the GetVersionEx function to check the system version.
//  Then when running on Windows NT 3.x, use MB_SERVICE_NOTIFICATION_NT3X;
//  and on Windows NT 4.0, use MB_SERVICE_NOTIFICATION.

//  MB_SERVICE_NOTIFICATION_NT3X

//  Windows NT only: This value corresponds to the value defined for
//  MB_SERVICE_NOTIFICATION for Windows NT version 3.51.

//  Return Values

//  The return value is zero if there is not enough memory to create
//  the message box.
//  If the function succeeds, the return value is one of the following
//  menu-item values returned by the dialog box:

//  Value	    Meaning
//  IDABORT	    Abort button was selected.
//  IDCANCEL	Cancel button was selected.
//  IDIGNORE	Ignore button was selected.
//  IDNO	    No button was selected.
//  IDOK    	OK button was selected.
//  IDRETRY	    Retry button was selected.
//  IDYES	    Yes button was selected.


//  If a message box has a Cancel button, the function returns
//  the IDCANCEL value if either the ESC key is pressed or
//  the Cancel button is selected. If the message box has no Cancel button,
//  pressing ESC has no effect.

//  Remarks

//  When you use a system-modal message box to indicate that the system
//  is low on memory, the strings pointed to by the lpText and
//  lpCaption parameters should not be taken from a resource file,
//  because an attempt to load the resource may fail.
//  When an application calls MessageBox and specifies the MB_ICONHAND
//  and MB_SYSTEMMODAL flags for the uType parameter, Windows displays
//  the resulting message box regardless of available memory.
//  When these flags are specified, Windows limits the length of
//  the message box text to three lines. Windows does not automatically
//  break the lines to fit in the message box, however,
//  so the message string must contain carriage returns to
//  break the lines at the appropriate places.

//  If you create a message box while a dialog box is present,
//  use the handle of the dialog box as the hWnd parameter.
//  The hWnd parameter should not identify a child window, such as
//  a control in a dialog box.
//  Windows 95: The system can support a maximum of 16,364 window handles.
}
//---------------------------------------------------------------------------

void __fastcall TMainFormRefer::ToolButtonPageModifyClick(TObject *Sender)
{
// Change toolbar into Page Search.
// Some tool-buttons - Criteria, Find, Save, Output, Last, must be visible;
// Other tool-buttons - Append, Insert, Change, Delete, Pack must be invisible.
  MenuItemOptionsPageSearch->Checked = false;
  MenuItemOptionsPageModify->Checked = true;
  ToolButtonPack->Visible = true;
  ToolButtonLast->Visible = false;
  ToolButtonDelete->Visible = true;
  ToolButtonOutput->Visible = false;
  ToolButtonChange->Visible = true;
  ToolButtonSave->Visible = false;
  ToolButtonAppend->Visible = true;
  ToolButtonFind->Visible = false;
  ToolButtonInsert->Visible = true;
  ToolButtonCriteria->Visible = false;
  ToolButtonPageSearch->Visible = true;
  ToolButtonPageModify->Visible = false;
}
//---------------------------------------------------------------------------

void __fastcall TMainFormRefer::ToolButtonPageSearchClick(TObject *Sender)
{
// Change toolbar into Page Search.
// Some tool-buttons - Criteria, Find, Save, Output, Last, must be visible;
// Other tool-buttons - Append, Insert, Change, Delete, Pack must be invisible.
  MenuItemOptionsPageSearch->Checked = true;
  MenuItemOptionsPageModify->Checked = false;
  ToolButtonPack->Visible = false;
  ToolButtonLast->Visible = true;
  ToolButtonDelete->Visible = false;
  ToolButtonOutput->Visible = true;
  ToolButtonChange->Visible = false;
  ToolButtonSave->Visible = true;
  ToolButtonAppend->Visible = false;
  ToolButtonFind->Visible = true;
  ToolButtonInsert->Visible = false;
  ToolButtonCriteria->Visible = true;
  ToolButtonPageSearch->Visible = false;
  ToolButtonPageModify->Visible = true;
}
//---------------------------------------------------------------------------

void __fastcall TMainFormRefer::MenuItemOptionsPageModifyClick(
      TObject *Sender)
{
// Change toolbar into Page Search.
// Some tool-buttons - Criteria, Find, Save, Output, Last, must be visible;
// Other tool-buttons - Append, Insert, Change, Delete, Pack must be invisible.
  MenuItemOptionsPageSearch->Checked = false;
  MenuItemOptionsPageModify->Checked = true;
  ToolButtonPack->Visible = true;
  ToolButtonLast->Visible = false;
  ToolButtonDelete->Visible = true;
  ToolButtonOutput->Visible = false;
  ToolButtonChange->Visible = true;
  ToolButtonSave->Visible = false;
  ToolButtonAppend->Visible = true;
  ToolButtonFind->Visible = false;
  ToolButtonInsert->Visible = true;
  ToolButtonCriteria->Visible = false;
  ToolButtonPageSearch->Visible = true;
  ToolButtonPageModify->Visible = false;
}
//---------------------------------------------------------------------------

void __fastcall TMainFormRefer::MenuItemOptionsPageSearchClick(
      TObject *Sender)
{
// Change toolbar into Page Search.
// Some tool-buttons - Criteria, Find, Save, Output, Last, must be visible;
// Other tool-buttons - Append, Insert, Change, Delete, Pack must be invisible.
  MenuItemOptionsPageSearch->Checked = true;
  MenuItemOptionsPageModify->Checked = false;
  ToolButtonPack->Visible = false;
  ToolButtonLast->Visible = true;
  ToolButtonDelete->Visible = false;
  ToolButtonOutput->Visible = true;
  ToolButtonChange->Visible = false;
  ToolButtonSave->Visible = true;
  ToolButtonAppend->Visible = false;
  ToolButtonFind->Visible = true;
  ToolButtonInsert->Visible = false;
  ToolButtonCriteria->Visible = true;
  ToolButtonPageSearch->Visible = false;
  ToolButtonPageModify->Visible = true;
}
//---------------------------------------------------------------------------

void __fastcall TMainFormRefer::MenuItemOptionsModifyingClick(
      TObject *Sender)
{
// Show in status bar.
  StatusBar->Panels->Items[2]->Text = "Modifying";
// Set searching flag to false.
  m_bSearching = false;
// Change toolbar into Page Search.
// Some tool-buttons - Criteria, Find, Save, Output, Last, must be visible;
// Other tool-buttons - Append, Insert, Change, Delete, Pack must be invisible.
  MenuItemOptionsSearching->Checked = false;
  MenuItemOptionsModifying->Checked = true;
  MenuItemOptionsPageSearch->Checked = false;
  MenuItemOptionsPageModify->Checked = true;
  MenuItemDatabasePack->Enabled = true;
  ToolButtonPack->Enabled = true;
  ToolButtonPack->Visible = true;
  ToolButtonLast->Visible = false;
  MenuItemDatabaseDelete->Enabled = true;
  ToolButtonDelete->Enabled = true;
  ToolButtonDelete->Visible = true;
  ToolButtonOutput->Visible = false;
  MenuItemDatabaseChange->Enabled = true;
  ToolButtonChange->Enabled = true;
  ToolButtonChange->Visible = true;
  ToolButtonSave->Visible = false;
  MenuItemDatabaseAppend->Enabled = true;
  ToolButtonAppend->Enabled = true;
  ToolButtonAppend->Visible = true;
  ToolButtonFind->Visible = false;
  MenuItemDatabaseInsert->Enabled = true;
  ToolButtonInsert->Enabled = true;
  ToolButtonInsert->Visible = true;
  ToolButtonCriteria->Visible = false;
  ToolButtonPageSearch->Visible = true;
  ToolButtonPageModify->Visible = false;
}
//---------------------------------------------------------------------------

void __fastcall TMainFormRefer::MenuItemOptionsSearchingClick(TObject *Sender)
{
// Show in status bar.
  StatusBar->Panels->Items[2]->Text = "Searching";
// Set searching flag to false.
  m_bSearching = true;
// Change toolbar into Page Search.
// Some tool-buttons - Criteria, Find, Save, Output, Last, must be visible;
// Other tool-buttons - Append, Insert, Change, Delete, Pack must be invisible.
//  ToolButtonPack->Indeterminate = true;
  MenuItemOptionsSearching->Checked = true;
  MenuItemOptionsModifying->Checked = false;
  MenuItemOptionsPageSearch->Checked = true;
  MenuItemOptionsPageModify->Checked = false;
  MenuItemDatabasePack->Enabled = false;
  ToolButtonPack->Enabled = false;
  ToolButtonPack->Visible = false;
  ToolButtonLast->Visible = true;
  MenuItemDatabaseDelete->Enabled = false;
  ToolButtonDelete->Enabled = false;
  ToolButtonDelete->Visible = false;
  ToolButtonOutput->Visible = true;
  MenuItemDatabaseChange->Enabled = false;
  ToolButtonChange->Enabled = false;
  ToolButtonChange->Visible = false;
  ToolButtonSave->Visible = true;
  MenuItemDatabaseAppend->Enabled = false;
  ToolButtonAppend->Enabled = false;
  ToolButtonAppend->Visible = false;
  ToolButtonFind->Visible = true;
  MenuItemDatabaseInsert->Enabled = false;
  ToolButtonInsert->Enabled = false;
  ToolButtonInsert->Visible = false;
  ToolButtonCriteria->Visible = true;
  ToolButtonPageSearch->Visible = false;
  ToolButtonPageModify->Visible = true;
}
//---------------------------------------------------------------------------

void __fastcall TMainFormRefer::FormClose(TObject *Sender, TCloseAction &Action)
{
//  If m_prsReferenceStream is not NULL, that is, some elements exist.
  if( m_prsReferenceStream != NULL )
  {
//  Release memory pointed to by m_prsReferenceStream.
    delete m_prsReferenceStream;
    m_prsReferenceStream = NULL;
  }
//  If m_prlReferList is not NULL, that is, some items exist.
  if( m_prlReferList != NULL )
  {
//  Release memory pointed to by m_prlReferList.
    for ( int i=0; i<m_prlReferList->Count; i++ )
    {
//  Release memory pointed to by every items, first.
      TReferRecord *prrDeleting = ( TReferRecord * )( m_prlReferList->Items[i] );
      if ( prrDeleting != NULL )
      {
        delete prrDeleting;
        prrDeleting = NULL;
      }
    }
//  Release memory pointed to by m_prlReferList, per se.
    delete m_prlReferList;
    m_prlReferList = NULL;
  }
//  If m_prlSearchedReferList is not NULL, that is, some items exist.
  if( m_prlSearchedReferList != NULL )
  {
//  Release memory pointed to by m_prlSearchedReferList.
    for ( int i=0; i<m_prlSearchedReferList->Count; i++ )
    {
//  Release memory pointed to by every items, first.
      TReferRecord *prrDeleting = ( TReferRecord * )( m_prlSearchedReferList->Items[i] );
      if ( prrDeleting != NULL )
      {
        delete prrDeleting;
        prrDeleting = NULL;
      }
    }
//  Release memory pointed to by m_prlSearchedReferList, per se.
    delete m_prlSearchedReferList;
    m_prlSearchedReferList = NULL;
  }
}
//---------------------------------------------------------------------------

void __fastcall TMainFormRefer::ToolButtonFirstClick(TObject *Sender)
{
//  if( m_bModified )

⌨️ 快捷键说明

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