QueryOptionsDlg.cpp
上传用户:jsxglz
上传日期:2007-01-03
资源大小:117k
文件大小:3k
源码类别:

SQL Server

开发平台:

Visual C++

  1. // QueryOptionsDlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "interactivesql.h"
  5. #include "QueryOptionsDlg.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. const char* g_szQueryOptions = "QueryOptions";
  12. const char* g_szThreadPriority = "ThreadPriority";
  13. const char* g_szTimeCritical = "Time critical";
  14. const char* g_szHighest = "Highest";
  15. const char* g_szAboveNormal = "Above Normal";
  16. const char* g_szNormal = "Normal";
  17. const char* g_szBelowNormal = "Below Normal";
  18. const char* g_szLowest = "Lowest";
  19. /////////////////////////////////////////////////////////////////////////////
  20. // CQueryOptionsDlg dialog
  21. CQueryOptionsDlg::CQueryOptionsDlg(CWnd* pParent /*=NULL*/)
  22. : CDialog(CQueryOptionsDlg::IDD, pParent)
  23. {
  24. //{{AFX_DATA_INIT(CQueryOptionsDlg)
  25. //}}AFX_DATA_INIT
  26. }
  27. void CQueryOptionsDlg::DoDataExchange(CDataExchange* pDX)
  28. {
  29. CDialog::DoDataExchange(pDX);
  30. //{{AFX_DATA_MAP(CQueryOptionsDlg)
  31. DDX_Control(pDX, IDC_EXECUTION_PRIORITY, m_cbThreadPriority);
  32. //}}AFX_DATA_MAP
  33. }
  34. BEGIN_MESSAGE_MAP(CQueryOptionsDlg, CDialog)
  35. //{{AFX_MSG_MAP(CQueryOptionsDlg)
  36. ON_BN_CLICKED(IDC_RESET, OnReset)
  37. //}}AFX_MSG_MAP
  38. END_MESSAGE_MAP()
  39. /////////////////////////////////////////////////////////////////////////////
  40. // CQueryOptionsDlg message handlers
  41. void CQueryOptionsDlg::OnReset() 
  42. {
  43. m_cbThreadPriority.SelectString(-1, g_szNormal);
  44. UpdateData(FALSE);
  45. }
  46. BOOL CQueryOptionsDlg::OnInitDialog() 
  47. {
  48. CDialog::OnInitDialog();
  49. m_cbThreadPriority.SetItemData(
  50. m_cbThreadPriority.AddString(g_szTimeCritical),
  51. THREAD_PRIORITY_TIME_CRITICAL);
  52. m_cbThreadPriority.SetItemData(
  53. m_cbThreadPriority.AddString(g_szHighest),
  54. THREAD_PRIORITY_HIGHEST);
  55. m_cbThreadPriority.SetItemData(
  56. m_cbThreadPriority.AddString(g_szAboveNormal),
  57. THREAD_PRIORITY_ABOVE_NORMAL);
  58. m_cbThreadPriority.SetItemData(
  59. m_cbThreadPriority.AddString(g_szNormal),
  60. THREAD_PRIORITY_NORMAL);
  61. m_cbThreadPriority.SetItemData(
  62. m_cbThreadPriority.AddString(g_szBelowNormal),
  63. THREAD_PRIORITY_BELOW_NORMAL);
  64. m_cbThreadPriority.SetItemData(
  65. m_cbThreadPriority.AddString(g_szLowest),
  66. THREAD_PRIORITY_LOWEST);
  67. m_strThreadPriority = AfxGetApp()->GetProfileString(g_szQueryOptions, g_szThreadPriority);
  68. m_strThreadPriority.TrimRight(); 
  69. m_strThreadPriority.TrimLeft();
  70. if(m_strThreadPriority.IsEmpty())
  71. m_strThreadPriority = g_szNormal;
  72. m_cbThreadPriority.SelectString(-1, m_strThreadPriority);
  73. return TRUE;  // return TRUE unless you set the focus to a control
  74.               // EXCEPTION: OCX Property Pages should return FALSE
  75. }
  76. void CQueryOptionsDlg::OnOK() 
  77. {
  78. UpdateData(TRUE);
  79. m_cbThreadPriority.GetWindowText(m_strThreadPriority);
  80. AfxGetApp()->WriteProfileString(g_szQueryOptions, g_szThreadPriority, m_strThreadPriority);
  81. CDialog::OnOK();
  82. }