CMakeSetupDialog.cpp 36 KB

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