CMakeSetupDialog.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673
  1. // pcbuilderdialogDlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "CMakeSetup.h"
  5. #include "PathDialog.h"
  6. #include "CMakeSetupDialog.h"
  7. #include "../cmCacheManager.h"
  8. #include "../cmake.h"
  9. #ifdef _DEBUG
  10. #define new DEBUG_NEW
  11. #undef THIS_FILE
  12. static char THIS_FILE[] = __FILE__;
  13. #endif
  14. /////////////////////////////////////////////////////////////////////////////
  15. // CAboutDlg dialog used for App About
  16. class CAboutDlg : public CDialog
  17. {
  18. public:
  19. CAboutDlg();
  20. // Dialog Data
  21. //{{AFX_DATA(CAboutDlg)
  22. enum { IDD = IDD_ABOUTBOX };
  23. //}}AFX_DATA
  24. // ClassWizard generated virtual function overrides
  25. //{{AFX_VIRTUAL(CAboutDlg)
  26. protected:
  27. virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
  28. //}}AFX_VIRTUAL
  29. // Implementation
  30. protected:
  31. //{{AFX_MSG(CAboutDlg)
  32. //}}AFX_MSG
  33. DECLARE_MESSAGE_MAP()
  34. };
  35. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  36. {
  37. //{{AFX_DATA_INIT(CAboutDlg)
  38. //}}AFX_DATA_INIT
  39. }
  40. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  41. {
  42. CDialog::DoDataExchange(pDX);
  43. //{{AFX_DATA_MAP(CAboutDlg)
  44. //}}AFX_DATA_MAP
  45. }
  46. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  47. //{{AFX_MSG_MAP(CAboutDlg)
  48. // No message handlers
  49. //}}AFX_MSG_MAP
  50. END_MESSAGE_MAP();
  51. /////////////////////////////////////////////////////////////////////////////
  52. // CMakeSetupDialog dialog
  53. CMakeSetupDialog::CMakeSetupDialog(CWnd* pParent /*=NULL*/)
  54. : CDialog(CMakeSetupDialog::IDD, pParent)
  55. {
  56. m_RegistryKey = "Software\\Kitware\\CMakeSetup\\Settings\\StartPath";
  57. //{{AFX_DATA_INIT(CMakeSetupDialog)
  58. m_WhereBuild = _T("");
  59. m_WhereSource = _T("");
  60. //}}AFX_DATA_INIT
  61. // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
  62. m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
  63. m_BuildPathChanged = false;
  64. // Find the path to the cmake.exe executable
  65. char fname[1024];
  66. ::GetModuleFileName(NULL,fname,1023);
  67. // extract just the path part
  68. m_PathToExecutable = cmSystemTools::GetProgramPath(fname).c_str();
  69. // add the cmake.exe to the path
  70. m_PathToExecutable += "/cmake.exe";
  71. m_oldCX = -1;
  72. m_deltaXRemainder = 0;
  73. }
  74. void CMakeSetupDialog::DoDataExchange(CDataExchange* pDX)
  75. {
  76. CDialog::DoDataExchange(pDX);
  77. //{{AFX_DATA_MAP(CMakeSetupDialog)
  78. DDX_Control(pDX, IDOK, m_CancelButton);
  79. DDX_Control(pDX, IDC_MouseHelpCaption, m_MouseHelp);
  80. DDX_Control(pDX, IDC_CMAKE_VERSION, m_VersionDisplay);
  81. DDX_Control(pDX, IDC_BuildProjects, m_BuildProjects);
  82. DDX_Control(pDX, IDC_FRAME, m_ListFrame);
  83. DDX_Control(pDX, IDC_WhereSource, m_WhereSourceControl);
  84. DDX_Control(pDX, IDC_WhereBuild, m_WhereBuildControl);
  85. DDX_Control(pDX, IDC_LIST2, m_CacheEntriesList);
  86. DDX_CBStringExact(pDX, IDC_WhereBuild, m_WhereBuild);
  87. DDX_CBStringExact(pDX, IDC_WhereSource, m_WhereSource);
  88. //}}AFX_DATA_MAP
  89. }
  90. BEGIN_MESSAGE_MAP(CMakeSetupDialog, CDialog)
  91. //{{AFX_MSG_MAP(CMakeSetupDialog)
  92. ON_WM_SYSCOMMAND()
  93. ON_WM_PAINT()
  94. ON_WM_QUERYDRAGICON()
  95. ON_BN_CLICKED(IDOK, OnOK)
  96. ON_BN_CLICKED(IDC_BuildProjects, OnBuildProjects)
  97. ON_CBN_EDITCHANGE(IDC_WhereBuild, OnChangeWhereBuild)
  98. ON_CBN_EDITCHANGE(IDC_WhereSource, OnChangeWhereSource)
  99. ON_CBN_SELCHANGE(IDC_WhereBuild, OnSelendokWhereBuild)
  100. ON_BN_CLICKED(IDC_BUTTON2, OnBrowseWhereSource)
  101. ON_BN_CLICKED(IDC_BUTTON3, OnBrowseWhereBuild)
  102. ON_CBN_SELENDOK(IDC_WhereSource, OnSelendokWhereSource)
  103. ON_WM_SIZE()
  104. ON_WM_GETMINMAXINFO()
  105. //}}AFX_MSG_MAP
  106. END_MESSAGE_MAP()
  107. /////////////////////////////////////////////////////////////////////////////
  108. // CMakeSetupDialog message handlers
  109. BOOL CMakeSetupDialog::OnInitDialog()
  110. {
  111. CDialog::OnInitDialog();
  112. // Add "About..." menu item to system menu.
  113. // IDM_ABOUTBOX must be in the system command range.
  114. ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
  115. ASSERT(IDM_ABOUTBOX < 0xF000);
  116. CMenu* pSysMenu = GetSystemMenu(FALSE);
  117. if (pSysMenu != NULL)
  118. {
  119. CString strAboutMenu;
  120. strAboutMenu.LoadString(IDS_ABOUTBOX);
  121. if (!strAboutMenu.IsEmpty())
  122. {
  123. pSysMenu->AppendMenu(MF_SEPARATOR);
  124. pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
  125. }
  126. }
  127. // Set the icon for this dialog. The framework does this automatically
  128. // when the application's main window is not a dialog
  129. SetIcon(m_hIcon, TRUE); // Set big icon
  130. SetIcon(m_hIcon, FALSE); // Set small icon
  131. // Load source and build dirs from registry
  132. this->LoadFromRegistry();
  133. // try to load the cmake cache from disk
  134. this->LoadCacheFromDiskToGUI();
  135. m_WhereBuildControl.LimitText(2048);
  136. m_WhereSourceControl.LimitText(2048);
  137. // Set the version number
  138. char tmp[1024];
  139. sprintf(tmp,"Version %d.%d", cmMakefile::GetMajorVersion(),
  140. cmMakefile::GetMinorVersion());
  141. SetDlgItemText(IDC_CMAKE_VERSION, tmp);
  142. this->UpdateData(FALSE);
  143. return TRUE; // return TRUE unless you set the focus to a control
  144. }
  145. // About dialog invoke
  146. void CMakeSetupDialog::OnSysCommand(UINT nID, LPARAM lParam)
  147. {
  148. if ((nID & 0xFFF0) == IDM_ABOUTBOX)
  149. {
  150. CAboutDlg dlgAbout;
  151. dlgAbout.DoModal();
  152. }
  153. else
  154. {
  155. CDialog::OnSysCommand(nID, lParam);
  156. }
  157. }
  158. // If you add a minimize button to your dialog, you will need the code below
  159. // to draw the icon. For MFC applications using the document/view model,
  160. // this is automatically done for you by the framework.
  161. void CMakeSetupDialog::OnPaint()
  162. {
  163. if (IsIconic())
  164. {
  165. CPaintDC dc(this); // device context for painting
  166. SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
  167. // Center icon in client rectangle
  168. int cxIcon = GetSystemMetrics(SM_CXICON);
  169. int cyIcon = GetSystemMetrics(SM_CYICON);
  170. CRect rect;
  171. GetClientRect(&rect);
  172. int x = (rect.Width() - cxIcon + 1) / 2;
  173. int y = (rect.Height() - cyIcon + 1) / 2;
  174. // Draw the icon
  175. dc.DrawIcon(x, y, m_hIcon);
  176. }
  177. else
  178. {
  179. CDialog::OnPaint();
  180. }
  181. }
  182. // The system calls this to obtain the cursor to display while the user drags
  183. // the minimized window.
  184. HCURSOR CMakeSetupDialog::OnQueryDragIcon()
  185. {
  186. return (HCURSOR) m_hIcon;
  187. }
  188. // Browse button
  189. bool CMakeSetupDialog::Browse(CString &result, const char *title)
  190. {
  191. CPathDialog dlg("Select Path", title, result);
  192. if(dlg.DoModal()==IDOK)
  193. {
  194. result = dlg.GetPathName();
  195. return true;
  196. }
  197. else
  198. {
  199. return false;
  200. }
  201. }
  202. void CMakeSetupDialog::SaveToRegistry()
  203. {
  204. HKEY hKey;
  205. DWORD dwDummy;
  206. if(RegCreateKeyEx(HKEY_CURRENT_USER,
  207. m_RegistryKey,
  208. 0, "", REG_OPTION_NON_VOLATILE, KEY_READ|KEY_WRITE,
  209. NULL, &hKey, &dwDummy) != ERROR_SUCCESS)
  210. {
  211. return;
  212. }
  213. else
  214. {
  215. // load some values
  216. CString regvalue;
  217. this->ReadRegistryValue(hKey, &(regvalue),"WhereSource","C:\\");
  218. if(m_WhereSource != regvalue)
  219. {
  220. regvalue = "";
  221. this->ReadRegistryValue(hKey, &(regvalue),"WhereSource3","");
  222. RegSetValueEx(hKey, _T("WhereSource4"), 0, REG_SZ,
  223. (CONST BYTE *)(const char *)regvalue,
  224. regvalue.GetLength());
  225. regvalue = "";
  226. this->ReadRegistryValue(hKey, &(regvalue),"WhereSource2","");
  227. RegSetValueEx(hKey, _T("WhereSource3"), 0, REG_SZ,
  228. (CONST BYTE *)(const char *)regvalue,
  229. regvalue.GetLength());
  230. regvalue = "";
  231. this->ReadRegistryValue(hKey, &(regvalue),"WhereSource","");
  232. RegSetValueEx(hKey, _T("WhereSource2"), 0, REG_SZ,
  233. (CONST BYTE *)(const char *)regvalue,
  234. regvalue.GetLength());
  235. RegSetValueEx(hKey, _T("WhereSource"), 0, REG_SZ,
  236. (CONST BYTE *)(const char *)m_WhereSource,
  237. m_WhereSource.GetLength());
  238. }
  239. this->ReadRegistryValue(hKey, &(regvalue),"WhereBuild","C:\\");
  240. if(m_WhereBuild != regvalue)
  241. {
  242. regvalue = "";
  243. this->ReadRegistryValue(hKey, &(regvalue),"WhereBuild3","");
  244. RegSetValueEx(hKey, _T("WhereBuild4"), 0, REG_SZ,
  245. (CONST BYTE *)(const char *)regvalue,
  246. regvalue.GetLength());
  247. regvalue = "";
  248. this->ReadRegistryValue(hKey, &(regvalue),"WhereBuild2","");
  249. RegSetValueEx(hKey, _T("WhereBuild3"), 0, REG_SZ,
  250. (CONST BYTE *)(const char *)regvalue,
  251. regvalue.GetLength());
  252. regvalue = "";
  253. this->ReadRegistryValue(hKey, &(regvalue),"WhereBuild","");
  254. RegSetValueEx(hKey, _T("WhereBuild2"), 0, REG_SZ,
  255. (CONST BYTE *)(const char *)regvalue,
  256. regvalue.GetLength());
  257. RegSetValueEx(hKey, _T("WhereBuild"), 0, REG_SZ,
  258. (CONST BYTE *)(const char *)m_WhereBuild,
  259. m_WhereBuild.GetLength());
  260. }
  261. }
  262. RegCloseKey(hKey);
  263. }
  264. void CMakeSetupDialog::ReadRegistryValue(HKEY hKey,
  265. CString *val,
  266. const char *key,
  267. const char *adefault)
  268. {
  269. DWORD dwType, dwSize;
  270. char *pb;
  271. dwType = REG_SZ;
  272. pb = val->GetBuffer(MAX_PATH);
  273. dwSize = MAX_PATH;
  274. if(RegQueryValueEx(hKey,_T(key), NULL, &dwType,
  275. (BYTE *)pb, &dwSize) != ERROR_SUCCESS)
  276. {
  277. val->ReleaseBuffer();
  278. *val = _T(adefault);
  279. }
  280. else
  281. {
  282. val->ReleaseBuffer();
  283. }
  284. }
  285. void CMakeSetupDialog::LoadFromRegistry()
  286. {
  287. HKEY hKey;
  288. if(RegOpenKeyEx(HKEY_CURRENT_USER,
  289. m_RegistryKey,
  290. 0, KEY_READ, &hKey) != ERROR_SUCCESS)
  291. {
  292. return;
  293. }
  294. else
  295. {
  296. // load some values
  297. this->ReadRegistryValue(hKey, &(m_WhereSource),"WhereSource","C:\\");
  298. this->ReadRegistryValue(hKey, &(m_WhereBuild),"WhereBuild","C:\\");
  299. m_WhereSourceControl.AddString(m_WhereSource);
  300. m_WhereBuildControl.AddString(m_WhereBuild);
  301. CString regvalue;
  302. this->ReadRegistryValue(hKey, &(regvalue),"WhereSource2","C:\\");
  303. m_WhereSourceControl.AddString(regvalue);
  304. regvalue = "";
  305. this->ReadRegistryValue(hKey, &(regvalue),"WhereBuild2","C:\\");
  306. m_WhereBuildControl.AddString(regvalue);
  307. regvalue = "";
  308. this->ReadRegistryValue(hKey, &(regvalue),"WhereSource3","C:\\");
  309. m_WhereSourceControl.AddString(regvalue);
  310. regvalue = "";
  311. this->ReadRegistryValue(hKey, &(regvalue),"WhereBuild3","C:\\");
  312. m_WhereBuildControl.AddString(regvalue);
  313. regvalue = "";
  314. this->ReadRegistryValue(hKey, &(regvalue),"WhereSource4","C:\\");
  315. m_WhereSourceControl.AddString(regvalue);
  316. regvalue = "";
  317. this->ReadRegistryValue(hKey, &(regvalue),"WhereBuild4","C:\\");
  318. m_WhereBuildControl.AddString(regvalue);
  319. }
  320. RegCloseKey(hKey);
  321. }
  322. // Callback for browse source button
  323. void CMakeSetupDialog::OnBrowseWhereSource()
  324. {
  325. this->UpdateData();
  326. Browse(m_WhereSource, "Enter Path to Source");
  327. this->UpdateData(false);
  328. this->OnChangeWhereSource();
  329. }
  330. // Callback for browser build button
  331. void CMakeSetupDialog::OnBrowseWhereBuild()
  332. {
  333. this->UpdateData();
  334. Browse(m_WhereBuild, "Enter Path to Build");
  335. this->UpdateData(false);
  336. this->OnChangeWhereBuild();
  337. }
  338. // Callback for build projects button
  339. void CMakeSetupDialog::OnBuildProjects()
  340. {
  341. if(!cmSystemTools::FileExists(m_WhereBuild))
  342. {
  343. std::string message =
  344. "Build directory does not exist, should I create it?\n\n"
  345. "Directory: ";
  346. message += (const char*)m_WhereBuild;
  347. if(MessageBox(message.c_str(), "Create Directory", MB_OKCANCEL) == IDOK)
  348. {
  349. cmSystemTools::MakeDirectory(m_WhereBuild);
  350. }
  351. else
  352. {
  353. MessageBox("Build Project aborted, nothing done.");
  354. return;
  355. }
  356. }
  357. // set the wait cursor
  358. ::SetCursor(LoadCursor(NULL, IDC_WAIT));
  359. // get all the info from the dialog
  360. this->UpdateData();
  361. if(!m_BuildPathChanged)
  362. {
  363. // if the build path has not changed save the
  364. // current GUI values to the cache
  365. this->SaveCacheFromGUI();
  366. }
  367. // Make sure we are working from the cache on disk
  368. this->LoadCacheFromDiskToGUI();
  369. // create a cmake object
  370. cmake make;
  371. // create the arguments for the cmake object
  372. std::vector<std::string> args;
  373. args.push_back((const char*)m_PathToExecutable);
  374. std::string arg;
  375. arg = "-H";
  376. arg += m_WhereSource;
  377. args.push_back(arg);
  378. arg = "-B";
  379. arg += m_WhereBuild;
  380. args.push_back(arg);
  381. // run the generate process
  382. if(make.Generate(args) != 0)
  383. {
  384. cmSystemTools::Error(
  385. "Error in generation process, project files may be invalid");
  386. cmSystemTools::ResetErrorOccuredFlag();
  387. }
  388. // update the GUI with any new values in the caused by the
  389. // generation process
  390. this->LoadCacheFromDiskToGUI();
  391. // save source and build paths to registry
  392. this->SaveToRegistry();
  393. // path is up-to-date now
  394. m_BuildPathChanged = false;
  395. // put the cursor back
  396. ::SetCursor(LoadCursor(NULL, IDC_ARROW));
  397. m_CacheEntriesList.ClearDirty();
  398. }
  399. // callback for combo box menu where build selection
  400. void CMakeSetupDialog::OnSelendokWhereBuild()
  401. {
  402. m_WhereBuildControl.GetLBText(m_WhereBuildControl.GetCurSel(),
  403. m_WhereBuild);
  404. m_WhereBuildControl.SetWindowText( m_WhereBuild);
  405. this->UpdateData(FALSE);
  406. this->OnChangeWhereBuild();
  407. }
  408. // callback for combo box menu where source selection
  409. void CMakeSetupDialog::OnSelendokWhereSource()
  410. {
  411. m_WhereSourceControl.GetLBText(m_WhereSourceControl.GetCurSel(),
  412. m_WhereSource);
  413. this->UpdateData(FALSE);
  414. this->OnChangeWhereSource();
  415. }
  416. // callback for chaing source directory
  417. void CMakeSetupDialog::OnChangeWhereSource()
  418. {
  419. }
  420. // callback for changing the build directory
  421. void CMakeSetupDialog::OnChangeWhereBuild()
  422. {
  423. this->UpdateData();
  424. m_CacheEntriesList.RemoveAll();
  425. m_CacheEntriesList.ShowWindow(SW_SHOW);
  426. this->LoadCacheFromDiskToGUI();
  427. m_BuildPathChanged = true;
  428. }
  429. // copy from the cache manager to the cache edit list box
  430. void CMakeSetupDialog::FillCacheGUIFromCacheManager()
  431. {
  432. const cmCacheManager::CacheEntryMap &cache =
  433. cmCacheManager::GetInstance()->GetCacheMap();
  434. for(cmCacheManager::CacheEntryMap::const_iterator i = cache.begin();
  435. i != cache.end(); ++i)
  436. {
  437. const char* key = i->first.c_str();
  438. const cmCacheManager::CacheEntry& value = i->second;
  439. switch(value.m_Type )
  440. {
  441. case cmCacheManager::BOOL:
  442. if(cmCacheManager::GetInstance()->IsOn(key))
  443. {
  444. m_CacheEntriesList.AddProperty(key,
  445. "ON",
  446. value.m_HelpString.c_str(),
  447. CPropertyList::CHECKBOX,"");
  448. }
  449. else
  450. {
  451. m_CacheEntriesList.AddProperty(key,
  452. "OFF",
  453. value.m_HelpString.c_str(),
  454. CPropertyList::CHECKBOX,"");
  455. }
  456. break;
  457. case cmCacheManager::PATH:
  458. m_CacheEntriesList.AddProperty(key,
  459. value.m_Value.c_str(),
  460. value.m_HelpString.c_str(),
  461. CPropertyList::PATH,"");
  462. break;
  463. case cmCacheManager::FILEPATH:
  464. m_CacheEntriesList.AddProperty(key,
  465. value.m_Value.c_str(),
  466. value.m_HelpString.c_str(),
  467. CPropertyList::FILE,"");
  468. break;
  469. case cmCacheManager::STRING:
  470. m_CacheEntriesList.AddProperty(key,
  471. value.m_Value.c_str(),
  472. value.m_HelpString.c_str(),
  473. CPropertyList::EDIT,"");
  474. break;
  475. case cmCacheManager::INTERNAL:
  476. break;
  477. }
  478. }
  479. }
  480. // copy from the list box to the cache manager
  481. void CMakeSetupDialog::FillCacheManagerFromCacheGUI()
  482. {
  483. cmCacheManager::GetInstance()->GetCacheMap();
  484. std::set<CPropertyItem*> items = m_CacheEntriesList.GetItems();
  485. for(std::set<CPropertyItem*>::iterator i = items.begin();
  486. i != items.end(); ++i)
  487. {
  488. CPropertyItem* item = *i;
  489. cmCacheManager::CacheEntry *entry =
  490. cmCacheManager::GetInstance()->GetCacheEntry(
  491. (const char*)item->m_propName);
  492. if (entry)
  493. {
  494. entry->m_Value = item->m_curValue;
  495. }
  496. }
  497. }
  498. //! Load cache file from m_WhereBuild and display in GUI editor
  499. void CMakeSetupDialog::LoadCacheFromDiskToGUI()
  500. {
  501. if(m_WhereBuild != "")
  502. {
  503. cmCacheManager::GetInstance()->LoadCache(m_WhereBuild);
  504. this->FillCacheGUIFromCacheManager();
  505. }
  506. }
  507. //! Save GUI values to cmCacheManager and then save to disk.
  508. void CMakeSetupDialog::SaveCacheFromGUI()
  509. {
  510. this->FillCacheManagerFromCacheGUI();
  511. if(m_WhereBuild != "")
  512. {
  513. cmCacheManager::GetInstance()->SaveCache(m_WhereBuild);
  514. }
  515. }
  516. void CMakeSetupDialog::OnSize(UINT nType, int cx, int cy)
  517. {
  518. if (nType == SIZE_MINIMIZED)
  519. {
  520. CDialog::OnSize(nType, cx, cy);
  521. return;
  522. }
  523. if (m_oldCX == -1)
  524. {
  525. m_oldCX = cx;
  526. m_oldCY = cy;
  527. }
  528. int deltax = cx - m_oldCX;
  529. int deltay = cy - m_oldCY;
  530. m_oldCX = cx;
  531. m_oldCY = cy;
  532. CDialog::OnSize(nType, cx, cy);
  533. if (deltax == 0 && deltay == 0)
  534. {
  535. return;
  536. }
  537. if(m_CacheEntriesList.m_hWnd)
  538. {
  539. // get the original sizes/positions
  540. CRect cRect;
  541. m_ListFrame.GetWindowRect(&cRect);
  542. m_ListFrame.SetWindowPos(&wndTop, cRect.left, cRect.top,
  543. cRect.Width() + deltax,
  544. cRect.Height() + deltay,
  545. SWP_NOMOVE | SWP_NOZORDER);
  546. m_CacheEntriesList.GetWindowRect(&cRect);
  547. m_CacheEntriesList.SetWindowPos(&wndTop, cRect.left, cRect.top,
  548. cRect.Width() + deltax,
  549. cRect.Height() + deltay,
  550. SWP_NOMOVE | SWP_NOZORDER);
  551. m_VersionDisplay.SetWindowPos(&wndTop, 5, cy-23, 0, 0,
  552. SWP_NOSIZE | SWP_NOZORDER);
  553. deltax = deltax + m_deltaXRemainder;
  554. m_deltaXRemainder = deltax%2;
  555. m_MouseHelp.GetWindowRect(&cRect);
  556. this->ScreenToClient(&cRect);
  557. m_MouseHelp.SetWindowPos(&wndTop, cRect.left + deltax/2,
  558. cRect.top + deltay,
  559. 0, 0,
  560. SWP_NOSIZE | SWP_NOZORDER);
  561. m_BuildProjects.GetWindowRect(&cRect);
  562. this->ScreenToClient(&cRect);
  563. m_BuildProjects.SetWindowPos(&wndTop, cRect.left + deltax/2,
  564. cRect.top + deltay,
  565. 0, 0,
  566. SWP_NOSIZE | SWP_NOZORDER);
  567. m_CancelButton.GetWindowRect(&cRect);
  568. this->ScreenToClient(&cRect);
  569. m_CancelButton.SetWindowPos(&wndTop, cRect.left + deltax/2,
  570. cRect.top + deltay,
  571. 0, 0,
  572. SWP_NOSIZE | SWP_NOZORDER);
  573. }
  574. }
  575. void CMakeSetupDialog::OnGetMinMaxInfo( MINMAXINFO FAR* lpMMI )
  576. {
  577. lpMMI->ptMinTrackSize.x = 550;
  578. lpMMI->ptMinTrackSize.y = 272;
  579. }
  580. void CMakeSetupDialog::OnOK()
  581. {
  582. if(m_CacheEntriesList.IsDirty())
  583. {
  584. if(MessageBox("You have changed options but not rebuilt, "
  585. "are you sure you want to exit?", "Confirm Exit",
  586. MB_YESNO) == IDYES)
  587. {
  588. CDialog::OnOK();
  589. }
  590. }
  591. else
  592. {
  593. CDialog::OnOK();
  594. }
  595. }