Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

181 lines
4.1 KiB

  1. // Html2Bmp.cpp : Defines the class behaviors for the application.
  2. //
  3. // created: JurgenE
  4. //
  5. #include "stdafx.h"
  6. #include "Html2Bmp.h"
  7. #include "HtmlDlg.h"
  8. #include "FileDialogEx.h"
  9. #include "iostream.h"
  10. #ifdef _DEBUG
  11. #define new DEBUG_NEW
  12. #undef THIS_FILE
  13. static char THIS_FILE[] = __FILE__;
  14. #endif
  15. /////////////////////////////////////////////////////////////////////////////
  16. // CHtml2BmpApp
  17. BEGIN_MESSAGE_MAP(CHtml2BmpApp, CWinApp)
  18. //{{AFX_MSG_MAP(CHtml2BmpApp)
  19. // NOTE - the ClassWizard will add and remove mapping macros here.
  20. // DO NOT EDIT what you see in these blocks of generated code!
  21. //}}AFX_MSG
  22. ON_COMMAND(ID_HELP, CWinApp::OnHelp)
  23. END_MESSAGE_MAP()
  24. /////////////////////////////////////////////////////////////////////////////
  25. // CHtml2BmpApp construction
  26. CHtml2BmpApp::CHtml2BmpApp()
  27. {
  28. // TODO: add construction code here,
  29. // Place all significant initialization in InitInstance
  30. }
  31. /////////////////////////////////////////////////////////////////////////////
  32. // The one and only CHtml2BmpApp object
  33. CHtml2BmpApp theApp;
  34. /////////////////////////////////////////////////////////////////////////////
  35. // CHtml2BmpApp initialization
  36. BOOL CHtml2BmpApp::InitInstance()
  37. {
  38. // Standard initialization
  39. // If you are not using these features and wish to reduce the size
  40. // of your final executable, you should remove from the following
  41. // the specific initialization routines you do not need.
  42. #ifdef _AFXDLL
  43. Enable3dControls(); // Call this when using MFC in a shared DLL
  44. #else
  45. Enable3dControlsStatic(); // Call this when linking to MFC statically
  46. #endif
  47. CHtmlDlg dlg;
  48. CString m_HtmlFile;
  49. CString m_TemplateBitmapFile;
  50. CString m_OutputBitmapFile;
  51. CStringArray* cmdLine = new CStringArray;
  52. CEigeneCommandLineInfo cmdInfo;
  53. cmdInfo.cmdLine = cmdLine;
  54. ParseCommandLine(cmdInfo);
  55. INT_PTR m = cmdLine->GetSize();
  56. CString cTest;
  57. // read all command line options
  58. for(int j = 0; j < m; j++)
  59. {
  60. cTest = cmdLine->GetAt(j);
  61. cTest.MakeLower();
  62. if(cTest == "?") // HTML file
  63. {
  64. CString help;
  65. help = "Usage: Html2Bmp [-h HTMLfile] [-t TemplateBitmap] [-o OutputBitmap]\n\r\n\r";
  66. help += "Example: Html2Bmp -h c:\\scr\\screen1.html ; template bitmap will be extracted from screen1.html\n\r";
  67. help += " Html2Bmp -h c:\\scr\\screen1.html -t template.bmp\n\r";
  68. help += "\n\rContact: Jurgen Eidt";
  69. AfxMessageBox(help, MB_ICONINFORMATION);
  70. return FALSE;
  71. }
  72. if(cTest == "h") // HTML file
  73. {
  74. if(j+1 < m)
  75. {
  76. m_HtmlFile = cmdLine->GetAt(j+1);
  77. j++;
  78. }
  79. continue;
  80. }
  81. if(cTest == "t") // Template bitmap file
  82. {
  83. if(j+1 < m)
  84. {
  85. m_TemplateBitmapFile = cmdLine->GetAt(j+1);
  86. j++;
  87. }
  88. continue;
  89. }
  90. if(cTest == "o") // output bitmap file
  91. {
  92. if(j+1 < m)
  93. {
  94. m_OutputBitmapFile = cmdLine->GetAt(j+1);
  95. j++;
  96. }
  97. continue;
  98. }
  99. }
  100. cmdLine->RemoveAll();
  101. delete cmdLine;
  102. if(m_HtmlFile.IsEmpty())
  103. {
  104. CFileDialogEx fd(TRUE, NULL, NULL,
  105. OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
  106. "HTML files (*.html;*.htm) |*.html;*.htm|All files (*.*)|*.*||", NULL );
  107. if(fd.DoModal() == IDOK)
  108. m_HtmlFile = fd.GetPathName();
  109. else
  110. return FALSE;
  111. }
  112. dlg.m_HtmlFile = m_HtmlFile;
  113. dlg.m_TemplateBitmapFile = m_TemplateBitmapFile;
  114. dlg.m_OutputBitmapFile = m_OutputBitmapFile;
  115. dlg.DoModal();
  116. /*
  117. CHtml2BmpDlg dlg;
  118. m_pMainWnd = &dlg;
  119. int nResponse = dlg.DoModal();
  120. if (nResponse == IDOK)
  121. {
  122. // TODO: Place code here to handle when the dialog is
  123. // dismissed with OK
  124. }
  125. else if (nResponse == IDCANCEL)
  126. {
  127. // TODO: Place code here to handle when the dialog is
  128. // dismissed with Cancel
  129. }
  130. */
  131. // Since the dialog has been closed, return FALSE so that we exit the
  132. // application, rather than start the application's message pump.
  133. return FALSE;
  134. }
  135. void CEigeneCommandLineInfo::ParseParam( LPCTSTR lpszParam, BOOL bFlag, BOOL bLast )
  136. {
  137. /*
  138. lpszParam The parameter or flag.
  139. bFlag Indicates whether lpszParam is a parameter or a flag.
  140. bLast Indicates if this is the last parameter or flag on the command line.
  141. */
  142. // disable the shell from processing the user defined cmd line arguments
  143. // CCommandLineInfo::ParseParam(lpszParam, bFlag, bLast);
  144. cmdLine->Add(lpszParam);
  145. }