How using code from MSVC C++
Unsolved
General and Desktop
-
wrote on 22 Jan 2019, 08:06 last edited by
Hi!
I have this code [this code(https://www.experts-exchange.com/articles/3096/Convert-RTF-to-HTML-and-HTML-to-RTF.html).
How I con using this code in QT?// Rtf2Html.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include "Rtf2Html2.h" #include "afxhtml.h" CWinApp theApp; // Win32 App with MFC support CRichEditCtrl g_ctlRichEdit; // the two controls CHtmlEditCtrl g_ctlEditHtml; // This is needed to load the RichEdit control from a file static DWORD CALLBACK MyStreamInCallback(DWORD dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb) { CFile* pFile = (CFile*) dwCookie; *pcb = pFile->Read(pbBuff, cb); return 0; } void LoadRtfFile( LPCTSTR pszFilename ) { wchar_t szFilter[] = L"RTF files (*.rtf)|*.rtf;|" L"All Files (*.*)|*.*||"; CFileDialog dlg(TRUE,0,pszFilename,6,szFilter ); if ( dlg.DoModal()!=IDOK ) { return; } CFile cf( dlg.GetPathName(),CFile::modeRead ); // CFile cf( pszFilename,CFile::modeRead ); EDITSTREAM es; es.dwCookie = (DWORD)&cf; es.pfnCallback = MyStreamInCallback; g_ctlRichEdit.StreamIn( SF_RTF, es ); // load from the file } int _tmain(int argc, TCHAR* argv[], TCHAR* envp[]) { AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0); AfxInitRichEdit2(); // needed for using CRichEditCtrl CWnd* pWnd = CWnd::GetDesktopWindow(); CRect r(0,0,200,200); g_ctlRichEdit.Create( ES_MULTILINE, r, pWnd, 1111); g_ctlEditHtml.Create( 0,0, r, pWnd, 2222 ); LoadRtfFile( argv[1] ); // read the RTF file into the ctrl g_ctlRichEdit.SetSel(0,-1); // select all in the RTF ctrl g_ctlRichEdit.Copy(); // copy to clipboard g_ctlEditHtml.Paste(); // paste into the Html Edit ctrl g_ctlEditHtml.SaveAs( L"C:\\temp\\test.html"); // save HTML return 0; }
-
Hi!
I have this code [this code(https://www.experts-exchange.com/articles/3096/Convert-RTF-to-HTML-and-HTML-to-RTF.html).
How I con using this code in QT?// Rtf2Html.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include "Rtf2Html2.h" #include "afxhtml.h" CWinApp theApp; // Win32 App with MFC support CRichEditCtrl g_ctlRichEdit; // the two controls CHtmlEditCtrl g_ctlEditHtml; // This is needed to load the RichEdit control from a file static DWORD CALLBACK MyStreamInCallback(DWORD dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb) { CFile* pFile = (CFile*) dwCookie; *pcb = pFile->Read(pbBuff, cb); return 0; } void LoadRtfFile( LPCTSTR pszFilename ) { wchar_t szFilter[] = L"RTF files (*.rtf)|*.rtf;|" L"All Files (*.*)|*.*||"; CFileDialog dlg(TRUE,0,pszFilename,6,szFilter ); if ( dlg.DoModal()!=IDOK ) { return; } CFile cf( dlg.GetPathName(),CFile::modeRead ); // CFile cf( pszFilename,CFile::modeRead ); EDITSTREAM es; es.dwCookie = (DWORD)&cf; es.pfnCallback = MyStreamInCallback; g_ctlRichEdit.StreamIn( SF_RTF, es ); // load from the file } int _tmain(int argc, TCHAR* argv[], TCHAR* envp[]) { AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0); AfxInitRichEdit2(); // needed for using CRichEditCtrl CWnd* pWnd = CWnd::GetDesktopWindow(); CRect r(0,0,200,200); g_ctlRichEdit.Create( ES_MULTILINE, r, pWnd, 1111); g_ctlEditHtml.Create( 0,0, r, pWnd, 2222 ); LoadRtfFile( argv[1] ); // read the RTF file into the ctrl g_ctlRichEdit.SetSel(0,-1); // select all in the RTF ctrl g_ctlRichEdit.Copy(); // copy to clipboard g_ctlEditHtml.Paste(); // paste into the Html Edit ctrl g_ctlEditHtml.SaveAs( L"C:\\temp\\test.html"); // save HTML return 0; }
@Mikeeeeee said in How using code from MSVC C++:
How I con using this code in QT?
Well, copy paste and change what needs to be changed.
Your question is too generic.
For example remove this CWinApp thing and use QApplication instead.
This code uses some libraries (Rtf2Html2, afxhtml) you will need to add them to your project if there is no replacement in Qt.
1/2