CMakeSetupDialog.cpp 36 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294
  1. // pcbuilderdialogDlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "shellapi.h"
  5. // a fun undef for DOT NET
  6. #undef DEBUG
  7. #include "CMakeSetup.h"
  8. #include "MakeHelp.h"
  9. #include "PathDialog.h"
  10. #include "CMakeSetupDialog.h"
  11. #include "CMakeCommandLineInfo.h"
  12. #include "../cmCacheManager.h"
  13. #include "../cmake.h"
  14. #include "../cmGlobalGenerator.h"
  15. #ifdef _DEBUG
  16. #define new DEBUG_NEW
  17. #undef THIS_FILE
  18. static char THIS_FILE[] = __FILE__;
  19. #endif
  20. // Convert to Win32 path (slashes). But it's not in cmSystemTools, so
  21. // the 2 billions people that are using the CMake API can not mistake
  22. // it with cmMakeMyCoffeeButNoSugarPlease().
  23. std::string ConvertToWindowsPath(const char* path)
  24. {
  25. // Convert to output path.
  26. // Remove the "" around it (if any) since it's an output path for
  27. // the shell. If another shell-oriented feature is not designed
  28. // for a GUI use, then we are in trouble.
  29. std::string s = cmSystemTools::ConvertToOutputPath(path);
  30. std::string::iterator i = s.begin();
  31. if (*i == '\"')
  32. {
  33. s.erase(i, i + 1);
  34. }
  35. i = s.begin() + s.length() - 1;
  36. if (*i == '\"')
  37. {
  38. s.erase(i, i + 1);
  39. }
  40. return s;
  41. }
  42. /////////////////////////////////////////////////////////////////////////////
  43. // CAboutDlg dialog used for App About
  44. class CAboutDlg : public CDialog
  45. {
  46. public:
  47. CAboutDlg();
  48. // Dialog Data
  49. //{{AFX_DATA(CAboutDlg)
  50. enum { IDD = IDD_ABOUTBOX };
  51. //}}AFX_DATA
  52. // ClassWizard generated virtual function overrides
  53. //{{AFX_VIRTUAL(CAboutDlg)
  54. protected:
  55. virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
  56. //}}AFX_VIRTUAL
  57. // Implementation
  58. protected:
  59. //{{AFX_MSG(CAboutDlg)
  60. //}}AFX_MSG
  61. DECLARE_MESSAGE_MAP()
  62. };
  63. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  64. {
  65. //{{AFX_DATA_INIT(CAboutDlg)
  66. //}}AFX_DATA_INIT
  67. }
  68. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  69. {
  70. CDialog::DoDataExchange(pDX);
  71. //{{AFX_DATA_MAP(CAboutDlg)
  72. //}}AFX_DATA_MAP
  73. }
  74. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  75. //{{AFX_MSG_MAP(CAboutDlg)
  76. // No message handlers
  77. //}}AFX_MSG_MAP
  78. END_MESSAGE_MAP();
  79. void MFCMessageCallback(const char* m, const char* title, bool& nomore)
  80. {
  81. std::string message = m;
  82. message += "\n\n(Press Cancel to suppress any further messages.)";
  83. if(::MessageBox(0, message.c_str(), title,
  84. MB_OKCANCEL|MB_TASKMODAL) == IDCANCEL)
  85. {
  86. nomore = true;
  87. }
  88. }
  89. /////////////////////////////////////////////////////////////////////////////
  90. // CMakeSetupDialog dialog
  91. CMakeSetupDialog::CMakeSetupDialog(const CMakeCommandLineInfo& cmdInfo,
  92. CWnd* pParent /*=NULL*/)
  93. : CDialog(CMakeSetupDialog::IDD, pParent)
  94. {
  95. cmSystemTools::SetErrorCallback(MFCMessageCallback);
  96. m_RegistryKey = "Software\\Kitware\\CMakeSetup\\Settings\\StartPath";
  97. m_CacheEntriesList.m_CMakeSetupDialog = this;
  98. //{{AFX_DATA_INIT(CMakeSetupDialog)
  99. // Get the parameters from the command line info
  100. // If an unknown parameter is found, try to interpret it too, since it
  101. // is likely to be a file dropped on the shortcut :)
  102. if (cmdInfo.m_LastUnknownParameter.IsEmpty())
  103. {
  104. this->m_WhereSource = cmdInfo.m_WhereSource;
  105. this->m_WhereBuild = cmdInfo.m_WhereBuild;
  106. this->m_GeneratorChoiceString = cmdInfo.m_GeneratorChoiceString;
  107. this->m_AdvancedValues = cmdInfo.m_AdvancedValues;
  108. }
  109. else
  110. {
  111. this->m_WhereSource = _T("");
  112. this->m_WhereBuild = _T("");
  113. this->m_AdvancedValues = FALSE;
  114. this->m_GeneratorChoiceString = _T("");
  115. this->ChangeDirectoriesFromFile((LPCTSTR)cmdInfo.m_LastUnknownParameter);
  116. }
  117. //}}AFX_DATA_INIT
  118. // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
  119. m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
  120. m_BuildPathChanged = false;
  121. // Find the path to the cmake.exe executable
  122. char fname[1024];
  123. ::GetModuleFileName(NULL,fname,1023);
  124. // extract just the path part
  125. m_PathToExecutable = cmSystemTools::GetProgramPath(fname).c_str();
  126. // add the cmake.exe to the path
  127. m_PathToExecutable += "/cmake.exe";
  128. m_oldCX = -1;
  129. m_deltaXRemainder = 0;
  130. m_CMakeInstance = new cmake;
  131. }
  132. void CMakeSetupDialog::DoDataExchange(CDataExchange* pDX)
  133. {
  134. CDialog::DoDataExchange(pDX);
  135. //{{AFX_DATA_MAP(CMakeSetupDialog)
  136. DDX_Control(pDX, IDC_HELP_BUTTON, m_HelpButton);
  137. DDX_Control(pDX, IDC_Generator, m_GeneratorChoice);
  138. DDX_Control(pDX, IDC_OK, m_OKButton);
  139. DDX_Control(pDX, IDCANCEL, m_CancelButton);
  140. DDX_CBStringExact(pDX, IDC_WhereSource, m_WhereSource);
  141. DDX_CBStringExact(pDX, IDC_WhereBuild, m_WhereBuild);
  142. DDX_Control(pDX, IDC_FRAME, m_ListFrame);
  143. DDX_Control(pDX, IDC_WhereSource, m_WhereSourceControl);
  144. DDX_Control(pDX, IDC_WhereBuild, m_WhereBuildControl);
  145. DDX_Control(pDX, IDC_LIST2, m_CacheEntriesList);
  146. DDX_Control(pDX, IDC_MouseHelpCaption, m_MouseHelp);
  147. DDX_Control(pDX, IDC_CMAKE_VERSION, m_VersionDisplay);
  148. DDX_Control(pDX, IDC_BuildProjects, m_Configure);
  149. DDX_CBStringExact(pDX, IDC_Generator, m_GeneratorChoiceString);
  150. DDX_Check(pDX, IDC_AdvancedValues, m_AdvancedValues);
  151. //}}AFX_DATA_MAP
  152. }
  153. BEGIN_MESSAGE_MAP(CMakeSetupDialog, CDialog)
  154. //{{AFX_MSG_MAP(CMakeSetupDialog)
  155. ON_WM_SYSCOMMAND()
  156. ON_WM_PAINT()
  157. ON_WM_QUERYDRAGICON()
  158. ON_WM_DROPFILES()
  159. ON_BN_CLICKED(IDC_BUTTON2, OnBrowseWhereSource)
  160. ON_BN_CLICKED(IDC_BuildProjects, OnConfigure)
  161. ON_BN_CLICKED(IDC_BUTTON3, OnBrowseWhereBuild)
  162. ON_CBN_EDITCHANGE(IDC_WhereBuild, OnChangeWhereBuild)
  163. ON_CBN_SELCHANGE(IDC_WhereBuild, OnSelendokWhereBuild)
  164. ON_CBN_EDITCHANGE(IDC_WhereSource, OnChangeWhereSource)
  165. ON_CBN_SELENDOK(IDC_WhereSource, OnSelendokWhereSource)
  166. ON_WM_SIZE()
  167. ON_WM_GETMINMAXINFO()
  168. ON_BN_CLICKED(IDC_OK, OnOk)
  169. ON_CBN_EDITCHANGE(IDC_Generator, OnEditchangeGenerator)
  170. ON_BN_CLICKED(IDC_HELP_BUTTON, OnHelpButton)
  171. ON_BN_CLICKED(IDCANCEL, OnCancel)
  172. ON_BN_CLICKED(IDC_AdvancedValues, OnAdvancedValues)
  173. ON_BN_DOUBLECLICKED(IDC_AdvancedValues, OnDoubleclickedAdvancedValues)
  174. //}}AFX_MSG_MAP
  175. END_MESSAGE_MAP()
  176. /////////////////////////////////////////////////////////////////////////////
  177. // CMakeSetupDialog message handlers
  178. BOOL CMakeSetupDialog::OnInitDialog()
  179. {
  180. CDialog::OnInitDialog();
  181. this->DragAcceptFiles(true);
  182. // Add "Create shortcut" menu item to system menu.
  183. // IDM_CREATESHORTCUT must be in the system command range.
  184. ASSERT((IDM_CREATESHORTCUT & 0xFFF0) == IDM_CREATESHORTCUT);
  185. ASSERT(IDM_CREATESHORTCUT < 0xF000);
  186. // Add "About..." menu item to system menu.
  187. // IDM_ABOUTBOX must be in the system command range.
  188. ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
  189. ASSERT(IDM_ABOUTBOX < 0xF000);
  190. CMenu* pSysMenu = GetSystemMenu(FALSE);
  191. if (pSysMenu != NULL)
  192. {
  193. CString strCreateShortcutMenu;
  194. strCreateShortcutMenu.LoadString(IDS_CREATESHORTCUT);
  195. if (!strCreateShortcutMenu.IsEmpty())
  196. {
  197. pSysMenu->AppendMenu(MF_SEPARATOR);
  198. pSysMenu->AppendMenu(MF_STRING,
  199. IDM_CREATESHORTCUT,
  200. strCreateShortcutMenu);
  201. }
  202. CString strAboutMenu;
  203. strAboutMenu.LoadString(IDS_ABOUTBOX);
  204. if (!strAboutMenu.IsEmpty())
  205. {
  206. pSysMenu->AppendMenu(MF_SEPARATOR);
  207. pSysMenu->AppendMenu(MF_STRING,
  208. IDM_ABOUTBOX,
  209. strAboutMenu);
  210. }
  211. }
  212. // Set the icon for this dialog. The framework does this automatically
  213. // when the application's main window is not a dialog
  214. SetIcon(m_hIcon, TRUE); // Set big icon
  215. SetIcon(m_hIcon, FALSE); // Set small icon
  216. // Load source and build dirs from registry
  217. this->LoadFromRegistry();
  218. std::vector<std::string> names;
  219. this->m_CMakeInstance->GetRegisteredGenerators(names);
  220. for(std::vector<std::string>::iterator i = names.begin();
  221. i != names.end(); ++i)
  222. {
  223. m_GeneratorChoice.AddString(i->c_str());
  224. }
  225. if (m_GeneratorChoiceString == _T(""))
  226. {
  227. m_GeneratorChoiceString = "Visual Studio 6";
  228. }
  229. // try to load the cmake cache from disk
  230. this->LoadCacheFromDiskToGUI();
  231. m_WhereBuildControl.LimitText(2048);
  232. m_WhereSourceControl.LimitText(2048);
  233. m_GeneratorChoice.LimitText(2048);
  234. // Set the version number
  235. char tmp[1024];
  236. sprintf(tmp,"Version %d.%d - %s", cmake::GetMajorVersion(),
  237. cmake::GetMinorVersion(), cmake::GetReleaseVersion());
  238. SetDlgItemText(IDC_CMAKE_VERSION, tmp);
  239. this->UpdateData(FALSE);
  240. return TRUE; // return TRUE unless you set the focus to a control
  241. }
  242. // About dialog invoke
  243. void CMakeSetupDialog::OnSysCommand(UINT nID, LPARAM lParam)
  244. {
  245. if ((nID & 0xFFF0) == IDM_ABOUTBOX)
  246. {
  247. CAboutDlg dlgAbout;
  248. dlgAbout.DoModal();
  249. }
  250. else if ((nID & 0xFFF0) == IDM_CREATESHORTCUT)
  251. {
  252. CreateShortcut();
  253. }
  254. else
  255. {
  256. CDialog::OnSysCommand(nID, lParam);
  257. }
  258. }
  259. // If you add a minimize button to your dialog, you will need the code below
  260. // to draw the icon. For MFC applications using the document/view model,
  261. // this is automatically done for you by the framework.
  262. void CMakeSetupDialog::OnPaint()
  263. {
  264. if (IsIconic())
  265. {
  266. CPaintDC dc(this); // device context for painting
  267. SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
  268. // Center icon in client rectangle
  269. int cxIcon = GetSystemMetrics(SM_CXICON);
  270. int cyIcon = GetSystemMetrics(SM_CYICON);
  271. CRect rect;
  272. GetClientRect(&rect);
  273. int x = (rect.Width() - cxIcon + 1) / 2;
  274. int y = (rect.Height() - cyIcon + 1) / 2;
  275. // Draw the icon
  276. dc.DrawIcon(x, y, m_hIcon);
  277. }
  278. else
  279. {
  280. CDialog::OnPaint();
  281. }
  282. }
  283. // The system calls this to obtain the cursor to display while the user drags
  284. // the minimized window.
  285. HCURSOR CMakeSetupDialog::OnQueryDragIcon()
  286. {
  287. return (HCURSOR) m_hIcon;
  288. }
  289. // Browse button
  290. bool CMakeSetupDialog::Browse(CString &result, const char *title)
  291. {
  292. CPathDialog dlg("Select Path", title, result);
  293. if(dlg.DoModal()==IDOK)
  294. {
  295. result = dlg.GetPathName();
  296. return true;
  297. }
  298. else
  299. {
  300. return false;
  301. }
  302. }
  303. void CMakeSetupDialog::SaveToRegistry()
  304. {
  305. HKEY hKey;
  306. DWORD dwDummy;
  307. if(RegCreateKeyEx(HKEY_CURRENT_USER,
  308. m_RegistryKey,
  309. 0, "", REG_OPTION_NON_VOLATILE, KEY_READ|KEY_WRITE,
  310. NULL, &hKey, &dwDummy) != ERROR_SUCCESS)
  311. {
  312. return;
  313. }
  314. else
  315. {
  316. // save some values
  317. CString regvalue;
  318. this->ReadRegistryValue(hKey, &(regvalue),"WhereSource1","C:\\");
  319. int shiftEnd = 9;
  320. if(m_WhereSource != regvalue)
  321. {
  322. char keyName[1024];
  323. char keyName2[1024];
  324. int i;
  325. for (i = 2; i < 10; ++i)
  326. {
  327. regvalue = "";
  328. sprintf(keyName,"WhereSource%i",i);
  329. this->ReadRegistryValue(hKey, &(regvalue),keyName,"");
  330. // check for short circuit, if the new value is already in
  331. // the list then we stop
  332. if (m_WhereSource == regvalue)
  333. {
  334. shiftEnd = i - 1;
  335. }
  336. }
  337. for (i = shiftEnd; i; --i)
  338. {
  339. regvalue = "";
  340. sprintf(keyName,"WhereSource%i",i);
  341. sprintf(keyName2,"WhereSource%i",i+1);
  342. this->ReadRegistryValue(hKey, &(regvalue),keyName,"");
  343. if (strlen(regvalue))
  344. {
  345. RegSetValueEx(hKey, _T(keyName2), 0, REG_SZ,
  346. (CONST BYTE *)(const char *)regvalue,
  347. regvalue.GetLength());
  348. }
  349. }
  350. RegSetValueEx(hKey, _T("WhereSource1"), 0, REG_SZ,
  351. (CONST BYTE *)(const char *)m_WhereSource,
  352. m_WhereSource.GetLength());
  353. }
  354. this->ReadRegistryValue(hKey, &(regvalue),"WhereBuild1","C:\\");
  355. if(m_WhereBuild != regvalue)
  356. {
  357. int i;
  358. char keyName[1024];
  359. char keyName2[1024];
  360. for (i = 2; i < 10; ++i)
  361. {
  362. regvalue = "";
  363. sprintf(keyName,"WhereBuild%i",i);
  364. this->ReadRegistryValue(hKey, &(regvalue),keyName,"");
  365. // check for short circuit, if the new value is already in
  366. // the list then we stop
  367. if (m_WhereBuild == regvalue)
  368. {
  369. shiftEnd = i - 1;
  370. }
  371. }
  372. for (i = shiftEnd; i; --i)
  373. {
  374. regvalue = "";
  375. sprintf(keyName,"WhereBuild%i",i);
  376. sprintf(keyName2,"WhereBuild%i",i+1);
  377. this->ReadRegistryValue(hKey, &(regvalue),keyName,"");
  378. if (strlen(regvalue))
  379. {
  380. RegSetValueEx(hKey, _T(keyName2), 0, REG_SZ,
  381. (CONST BYTE *)(const char *)regvalue,
  382. regvalue.GetLength());
  383. }
  384. }
  385. RegSetValueEx(hKey, _T("WhereBuild1"), 0, REG_SZ,
  386. (CONST BYTE *)(const char *)m_WhereBuild,
  387. m_WhereBuild.GetLength());
  388. }
  389. }
  390. RegCloseKey(hKey);
  391. }
  392. void CMakeSetupDialog::ReadRegistryValue(HKEY hKey,
  393. CString *val,
  394. const char *key,
  395. const char *adefault)
  396. {
  397. DWORD dwType, dwSize;
  398. char *pb;
  399. dwType = REG_SZ;
  400. pb = val->GetBuffer(MAX_PATH);
  401. dwSize = MAX_PATH;
  402. if(RegQueryValueEx(hKey,_T(key), NULL, &dwType,
  403. (BYTE *)pb, &dwSize) != ERROR_SUCCESS)
  404. {
  405. val->ReleaseBuffer();
  406. *val = _T(adefault);
  407. }
  408. else
  409. {
  410. val->ReleaseBuffer();
  411. }
  412. }
  413. void CMakeSetupDialog::LoadFromRegistry()
  414. {
  415. HKEY hKey;
  416. if(RegOpenKeyEx(HKEY_CURRENT_USER,
  417. m_RegistryKey,
  418. 0, KEY_READ, &hKey) != ERROR_SUCCESS)
  419. {
  420. return;
  421. }
  422. else
  423. {
  424. // load some values
  425. if (m_WhereSource.IsEmpty())
  426. {
  427. this->ReadRegistryValue(hKey, &(m_WhereSource),"WhereSource1","C:\\");
  428. }
  429. if (m_WhereBuild.IsEmpty())
  430. {
  431. this->ReadRegistryValue(hKey, &(m_WhereBuild),"WhereBuild1","C:\\");
  432. }
  433. m_WhereSourceControl.AddString(m_WhereSource);
  434. m_WhereBuildControl.AddString(m_WhereBuild);
  435. char keyname[1024];
  436. CString regvalue;
  437. int i;
  438. for (i = 2; i <= 10; ++i)
  439. {
  440. sprintf(keyname,"WhereSource%i",i);
  441. regvalue = "";
  442. this->ReadRegistryValue(hKey, &(regvalue),keyname,"C:\\");
  443. if (strcmp("C:\\",regvalue))
  444. {
  445. m_WhereSourceControl.AddString(regvalue);
  446. }
  447. sprintf(keyname,"WhereBuild%i",i);
  448. regvalue = "";
  449. this->ReadRegistryValue(hKey, &(regvalue),keyname,"C:\\");
  450. if (strcmp("C:\\",regvalue))
  451. {
  452. m_WhereBuildControl.AddString(regvalue);
  453. }
  454. }
  455. }
  456. RegCloseKey(hKey);
  457. }
  458. // Callback for browse source button
  459. void CMakeSetupDialog::OnBrowseWhereSource()
  460. {
  461. this->UpdateData();
  462. Browse(m_WhereSource, "Enter Path to Source");
  463. this->UpdateData(false);
  464. this->OnChangeWhereSource();
  465. }
  466. // Callback for browser build button
  467. void CMakeSetupDialog::OnBrowseWhereBuild()
  468. {
  469. this->UpdateData();
  470. Browse(m_WhereBuild, "Enter Path to Build");
  471. this->UpdateData(false);
  472. this->OnChangeWhereBuild();
  473. }
  474. void CMakeSetupDialog::RunCMake(bool generateProjectFiles)
  475. {
  476. if(!cmSystemTools::FileExists(m_WhereBuild))
  477. {
  478. std::string message =
  479. "Build directory does not exist, should I create it?\n\n"
  480. "Directory: ";
  481. message += (const char*)m_WhereBuild;
  482. if(MessageBox(message.c_str(), "Create Directory", MB_OKCANCEL) == IDOK)
  483. {
  484. cmSystemTools::MakeDirectory(m_WhereBuild);
  485. }
  486. else
  487. {
  488. MessageBox("Build Project aborted, nothing done.");
  489. return;
  490. }
  491. }
  492. // set the wait cursor
  493. ::SetCursor(LoadCursor(NULL, IDC_WAIT));
  494. // get all the info from the dialog
  495. this->UpdateData();
  496. // always save the current gui values to disk
  497. this->SaveCacheFromGUI();
  498. // Make sure we are working from the cache on disk
  499. this->LoadCacheFromDiskToGUI();
  500. m_OKButton.EnableWindow(false);
  501. // setup the cmake instance
  502. if (generateProjectFiles)
  503. {
  504. if(m_CMakeInstance->Generate() != 0)
  505. {
  506. cmSystemTools::Error(
  507. "Error in generation process, project files may be invalid");
  508. }
  509. }
  510. else
  511. {
  512. m_CMakeInstance->SetHomeDirectory(m_WhereSource);
  513. m_CMakeInstance->SetStartDirectory(m_WhereSource);
  514. m_CMakeInstance->SetHomeOutputDirectory(m_WhereBuild);
  515. m_CMakeInstance->SetStartOutputDirectory(m_WhereBuild);
  516. m_CMakeInstance->SetGlobalGenerator(
  517. m_CMakeInstance->CreateGlobalGenerator(m_GeneratorChoiceString));
  518. m_CMakeInstance->SetCMakeCommand(m_PathToExecutable);
  519. m_CMakeInstance->LoadCache();
  520. if(m_CMakeInstance->Configure() != 0)
  521. {
  522. cmSystemTools::Error(
  523. "Error in configuration process, project files may be invalid");
  524. }
  525. // update the GUI with any new values in the caused by the
  526. // generation process
  527. this->LoadCacheFromDiskToGUI();
  528. }
  529. // save source and build paths to registry
  530. this->SaveToRegistry();
  531. // path is up-to-date now
  532. m_BuildPathChanged = false;
  533. // put the cursor back
  534. ::SetCursor(LoadCursor(NULL, IDC_ARROW));
  535. cmSystemTools::ResetErrorOccuredFlag();
  536. }
  537. // Callback for build projects button
  538. void CMakeSetupDialog::OnConfigure()
  539. {
  540. // enable error messages each time configure is pressed
  541. cmSystemTools::EnableMessages();
  542. this->RunCMake(false);
  543. }
  544. // callback for combo box menu where build selection
  545. void CMakeSetupDialog::OnSelendokWhereBuild()
  546. {
  547. m_WhereBuildControl.GetLBText(m_WhereBuildControl.GetCurSel(),
  548. m_WhereBuild);
  549. m_WhereBuildControl.SetWindowText( m_WhereBuild);
  550. this->UpdateData(FALSE);
  551. this->OnChangeWhereBuild();
  552. }
  553. // callback for combo box menu where source selection
  554. void CMakeSetupDialog::OnSelendokWhereSource()
  555. {
  556. m_WhereSourceControl.GetLBText(m_WhereSourceControl.GetCurSel(),
  557. m_WhereSource);
  558. this->UpdateData(FALSE);
  559. this->OnChangeWhereSource();
  560. }
  561. // callback for chaing source directory
  562. void CMakeSetupDialog::OnChangeWhereSource()
  563. {
  564. }
  565. // callback for changing the build directory
  566. void CMakeSetupDialog::OnChangeWhereBuild()
  567. {
  568. this->UpdateData();
  569. // The build dir has changed, check if there is a cache, and
  570. // grab the source dir from it
  571. std::string path = this->m_WhereBuild;
  572. cmSystemTools::ConvertToUnixSlashes(path);
  573. // adjust the cmake instance
  574. m_CMakeInstance->SetHomeOutputDirectory(m_WhereBuild);
  575. m_CMakeInstance->SetStartOutputDirectory(m_WhereBuild);
  576. std::string cache_file = path;
  577. cache_file += "/CMakeCache.txt";
  578. cmCacheManager *cachem = this->m_CMakeInstance->GetCacheManager();
  579. cmCacheManager::CacheIterator it = cachem->NewIterator();
  580. if (cmSystemTools::FileExists(cache_file.c_str()) &&
  581. cachem->LoadCache(path.c_str()) &&
  582. it.Find("CMAKE_HOME_DIRECTORY"))
  583. {
  584. path = ConvertToWindowsPath(it.GetValue());
  585. this->m_WhereSource = path.c_str();
  586. this->m_WhereSourceControl.SetWindowText(this->m_WhereSource);
  587. this->OnChangeWhereSource();
  588. }
  589. m_CacheEntriesList.RemoveAll();
  590. m_CacheEntriesList.ShowWindow(SW_SHOW);
  591. this->LoadCacheFromDiskToGUI();
  592. m_BuildPathChanged = true;
  593. }
  594. // copy from the cache manager to the cache edit list box
  595. void CMakeSetupDialog::FillCacheGUIFromCacheManager()
  596. {
  597. cmCacheManager *cachem = this->m_CMakeInstance->GetCacheManager();
  598. size_t size = m_CacheEntriesList.GetItems().size();
  599. bool reverseOrder = false;
  600. // if there are already entries in the cache, then
  601. // put the new ones in the top, so they show up first
  602. if(size)
  603. {
  604. reverseOrder = true;
  605. }
  606. // all the current values are not new any more
  607. std::set<CPropertyItem*> items = m_CacheEntriesList.GetItems();
  608. for(std::set<CPropertyItem*>::iterator i = items.begin();
  609. i != items.end(); ++i)
  610. {
  611. CPropertyItem* item = *i;
  612. item->m_NewValue = false;
  613. }
  614. for(cmCacheManager::CacheIterator i = cachem->NewIterator();
  615. !i.IsAtEnd(); i.Next())
  616. {
  617. const char* key = i.GetName();
  618. // if value has trailing space or tab, enclose it in single quotes
  619. // to enforce the fact that it has 'invisible' trailing stuff
  620. std::string value = i.GetValue();
  621. if (value.size() &&
  622. (value[value.size() - 1] == ' ' ||
  623. value[value.size() - 1] == '\t'))
  624. {
  625. value = '\'' + value + '\'';
  626. }
  627. if(!m_AdvancedValues)
  628. {
  629. if(i.GetPropertyAsBool("ADVANCED"))
  630. {
  631. m_CacheEntriesList.RemoveProperty(key);
  632. continue;
  633. }
  634. }
  635. switch(i.GetType() )
  636. {
  637. case cmCacheManager::BOOL:
  638. if(cmSystemTools::IsOn(value.c_str()))
  639. {
  640. m_CacheEntriesList.AddProperty(key,
  641. "ON",
  642. i.GetProperty("HELPSTRING"),
  643. CPropertyList::COMBO,"ON|OFF",
  644. reverseOrder
  645. );
  646. }
  647. else
  648. {
  649. m_CacheEntriesList.AddProperty(key,
  650. "OFF",
  651. i.GetProperty("HELPSTRING"),
  652. CPropertyList::COMBO,"ON|OFF",
  653. reverseOrder
  654. );
  655. }
  656. break;
  657. case cmCacheManager::PATH:
  658. m_CacheEntriesList.AddProperty(key,
  659. value.c_str(),
  660. i.GetProperty("HELPSTRING"),
  661. CPropertyList::PATH,"",
  662. reverseOrder
  663. );
  664. break;
  665. case cmCacheManager::FILEPATH:
  666. m_CacheEntriesList.AddProperty(key,
  667. value.c_str(),
  668. i.GetProperty("HELPSTRING"),
  669. CPropertyList::FILE,"",
  670. reverseOrder
  671. );
  672. break;
  673. case cmCacheManager::STRING:
  674. m_CacheEntriesList.AddProperty(key,
  675. value.c_str(),
  676. i.GetProperty("HELPSTRING"),
  677. CPropertyList::EDIT,"",
  678. reverseOrder
  679. );
  680. break;
  681. case cmCacheManager::INTERNAL:
  682. m_CacheEntriesList.RemoveProperty(key);
  683. break;
  684. }
  685. }
  686. m_OKButton.EnableWindow(false);
  687. if(cachem->GetSize() > 0 && !cmSystemTools::GetErrorOccuredFlag())
  688. {
  689. bool enable = true;
  690. items = m_CacheEntriesList.GetItems();
  691. for(std::set<CPropertyItem*>::iterator i = items.begin();
  692. i != items.end(); ++i)
  693. {
  694. CPropertyItem* item = *i;
  695. if(item->m_NewValue)
  696. {
  697. // if one new value then disable to OK button
  698. enable = false;
  699. break;
  700. }
  701. }
  702. if(enable)
  703. {
  704. m_OKButton.EnableWindow(true);
  705. }
  706. }
  707. // redraw the list
  708. m_CacheEntriesList.SetTopIndex(0);
  709. m_CacheEntriesList.Invalidate();
  710. }
  711. // copy from the list box to the cache manager
  712. void CMakeSetupDialog::FillCacheManagerFromCacheGUI()
  713. {
  714. cmCacheManager *cachem = this->m_CMakeInstance->GetCacheManager();
  715. std::set<CPropertyItem*> items = m_CacheEntriesList.GetItems();
  716. cmCacheManager::CacheIterator it = cachem->NewIterator();
  717. for(std::set<CPropertyItem*>::iterator i = items.begin();
  718. i != items.end(); ++i)
  719. {
  720. CPropertyItem* item = *i;
  721. if ( it.Find((const char*)item->m_propName) )
  722. {
  723. // if value is enclosed in single quotes ('foo') then remove them
  724. // they were used to enforce the fact that it had 'invisible'
  725. // trailing stuff
  726. if (item->m_curValue.GetLength() >= 2 &&
  727. item->m_curValue[0] == '\'' &&
  728. item->m_curValue[item->m_curValue.GetLength() - 1] == '\'')
  729. {
  730. it.SetValue(item->m_curValue.Mid(
  731. 1, item->m_curValue.GetLength() - 2));
  732. }
  733. else
  734. {
  735. it.SetValue(item->m_curValue);
  736. }
  737. }
  738. }
  739. }
  740. //! Load cache file from m_WhereBuild and display in GUI editor
  741. void CMakeSetupDialog::LoadCacheFromDiskToGUI()
  742. {
  743. cmCacheManager *cachem = this->m_CMakeInstance->GetCacheManager();
  744. if(m_WhereBuild != "")
  745. {
  746. cachem->LoadCache(m_WhereBuild);
  747. this->FillCacheGUIFromCacheManager();
  748. cmCacheManager::CacheIterator it =
  749. cachem->GetCacheIterator("CMAKE_GENERATOR");
  750. if(!it.IsAtEnd())
  751. {
  752. std::string curGen = it.GetValue();
  753. if(m_GeneratorChoiceString != curGen.c_str())
  754. {
  755. m_GeneratorChoiceString = curGen.c_str();
  756. this->UpdateData(FALSE);
  757. }
  758. }
  759. }
  760. }
  761. //! Save GUI values to cmCacheManager and then save to disk.
  762. void CMakeSetupDialog::SaveCacheFromGUI()
  763. {
  764. cmCacheManager *cachem = this->m_CMakeInstance->GetCacheManager();
  765. this->FillCacheManagerFromCacheGUI();
  766. if(m_WhereBuild != "")
  767. {
  768. cachem->SaveCache(m_WhereBuild);
  769. }
  770. }
  771. void CMakeSetupDialog::OnSize(UINT nType, int cx, int cy)
  772. {
  773. if (nType == SIZE_MINIMIZED)
  774. {
  775. CDialog::OnSize(nType, cx, cy);
  776. return;
  777. }
  778. if (m_oldCX == -1)
  779. {
  780. m_oldCX = cx;
  781. m_oldCY = cy;
  782. }
  783. int deltax = cx - m_oldCX;
  784. int deltay = cy - m_oldCY;
  785. m_oldCX = cx;
  786. m_oldCY = cy;
  787. CDialog::OnSize(nType, cx, cy);
  788. if (deltax == 0 && deltay == 0)
  789. {
  790. return;
  791. }
  792. if(m_CacheEntriesList.m_hWnd)
  793. {
  794. // get the original sizes/positions
  795. CRect cRect;
  796. m_ListFrame.GetWindowRect(&cRect);
  797. m_ListFrame.SetWindowPos(&wndTop, cRect.left, cRect.top,
  798. cRect.Width() + deltax,
  799. cRect.Height() + deltay,
  800. SWP_NOMOVE | SWP_NOZORDER);
  801. m_CacheEntriesList.GetWindowRect(&cRect);
  802. m_CacheEntriesList.SetWindowPos(&wndTop, cRect.left, cRect.top,
  803. cRect.Width() + deltax,
  804. cRect.Height() + deltay,
  805. SWP_NOMOVE | SWP_NOZORDER);
  806. m_VersionDisplay.SetWindowPos(&wndTop, 5, cy-23, 0, 0,
  807. SWP_NOSIZE | SWP_NOZORDER);
  808. deltax = int(deltax + m_deltaXRemainder);
  809. m_deltaXRemainder = float(deltax%2);
  810. m_MouseHelp.GetWindowRect(&cRect);
  811. this->ScreenToClient(&cRect);
  812. m_MouseHelp.SetWindowPos(&wndTop, cRect.left + deltax/2,
  813. cRect.top + deltay,
  814. 0, 0,
  815. SWP_NOSIZE | SWP_NOZORDER);
  816. m_Configure.GetWindowRect(&cRect);
  817. this->ScreenToClient(&cRect);
  818. m_Configure.SetWindowPos(&wndTop, cRect.left + deltax/2,
  819. cRect.top + deltay,
  820. 0, 0,
  821. SWP_NOSIZE | SWP_NOZORDER);
  822. m_CancelButton.GetWindowRect(&cRect);
  823. this->ScreenToClient(&cRect);
  824. m_CancelButton.SetWindowPos(&wndTop, cRect.left + deltax/2,
  825. cRect.top + deltay,
  826. 0, 0,
  827. SWP_NOSIZE | SWP_NOZORDER);
  828. m_OKButton.GetWindowRect(&cRect);
  829. this->ScreenToClient(&cRect);
  830. m_OKButton.SetWindowPos(&wndTop, cRect.left + deltax/2,
  831. cRect.top + deltay,
  832. 0, 0,
  833. SWP_NOSIZE | SWP_NOZORDER);
  834. m_HelpButton.GetWindowRect(&cRect);
  835. this->ScreenToClient(&cRect);
  836. m_HelpButton.SetWindowPos(&wndTop, cRect.left + deltax/2,
  837. cRect.top + deltay,
  838. 0, 0,
  839. SWP_NOSIZE | SWP_NOZORDER);
  840. }
  841. }
  842. void CMakeSetupDialog::OnGetMinMaxInfo( MINMAXINFO FAR* lpMMI )
  843. {
  844. lpMMI->ptMinTrackSize.x = 550;
  845. lpMMI->ptMinTrackSize.y = 272;
  846. }
  847. void CMakeSetupDialog::OnCancel()
  848. {
  849. if(m_CacheEntriesList.IsDirty())
  850. {
  851. if(MessageBox("You have changed options but not rebuilt, "
  852. "are you sure you want to exit?", "Confirm Exit",
  853. MB_YESNO) == IDYES)
  854. {
  855. CDialog::OnOK();
  856. }
  857. }
  858. else
  859. {
  860. CDialog::OnOK();
  861. }
  862. }
  863. void CMakeSetupDialog::OnOk()
  864. {
  865. // enable error messages each time configure is pressed
  866. cmSystemTools::EnableMessages();
  867. m_CacheEntriesList.ClearDirty();
  868. this->RunCMake(true);
  869. if (!(::GetKeyState(VK_SHIFT) & 0x1000))
  870. {
  871. CDialog::OnOK();
  872. }
  873. }
  874. void CMakeSetupDialog::OnEditchangeGenerator()
  875. {
  876. // TODO: Add your control notification handler code here
  877. }
  878. // Create a shortcut on the desktop with the current Source/Build dir.
  879. int CMakeSetupDialog::CreateShortcut()
  880. {
  881. // Find the desktop folder and create the link name
  882. HKEY hKey;
  883. if(RegOpenKeyEx(HKEY_CURRENT_USER,
  884. "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders",
  885. 0, KEY_READ, &hKey) != ERROR_SUCCESS)
  886. {
  887. AfxMessageBox ("Create shortcut: unable to find 'Shell Folders' key in registry!");
  888. return 1;
  889. }
  890. DWORD dwType, dwSize;
  891. #define MAXPATH 1024
  892. char link_name[MAXPATH];
  893. dwSize = MAXPATH;
  894. if(RegQueryValueEx(hKey,
  895. (LPCTSTR)"Desktop",
  896. NULL,
  897. &dwType,
  898. (BYTE *)link_name,
  899. &dwSize) != ERROR_SUCCESS)
  900. {
  901. AfxMessageBox ("Create shortcut: unable to find 'Desktop' registry value in 'Shell Folders' key!");
  902. return 1;
  903. }
  904. if(dwType != REG_SZ)
  905. {
  906. AfxMessageBox ("Create shortcut: 'Desktop' registry value in 'Shell Folders' key has wrong type!");
  907. return 1;
  908. }
  909. strcat(link_name, "\\CMake - ");
  910. std::string current_dir = cmSystemTools::GetFilenameName((LPCTSTR)m_WhereSource);
  911. strcat(link_name, current_dir.c_str());
  912. strcat(link_name, ".lnk");
  913. // Find the path to the current executable
  914. char path_to_current_exe[MAXPATH];
  915. ::GetModuleFileName(NULL, path_to_current_exe, MAXPATH);
  916. // Create the shortcut
  917. HRESULT hres;
  918. IShellLink *psl;
  919. // Initialize the COM library
  920. hres = CoInitialize(NULL);
  921. if (! SUCCEEDED (hres))
  922. {
  923. AfxMessageBox ("Create shortcut: unable to initialize the COM library!");
  924. return 1;
  925. }
  926. // Create an IShellLink object and get a pointer to the IShellLink
  927. // interface (returned from CoCreateInstance).
  928. hres = CoCreateInstance(CLSID_ShellLink,
  929. NULL,
  930. CLSCTX_INPROC_SERVER,
  931. IID_IShellLink,
  932. (void **)&psl);
  933. if (! SUCCEEDED (hres))
  934. {
  935. AfxMessageBox ("Create shortcut: unable to create IShellLink instance!");
  936. return 1;
  937. }
  938. IPersistFile *ppf;
  939. // Query IShellLink for the IPersistFile interface for
  940. // saving the shortcut in persistent storage.
  941. hres = psl->QueryInterface(IID_IPersistFile, (void **)&ppf);
  942. if (SUCCEEDED (hres))
  943. {
  944. // Set the path to the shortcut target.
  945. hres = psl->SetPath(path_to_current_exe);
  946. if (! SUCCEEDED (hres))
  947. {
  948. AfxMessageBox ("Create shortcut: SetPath failed!");
  949. }
  950. // Set the arguments of the shortcut.
  951. CString args = " /H=\"" + m_WhereSource + "\" /B=\"" + m_WhereBuild + "\" /G=\"" + m_GeneratorChoiceString + "\" /A=\"" + (m_AdvancedValues ? "TRUE" : "FALSE") + "\"";
  952. hres = psl->SetArguments(args);
  953. if (! SUCCEEDED (hres))
  954. {
  955. AfxMessageBox ("Create shortcut: SetArguments failed!");
  956. }
  957. // Set the description of the shortcut.
  958. hres = psl->SetDescription("Shortcut to CMakeSetup");
  959. if (! SUCCEEDED (hres))
  960. {
  961. AfxMessageBox ("Create shortcut: SetDescription failed!");
  962. }
  963. // Ensure that the string consists of ANSI characters.
  964. WORD wsz[MAX_PATH];
  965. MultiByteToWideChar(CP_ACP, 0, link_name, -1, wsz, MAX_PATH);
  966. // Save the shortcut via the IPersistFile::Save member function.
  967. hres = ppf->Save(wsz, TRUE);
  968. if (! SUCCEEDED (hres))
  969. {
  970. AfxMessageBox ("Create shortcut: Save failed!");
  971. }
  972. // Release the pointer to IPersistFile.
  973. ppf->Release ();
  974. }
  975. // Release the pointer to IShellLink.
  976. psl->Release ();
  977. return 0;
  978. }
  979. void CMakeSetupDialog::OnHelpButton()
  980. {
  981. CMakeHelp dialog;
  982. dialog.DoModal();
  983. }
  984. void CMakeSetupDialog::ShowAdvancedValues()
  985. {
  986. cmCacheManager *cachem = this->m_CMakeInstance->GetCacheManager();
  987. for(cmCacheManager::CacheIterator i = cachem->NewIterator();
  988. !i.IsAtEnd(); i.Next())
  989. {
  990. const char* key = i.GetName();
  991. if(!i.GetPropertyAsBool("ADVANCED"))
  992. {
  993. continue;
  994. }
  995. switch(i.GetType() )
  996. {
  997. case cmCacheManager::BOOL:
  998. if(cmSystemTools::IsOn(i.GetValue()))
  999. {
  1000. m_CacheEntriesList.AddProperty(key,
  1001. "ON",
  1002. i.GetProperty("HELPSTRING"),
  1003. CPropertyList::COMBO,"ON|OFF",
  1004. true
  1005. );
  1006. }
  1007. else
  1008. {
  1009. m_CacheEntriesList.AddProperty(key,
  1010. "OFF",
  1011. i.GetProperty("HELPSTRING"),
  1012. CPropertyList::COMBO,"ON|OFF",
  1013. true
  1014. );
  1015. }
  1016. break;
  1017. case cmCacheManager::PATH:
  1018. m_CacheEntriesList.AddProperty(key,
  1019. i.GetValue(),
  1020. i.GetProperty("HELPSTRING"),
  1021. CPropertyList::PATH,"",
  1022. true
  1023. );
  1024. break;
  1025. case cmCacheManager::FILEPATH:
  1026. m_CacheEntriesList.AddProperty(key,
  1027. i.GetValue(),
  1028. i.GetProperty("HELPSTRING"),
  1029. CPropertyList::FILE,"",
  1030. true
  1031. );
  1032. break;
  1033. case cmCacheManager::STRING:
  1034. m_CacheEntriesList.AddProperty(key,
  1035. i.GetValue(),
  1036. i.GetProperty("HELPSTRING"),
  1037. CPropertyList::EDIT,"",
  1038. true
  1039. );
  1040. break;
  1041. case cmCacheManager::INTERNAL:
  1042. m_CacheEntriesList.RemoveProperty(key);
  1043. break;
  1044. }
  1045. }
  1046. }
  1047. void CMakeSetupDialog::RemoveAdvancedValues()
  1048. {
  1049. cmCacheManager *cachem = this->m_CMakeInstance->GetCacheManager();
  1050. for(cmCacheManager::CacheIterator i = cachem->NewIterator();
  1051. !i.IsAtEnd(); i.Next())
  1052. {
  1053. const char* key = i.GetName();
  1054. if(i.GetPropertyAsBool("ADVANCED"))
  1055. {
  1056. m_CacheEntriesList.RemoveProperty(key);
  1057. }
  1058. }
  1059. }
  1060. void CMakeSetupDialog::OnAdvancedValues()
  1061. {
  1062. this->UpdateData();
  1063. if(m_AdvancedValues)
  1064. {
  1065. this->ShowAdvancedValues();
  1066. }
  1067. else
  1068. {
  1069. this->RemoveAdvancedValues();
  1070. }
  1071. }
  1072. void CMakeSetupDialog::OnDoubleclickedAdvancedValues()
  1073. {
  1074. this->OnAdvancedValues();
  1075. }
  1076. // Handle param or single dropped file.
  1077. // If the dropped file is a build directory or any file in a
  1078. // build directory, set the source dir from the cache file,
  1079. // otherwise set the source and build dirs to this file (or dir).
  1080. void CMakeSetupDialog::ChangeDirectoriesFromFile(const char* buffer)
  1081. {
  1082. // Get the path to this file
  1083. std::string path = buffer;
  1084. if (!cmSystemTools::FileIsDirectory(path.c_str()))
  1085. {
  1086. path = cmSystemTools::GetFilenamePath(path);
  1087. }
  1088. else
  1089. {
  1090. cmSystemTools::ConvertToUnixSlashes(path);
  1091. }
  1092. // Check if it's a build dir and grab the cache
  1093. std::string cache_file = path;
  1094. cache_file += "/CMakeCache.txt";
  1095. cmCacheManager *cachem = this->m_CMakeInstance->GetCacheManager();
  1096. cmCacheManager::CacheIterator it =
  1097. cachem->NewIterator();
  1098. if (cmSystemTools::FileExists(cache_file.c_str()) &&
  1099. cachem->LoadCache(path.c_str()) &&
  1100. it.Find("CMAKE_HOME_DIRECTORY"))
  1101. {
  1102. path = ConvertToWindowsPath(path.c_str());
  1103. this->m_WhereBuild = path.c_str();
  1104. path = ConvertToWindowsPath(it.GetName());
  1105. this->m_WhereSource = path.c_str();
  1106. }
  1107. else
  1108. {
  1109. path = ConvertToWindowsPath(path.c_str());
  1110. this->m_WhereSource = this->m_WhereBuild = path.c_str();
  1111. }
  1112. }
  1113. // The framework calls this member function when the user releases the
  1114. // left mouse button over a window that has registered itself as the
  1115. // recipient of dropped files.
  1116. void CMakeSetupDialog::OnDropFiles(HDROP hDropInfo)
  1117. {
  1118. UINT nb_files = DragQueryFile(hDropInfo, 0xFFFFFFFF, NULL, 0);
  1119. if (nb_files > 0)
  1120. {
  1121. UINT buffer_size = DragQueryFile(hDropInfo, 0, NULL, 0);
  1122. char *buffer = new char [buffer_size + 1];
  1123. DragQueryFile(hDropInfo, 0, buffer, buffer_size + 1);
  1124. this->ChangeDirectoriesFromFile(buffer);
  1125. delete [] buffer;
  1126. this->m_WhereSourceControl.SetWindowText(this->m_WhereSource);
  1127. this->m_WhereBuildControl.SetWindowText(this->m_WhereBuild);
  1128. this->UpdateData(FALSE);
  1129. this->OnChangeWhereSource();
  1130. this->OnChangeWhereBuild();
  1131. }
  1132. DragFinish(hDropInfo);
  1133. }