CMakeSetupDialog.cpp 36 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292
  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. if(m_CMakeInstance->Configure(m_PathToExecutable) != 0)
  519. {
  520. cmSystemTools::Error(
  521. "Error in configuration process, project files may be invalid");
  522. }
  523. // update the GUI with any new values in the caused by the
  524. // generation process
  525. this->LoadCacheFromDiskToGUI();
  526. }
  527. // save source and build paths to registry
  528. this->SaveToRegistry();
  529. // path is up-to-date now
  530. m_BuildPathChanged = false;
  531. // put the cursor back
  532. ::SetCursor(LoadCursor(NULL, IDC_ARROW));
  533. cmSystemTools::ResetErrorOccuredFlag();
  534. }
  535. // Callback for build projects button
  536. void CMakeSetupDialog::OnConfigure()
  537. {
  538. // enable error messages each time configure is pressed
  539. cmSystemTools::EnableMessages();
  540. this->RunCMake(false);
  541. }
  542. // callback for combo box menu where build selection
  543. void CMakeSetupDialog::OnSelendokWhereBuild()
  544. {
  545. m_WhereBuildControl.GetLBText(m_WhereBuildControl.GetCurSel(),
  546. m_WhereBuild);
  547. m_WhereBuildControl.SetWindowText( m_WhereBuild);
  548. this->UpdateData(FALSE);
  549. this->OnChangeWhereBuild();
  550. }
  551. // callback for combo box menu where source selection
  552. void CMakeSetupDialog::OnSelendokWhereSource()
  553. {
  554. m_WhereSourceControl.GetLBText(m_WhereSourceControl.GetCurSel(),
  555. m_WhereSource);
  556. this->UpdateData(FALSE);
  557. this->OnChangeWhereSource();
  558. }
  559. // callback for chaing source directory
  560. void CMakeSetupDialog::OnChangeWhereSource()
  561. {
  562. }
  563. // callback for changing the build directory
  564. void CMakeSetupDialog::OnChangeWhereBuild()
  565. {
  566. this->UpdateData();
  567. // The build dir has changed, check if there is a cache, and
  568. // grab the source dir from it
  569. std::string path = this->m_WhereBuild;
  570. cmSystemTools::ConvertToUnixSlashes(path);
  571. // adjust the cmake instance
  572. m_CMakeInstance->SetHomeOutputDirectory(m_WhereBuild);
  573. m_CMakeInstance->SetStartOutputDirectory(m_WhereBuild);
  574. std::string cache_file = path;
  575. cache_file += "/CMakeCache.txt";
  576. cmCacheManager *cachem = this->m_CMakeInstance->GetCacheManager();
  577. cmCacheManager::CacheIterator it = cachem->NewIterator();
  578. if (cmSystemTools::FileExists(cache_file.c_str()) &&
  579. cachem->LoadCache(path.c_str()) &&
  580. it.Find("CMAKE_HOME_DIRECTORY"))
  581. {
  582. path = ConvertToWindowsPath(it.GetValue());
  583. this->m_WhereSource = path.c_str();
  584. this->m_WhereSourceControl.SetWindowText(this->m_WhereSource);
  585. this->OnChangeWhereSource();
  586. }
  587. m_CacheEntriesList.RemoveAll();
  588. m_CacheEntriesList.ShowWindow(SW_SHOW);
  589. this->LoadCacheFromDiskToGUI();
  590. m_BuildPathChanged = true;
  591. }
  592. // copy from the cache manager to the cache edit list box
  593. void CMakeSetupDialog::FillCacheGUIFromCacheManager()
  594. {
  595. cmCacheManager *cachem = this->m_CMakeInstance->GetCacheManager();
  596. size_t size = m_CacheEntriesList.GetItems().size();
  597. bool reverseOrder = false;
  598. // if there are already entries in the cache, then
  599. // put the new ones in the top, so they show up first
  600. if(size)
  601. {
  602. reverseOrder = true;
  603. }
  604. // all the current values are not new any more
  605. std::set<CPropertyItem*> items = m_CacheEntriesList.GetItems();
  606. for(std::set<CPropertyItem*>::iterator i = items.begin();
  607. i != items.end(); ++i)
  608. {
  609. CPropertyItem* item = *i;
  610. item->m_NewValue = false;
  611. }
  612. for(cmCacheManager::CacheIterator i = cachem->NewIterator();
  613. !i.IsAtEnd(); i.Next())
  614. {
  615. const char* key = i.GetName();
  616. // if value has trailing space or tab, enclose it in single quotes
  617. // to enforce the fact that it has 'invisible' trailing stuff
  618. std::string value = i.GetValue();
  619. if (value.size() &&
  620. (value[value.size() - 1] == ' ' ||
  621. value[value.size() - 1] == '\t'))
  622. {
  623. value = '\'' + value + '\'';
  624. }
  625. if(!m_AdvancedValues)
  626. {
  627. if(i.GetPropertyAsBool("ADVANCED"))
  628. {
  629. m_CacheEntriesList.RemoveProperty(key);
  630. continue;
  631. }
  632. }
  633. switch(i.GetType() )
  634. {
  635. case cmCacheManager::BOOL:
  636. if(cmSystemTools::IsOn(value.c_str()))
  637. {
  638. m_CacheEntriesList.AddProperty(key,
  639. "ON",
  640. i.GetProperty("HELPSTRING"),
  641. CPropertyList::COMBO,"ON|OFF",
  642. reverseOrder
  643. );
  644. }
  645. else
  646. {
  647. m_CacheEntriesList.AddProperty(key,
  648. "OFF",
  649. i.GetProperty("HELPSTRING"),
  650. CPropertyList::COMBO,"ON|OFF",
  651. reverseOrder
  652. );
  653. }
  654. break;
  655. case cmCacheManager::PATH:
  656. m_CacheEntriesList.AddProperty(key,
  657. value.c_str(),
  658. i.GetProperty("HELPSTRING"),
  659. CPropertyList::PATH,"",
  660. reverseOrder
  661. );
  662. break;
  663. case cmCacheManager::FILEPATH:
  664. m_CacheEntriesList.AddProperty(key,
  665. value.c_str(),
  666. i.GetProperty("HELPSTRING"),
  667. CPropertyList::FILE,"",
  668. reverseOrder
  669. );
  670. break;
  671. case cmCacheManager::STRING:
  672. m_CacheEntriesList.AddProperty(key,
  673. value.c_str(),
  674. i.GetProperty("HELPSTRING"),
  675. CPropertyList::EDIT,"",
  676. reverseOrder
  677. );
  678. break;
  679. case cmCacheManager::INTERNAL:
  680. m_CacheEntriesList.RemoveProperty(key);
  681. break;
  682. }
  683. }
  684. m_OKButton.EnableWindow(false);
  685. if(cachem->GetSize() > 0 && !cmSystemTools::GetErrorOccuredFlag())
  686. {
  687. bool enable = true;
  688. items = m_CacheEntriesList.GetItems();
  689. for(std::set<CPropertyItem*>::iterator i = items.begin();
  690. i != items.end(); ++i)
  691. {
  692. CPropertyItem* item = *i;
  693. if(item->m_NewValue)
  694. {
  695. // if one new value then disable to OK button
  696. enable = false;
  697. break;
  698. }
  699. }
  700. if(enable)
  701. {
  702. m_OKButton.EnableWindow(true);
  703. }
  704. }
  705. // redraw the list
  706. m_CacheEntriesList.SetTopIndex(0);
  707. m_CacheEntriesList.Invalidate();
  708. }
  709. // copy from the list box to the cache manager
  710. void CMakeSetupDialog::FillCacheManagerFromCacheGUI()
  711. {
  712. cmCacheManager *cachem = this->m_CMakeInstance->GetCacheManager();
  713. std::set<CPropertyItem*> items = m_CacheEntriesList.GetItems();
  714. cmCacheManager::CacheIterator it = cachem->NewIterator();
  715. for(std::set<CPropertyItem*>::iterator i = items.begin();
  716. i != items.end(); ++i)
  717. {
  718. CPropertyItem* item = *i;
  719. if ( it.Find((const char*)item->m_propName) )
  720. {
  721. // if value is enclosed in single quotes ('foo') then remove them
  722. // they were used to enforce the fact that it had 'invisible'
  723. // trailing stuff
  724. if (item->m_curValue.GetLength() >= 2 &&
  725. item->m_curValue[0] == '\'' &&
  726. item->m_curValue[item->m_curValue.GetLength() - 1] == '\'')
  727. {
  728. it.SetValue(item->m_curValue.Mid(
  729. 1, item->m_curValue.GetLength() - 2));
  730. }
  731. else
  732. {
  733. it.SetValue(item->m_curValue);
  734. }
  735. }
  736. }
  737. }
  738. //! Load cache file from m_WhereBuild and display in GUI editor
  739. void CMakeSetupDialog::LoadCacheFromDiskToGUI()
  740. {
  741. cmCacheManager *cachem = this->m_CMakeInstance->GetCacheManager();
  742. if(m_WhereBuild != "")
  743. {
  744. cachem->LoadCache(m_WhereBuild);
  745. this->FillCacheGUIFromCacheManager();
  746. cmCacheManager::CacheIterator it =
  747. cachem->GetCacheIterator("CMAKE_GENERATOR");
  748. if(!it.IsAtEnd())
  749. {
  750. std::string curGen = it.GetValue();
  751. if(m_GeneratorChoiceString != curGen.c_str())
  752. {
  753. m_GeneratorChoiceString = curGen.c_str();
  754. this->UpdateData(FALSE);
  755. }
  756. }
  757. }
  758. }
  759. //! Save GUI values to cmCacheManager and then save to disk.
  760. void CMakeSetupDialog::SaveCacheFromGUI()
  761. {
  762. cmCacheManager *cachem = this->m_CMakeInstance->GetCacheManager();
  763. this->FillCacheManagerFromCacheGUI();
  764. if(m_WhereBuild != "")
  765. {
  766. cachem->SaveCache(m_WhereBuild);
  767. }
  768. }
  769. void CMakeSetupDialog::OnSize(UINT nType, int cx, int cy)
  770. {
  771. if (nType == SIZE_MINIMIZED)
  772. {
  773. CDialog::OnSize(nType, cx, cy);
  774. return;
  775. }
  776. if (m_oldCX == -1)
  777. {
  778. m_oldCX = cx;
  779. m_oldCY = cy;
  780. }
  781. int deltax = cx - m_oldCX;
  782. int deltay = cy - m_oldCY;
  783. m_oldCX = cx;
  784. m_oldCY = cy;
  785. CDialog::OnSize(nType, cx, cy);
  786. if (deltax == 0 && deltay == 0)
  787. {
  788. return;
  789. }
  790. if(m_CacheEntriesList.m_hWnd)
  791. {
  792. // get the original sizes/positions
  793. CRect cRect;
  794. m_ListFrame.GetWindowRect(&cRect);
  795. m_ListFrame.SetWindowPos(&wndTop, cRect.left, cRect.top,
  796. cRect.Width() + deltax,
  797. cRect.Height() + deltay,
  798. SWP_NOMOVE | SWP_NOZORDER);
  799. m_CacheEntriesList.GetWindowRect(&cRect);
  800. m_CacheEntriesList.SetWindowPos(&wndTop, cRect.left, cRect.top,
  801. cRect.Width() + deltax,
  802. cRect.Height() + deltay,
  803. SWP_NOMOVE | SWP_NOZORDER);
  804. m_VersionDisplay.SetWindowPos(&wndTop, 5, cy-23, 0, 0,
  805. SWP_NOSIZE | SWP_NOZORDER);
  806. deltax = int(deltax + m_deltaXRemainder);
  807. m_deltaXRemainder = float(deltax%2);
  808. m_MouseHelp.GetWindowRect(&cRect);
  809. this->ScreenToClient(&cRect);
  810. m_MouseHelp.SetWindowPos(&wndTop, cRect.left + deltax/2,
  811. cRect.top + deltay,
  812. 0, 0,
  813. SWP_NOSIZE | SWP_NOZORDER);
  814. m_Configure.GetWindowRect(&cRect);
  815. this->ScreenToClient(&cRect);
  816. m_Configure.SetWindowPos(&wndTop, cRect.left + deltax/2,
  817. cRect.top + deltay,
  818. 0, 0,
  819. SWP_NOSIZE | SWP_NOZORDER);
  820. m_CancelButton.GetWindowRect(&cRect);
  821. this->ScreenToClient(&cRect);
  822. m_CancelButton.SetWindowPos(&wndTop, cRect.left + deltax/2,
  823. cRect.top + deltay,
  824. 0, 0,
  825. SWP_NOSIZE | SWP_NOZORDER);
  826. m_OKButton.GetWindowRect(&cRect);
  827. this->ScreenToClient(&cRect);
  828. m_OKButton.SetWindowPos(&wndTop, cRect.left + deltax/2,
  829. cRect.top + deltay,
  830. 0, 0,
  831. SWP_NOSIZE | SWP_NOZORDER);
  832. m_HelpButton.GetWindowRect(&cRect);
  833. this->ScreenToClient(&cRect);
  834. m_HelpButton.SetWindowPos(&wndTop, cRect.left + deltax/2,
  835. cRect.top + deltay,
  836. 0, 0,
  837. SWP_NOSIZE | SWP_NOZORDER);
  838. }
  839. }
  840. void CMakeSetupDialog::OnGetMinMaxInfo( MINMAXINFO FAR* lpMMI )
  841. {
  842. lpMMI->ptMinTrackSize.x = 550;
  843. lpMMI->ptMinTrackSize.y = 272;
  844. }
  845. void CMakeSetupDialog::OnCancel()
  846. {
  847. if(m_CacheEntriesList.IsDirty())
  848. {
  849. if(MessageBox("You have changed options but not rebuilt, "
  850. "are you sure you want to exit?", "Confirm Exit",
  851. MB_YESNO) == IDYES)
  852. {
  853. CDialog::OnOK();
  854. }
  855. }
  856. else
  857. {
  858. CDialog::OnOK();
  859. }
  860. }
  861. void CMakeSetupDialog::OnOk()
  862. {
  863. // enable error messages each time configure is pressed
  864. cmSystemTools::EnableMessages();
  865. m_CacheEntriesList.ClearDirty();
  866. this->RunCMake(true);
  867. if (!(::GetKeyState(VK_SHIFT) & 0x1000))
  868. {
  869. CDialog::OnOK();
  870. }
  871. }
  872. void CMakeSetupDialog::OnEditchangeGenerator()
  873. {
  874. // TODO: Add your control notification handler code here
  875. }
  876. // Create a shortcut on the desktop with the current Source/Build dir.
  877. int CMakeSetupDialog::CreateShortcut()
  878. {
  879. // Find the desktop folder and create the link name
  880. HKEY hKey;
  881. if(RegOpenKeyEx(HKEY_CURRENT_USER,
  882. "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders",
  883. 0, KEY_READ, &hKey) != ERROR_SUCCESS)
  884. {
  885. AfxMessageBox ("Create shortcut: unable to find 'Shell Folders' key in registry!");
  886. return 1;
  887. }
  888. DWORD dwType, dwSize;
  889. #define MAXPATH 1024
  890. char link_name[MAXPATH];
  891. dwSize = MAXPATH;
  892. if(RegQueryValueEx(hKey,
  893. (LPCTSTR)"Desktop",
  894. NULL,
  895. &dwType,
  896. (BYTE *)link_name,
  897. &dwSize) != ERROR_SUCCESS)
  898. {
  899. AfxMessageBox ("Create shortcut: unable to find 'Desktop' registry value in 'Shell Folders' key!");
  900. return 1;
  901. }
  902. if(dwType != REG_SZ)
  903. {
  904. AfxMessageBox ("Create shortcut: 'Desktop' registry value in 'Shell Folders' key has wrong type!");
  905. return 1;
  906. }
  907. strcat(link_name, "\\CMake - ");
  908. std::string current_dir = cmSystemTools::GetFilenameName((LPCTSTR)m_WhereSource);
  909. strcat(link_name, current_dir.c_str());
  910. strcat(link_name, ".lnk");
  911. // Find the path to the current executable
  912. char path_to_current_exe[MAXPATH];
  913. ::GetModuleFileName(NULL, path_to_current_exe, MAXPATH);
  914. // Create the shortcut
  915. HRESULT hres;
  916. IShellLink *psl;
  917. // Initialize the COM library
  918. hres = CoInitialize(NULL);
  919. if (! SUCCEEDED (hres))
  920. {
  921. AfxMessageBox ("Create shortcut: unable to initialize the COM library!");
  922. return 1;
  923. }
  924. // Create an IShellLink object and get a pointer to the IShellLink
  925. // interface (returned from CoCreateInstance).
  926. hres = CoCreateInstance(CLSID_ShellLink,
  927. NULL,
  928. CLSCTX_INPROC_SERVER,
  929. IID_IShellLink,
  930. (void **)&psl);
  931. if (! SUCCEEDED (hres))
  932. {
  933. AfxMessageBox ("Create shortcut: unable to create IShellLink instance!");
  934. return 1;
  935. }
  936. IPersistFile *ppf;
  937. // Query IShellLink for the IPersistFile interface for
  938. // saving the shortcut in persistent storage.
  939. hres = psl->QueryInterface(IID_IPersistFile, (void **)&ppf);
  940. if (SUCCEEDED (hres))
  941. {
  942. // Set the path to the shortcut target.
  943. hres = psl->SetPath(path_to_current_exe);
  944. if (! SUCCEEDED (hres))
  945. {
  946. AfxMessageBox ("Create shortcut: SetPath failed!");
  947. }
  948. // Set the arguments of the shortcut.
  949. CString args = " /H=\"" + m_WhereSource + "\" /B=\"" + m_WhereBuild + "\" /G=\"" + m_GeneratorChoiceString + "\" /A=\"" + (m_AdvancedValues ? "TRUE" : "FALSE") + "\"";
  950. hres = psl->SetArguments(args);
  951. if (! SUCCEEDED (hres))
  952. {
  953. AfxMessageBox ("Create shortcut: SetArguments failed!");
  954. }
  955. // Set the description of the shortcut.
  956. hres = psl->SetDescription("Shortcut to CMakeSetup");
  957. if (! SUCCEEDED (hres))
  958. {
  959. AfxMessageBox ("Create shortcut: SetDescription failed!");
  960. }
  961. // Ensure that the string consists of ANSI characters.
  962. WORD wsz[MAX_PATH];
  963. MultiByteToWideChar(CP_ACP, 0, link_name, -1, wsz, MAX_PATH);
  964. // Save the shortcut via the IPersistFile::Save member function.
  965. hres = ppf->Save(wsz, TRUE);
  966. if (! SUCCEEDED (hres))
  967. {
  968. AfxMessageBox ("Create shortcut: Save failed!");
  969. }
  970. // Release the pointer to IPersistFile.
  971. ppf->Release ();
  972. }
  973. // Release the pointer to IShellLink.
  974. psl->Release ();
  975. return 0;
  976. }
  977. void CMakeSetupDialog::OnHelpButton()
  978. {
  979. CMakeHelp dialog;
  980. dialog.DoModal();
  981. }
  982. void CMakeSetupDialog::ShowAdvancedValues()
  983. {
  984. cmCacheManager *cachem = this->m_CMakeInstance->GetCacheManager();
  985. for(cmCacheManager::CacheIterator i = cachem->NewIterator();
  986. !i.IsAtEnd(); i.Next())
  987. {
  988. const char* key = i.GetName();
  989. if(!i.GetPropertyAsBool("ADVANCED"))
  990. {
  991. continue;
  992. }
  993. switch(i.GetType() )
  994. {
  995. case cmCacheManager::BOOL:
  996. if(cmSystemTools::IsOn(i.GetValue()))
  997. {
  998. m_CacheEntriesList.AddProperty(key,
  999. "ON",
  1000. i.GetProperty("HELPSTRING"),
  1001. CPropertyList::COMBO,"ON|OFF",
  1002. true
  1003. );
  1004. }
  1005. else
  1006. {
  1007. m_CacheEntriesList.AddProperty(key,
  1008. "OFF",
  1009. i.GetProperty("HELPSTRING"),
  1010. CPropertyList::COMBO,"ON|OFF",
  1011. true
  1012. );
  1013. }
  1014. break;
  1015. case cmCacheManager::PATH:
  1016. m_CacheEntriesList.AddProperty(key,
  1017. i.GetValue(),
  1018. i.GetProperty("HELPSTRING"),
  1019. CPropertyList::PATH,"",
  1020. true
  1021. );
  1022. break;
  1023. case cmCacheManager::FILEPATH:
  1024. m_CacheEntriesList.AddProperty(key,
  1025. i.GetValue(),
  1026. i.GetProperty("HELPSTRING"),
  1027. CPropertyList::FILE,"",
  1028. true
  1029. );
  1030. break;
  1031. case cmCacheManager::STRING:
  1032. m_CacheEntriesList.AddProperty(key,
  1033. i.GetValue(),
  1034. i.GetProperty("HELPSTRING"),
  1035. CPropertyList::EDIT,"",
  1036. true
  1037. );
  1038. break;
  1039. case cmCacheManager::INTERNAL:
  1040. m_CacheEntriesList.RemoveProperty(key);
  1041. break;
  1042. }
  1043. }
  1044. }
  1045. void CMakeSetupDialog::RemoveAdvancedValues()
  1046. {
  1047. cmCacheManager *cachem = this->m_CMakeInstance->GetCacheManager();
  1048. for(cmCacheManager::CacheIterator i = cachem->NewIterator();
  1049. !i.IsAtEnd(); i.Next())
  1050. {
  1051. const char* key = i.GetName();
  1052. if(i.GetPropertyAsBool("ADVANCED"))
  1053. {
  1054. m_CacheEntriesList.RemoveProperty(key);
  1055. }
  1056. }
  1057. }
  1058. void CMakeSetupDialog::OnAdvancedValues()
  1059. {
  1060. this->UpdateData();
  1061. if(m_AdvancedValues)
  1062. {
  1063. this->ShowAdvancedValues();
  1064. }
  1065. else
  1066. {
  1067. this->RemoveAdvancedValues();
  1068. }
  1069. }
  1070. void CMakeSetupDialog::OnDoubleclickedAdvancedValues()
  1071. {
  1072. this->OnAdvancedValues();
  1073. }
  1074. // Handle param or single dropped file.
  1075. // If the dropped file is a build directory or any file in a
  1076. // build directory, set the source dir from the cache file,
  1077. // otherwise set the source and build dirs to this file (or dir).
  1078. void CMakeSetupDialog::ChangeDirectoriesFromFile(const char* buffer)
  1079. {
  1080. // Get the path to this file
  1081. std::string path = buffer;
  1082. if (!cmSystemTools::FileIsDirectory(path.c_str()))
  1083. {
  1084. path = cmSystemTools::GetFilenamePath(path);
  1085. }
  1086. else
  1087. {
  1088. cmSystemTools::ConvertToUnixSlashes(path);
  1089. }
  1090. // Check if it's a build dir and grab the cache
  1091. std::string cache_file = path;
  1092. cache_file += "/CMakeCache.txt";
  1093. cmCacheManager *cachem = this->m_CMakeInstance->GetCacheManager();
  1094. cmCacheManager::CacheIterator it =
  1095. cachem->NewIterator();
  1096. if (cmSystemTools::FileExists(cache_file.c_str()) &&
  1097. cachem->LoadCache(path.c_str()) &&
  1098. it.Find("CMAKE_HOME_DIRECTORY"))
  1099. {
  1100. path = ConvertToWindowsPath(path.c_str());
  1101. this->m_WhereBuild = path.c_str();
  1102. path = ConvertToWindowsPath(it.GetName());
  1103. this->m_WhereSource = path.c_str();
  1104. }
  1105. else
  1106. {
  1107. path = ConvertToWindowsPath(path.c_str());
  1108. this->m_WhereSource = this->m_WhereBuild = path.c_str();
  1109. }
  1110. }
  1111. // The framework calls this member function when the user releases the
  1112. // left mouse button over a window that has registered itself as the
  1113. // recipient of dropped files.
  1114. void CMakeSetupDialog::OnDropFiles(HDROP hDropInfo)
  1115. {
  1116. UINT nb_files = DragQueryFile(hDropInfo, 0xFFFFFFFF, NULL, 0);
  1117. if (nb_files > 0)
  1118. {
  1119. UINT buffer_size = DragQueryFile(hDropInfo, 0, NULL, 0);
  1120. char *buffer = new char [buffer_size + 1];
  1121. DragQueryFile(hDropInfo, 0, buffer, buffer_size + 1);
  1122. this->ChangeDirectoriesFromFile(buffer);
  1123. delete [] buffer;
  1124. this->m_WhereSourceControl.SetWindowText(this->m_WhereSource);
  1125. this->m_WhereBuildControl.SetWindowText(this->m_WhereBuild);
  1126. this->UpdateData(FALSE);
  1127. this->OnChangeWhereSource();
  1128. this->OnChangeWhereBuild();
  1129. }
  1130. DragFinish(hDropInfo);
  1131. }