¿¾ ¹öÀüÀÌ ¾ø½À´Ï´Ù1 Âü°í #ÀÛÀº ÁÖÁ¦ÁÖÁ¦¾î ; Google "Embedded browser C++ sample" or "À¥ºê¶ó¿ìÀú ÀÓº£µù"
http://www.codeproject.com/kb/com/cwebpage.aspx
library http://www.adp-gmbh.ch/win/misc/mshtml/index.html http://intel.tistory.com/2460582 http://zzoouc.tistory.com/2 2 À¥ºê¶ó¿ìÀú #2.1 uBrowser #¢¹ http://ubrowser.com/ uBrowser´Â Mozilla¿£ÁøÀ» ÅëÇØ Firefox 1.5·Î º¸ÀÌ´Â À¥ ÆäÀÌÁö¸¦ 3Â÷¿øÀ¸·Î ·»´õ¸µ ÇÒ ¼ö ÀÖ°Ô ÇÏ´Â OpenGL(tm) ÇÁ·Î±×·¥ÀÌ´Ù. À¥ÆäÀÌÁö¿¡ ´ëÇÑ Á¿ì Å©±â º¯°æ, Âî±×¸®±â, ÆĵµÇü µî ´Ù¾çÇÑ ÀÎÅÍÆäÀ̽º·Î º¯ÇüÀ» °¡´ÉÇÏ°Ô ¸¸µç´Ù.
CallumÀº 3Â÷¿ø °¡»ó Ä¿¹Â´ÏƼ ¼ÒÇÁÆ®¿þ¾î¸¦ °³¹ßÇÏ´Â SecondLifeÀÇ °³¹ßÀÚÀ̱⵵ ÇÏ´Ù. (SecondLife´Â 2006³â web2con¿¡¼ ²Ï ÁÁÀº ¹ÝÀÀÀ» ¾ò±âµµ Çß´Ù.) ±×´Â ÀÌ ÇÁ·Î±×·¥À» ¸¸µç ÀÌÀ¯°¡ 2-D ºê¶ó¿ìÀú¸¦ ´ëüÇÏ°íÀÚ ÇÏ´Â °Ô ¾Æ´Ï¶ó, ¹º°¡ Á» ´õ Àç¹Õ°í Çõ½ÅÀûÀÎ °É ¸¸µé°í ½Í¾î Çß´Ù´Â °ÍÀÌ´Ù.
2.2 °ÔÀÓ¼ÓÀÇ À¥ºê¶ó¿ìÀú Rogue #Rogue´Â Adobe AIR ±â¹ÝÀÇ °ÔÀÓ ºê¶ó¿ìÀú·Î XP¿Í ºñ½ºÅ¸¿¡¼ »ç¿ë ÇÒ ¼ö ÀÖ´Ù. CSS, ÀÚ¹Ù½ºÅ©¸³Æ®, Ç÷¡½Ã¸¦ Áö¿øÇϸç ÅÇÀº ¹°·Ð ȨÆäÀÌÁö ÁöÁ¤°ú ºÏ¸¶Å©µµ °¡´ÉÇÏ´Ù.´ÜÃàÅ°...
F11 : Rogue¿Í °ÔÀÓ°£ÀÇ ¸¶¿ì½º/Å°º¸µå ÄÁÆ®·Ñ Àüȯ
Áö¿øµÇ´Â °ÔÀÓ ¸ñ·ÏÀº...F10 : Rogue¸¦ ´ú Åõ¸íÇÏ°Ô.. F9 : Rogue¸¦ ´õ Åõ¸íÇÏ°Ô..
. Age of Conan
Áö¿øÇÏÁö ¾Ê´Â °ÔÀÓ¸ñ·Ï.... Battlefield 2 . Call of Duty . Call of Duty 2 (not on menu screens) . Civilization IV . Counter-Strike: Source . Counter-Strike 1.6 . Gears of War . Guild Wars . Half-Life 2 . Halo: Combat Evolved . Neverwinter Nights . Neverwinter Nights 2 . Portal . Unreal Tournament III . Warhammer 40,000 . Warhammer: Dawn of War . World of Warcraft
. Call of Duty 4
°ÔÀÓÇÏ¸é¼ ºí·Î±× ´ñ±ÛÀ» ´Þ°Å³ª À¯Æ©ºê ºñµð¿Àµµ º¼ ¼ö ÀÖ´Ù.. Diablo 2 . Doom 3 . Quake 4 . Starcraft . Warcraft III . Wolfenstein: Enemy Territory
IWebBrowser::Navigate Post µ¥ÀÌÅÍ º¸³»±â
À̰͵µ ¿ª½Ã Á» Çì¸å´Ù. IWebBrowser::Navigate ÇÔ¼ö¸¦ ÀÌ¿ëÇØ µ¥ÀÌÅ͸¦ Post ÇؾßÇß´Ù. À̰͵µ ½ÃÀ۽ô ¾öû °£´ÜÇÒ °ÍÀ¸·Î »ý°¢Çß´Ù. ±Ùµ¥ ¼Ò½º¸¦ ¾Æ¹«¸® ºÁµµ À߸øµÈ Á¡Àº ¾ø´Âµ¥ ÀÛµ¿ÀÌ µÇÁú ¾Ê¾Ò´Ù... ³°¨... Navigate ¸Þ¼µå¸¦ È£ÃâÇÒ ¶§ ÆĶó¹ÌÅÍÁß Headers Ç׸ñÀÌ ÀÖ´Ù. ÀÌ°ÍÀº À¥¼¹ö¿¡ HTTP Çì´õ¸¦ Æ÷ÇÔÇÏ´Â °ªÀÌ´Ù. ³ª´Â ´ç¿¬È÷ HTTP Post °ª¸¸ ³Ö¾îÁÖ¸é µÉ°ÍÀ¸·Î »ý°¢Çß´Ù.
"µ¥ÀÌÅÍ Post ÇÒ¶§´Â ¹Ýµå½Ã Çì´õ ³»¿ëµµ ³Ö¾îÁÖ¾î¾ß ÇÑ´Ù."
´ÙÀ½Àº ¼Ò½ºÀÌ´Ù.
#include <Exdisp.h>
// CString sUrl = "c:/Help.htm"; // cf. file://c:/help.htm
CString sUrl = "http://www.naver.com"; BSTR bstrUrl = sUrl.AllocSysString();
VARIANT vtHeader={0}, vtPost={0}, vtEmpty={0};
CString sHeader = "Content-Type: application/x-www-form-urlencoded\n";
vtHeader.vt = VT_BSTR; vtHeader.bstrVal = sHeader.AllocSysString();
LPCTSTR szPostData = "postdatatest";
int nPostLen = strlen(szPostData);
LPSTR pPostData;
HRESULT hr = SafeArrayAccessData(psa, (void**)&pPostData); memcpy(pPostData, szPostData, nPostLen); hr = SafeArrayUnaccessData(psa);
IWebBrowser2 *pWeb;
CoCreateInstance(CLSID_InternetExplorer, NULL, CLSCTX_LOCAL_SERVER,
IID_IWebBrowser2, (void**)&pWeb);
pWeb->Navigate(bstrUrl, &vtEmpty, &vtEmpty, &vtPost, &vtHeader);pWeb->Release();
ÀÌ»óÀÔ´Ï´Ù.
3.2 IWebBrowser2¸¦ ÀÌ¿ëÇؼ ºê¶ó¿ìÀú¸¦ ¶ç¿ï ¶§, ºê¶ó¿ìÀú¸¦ ´Ù¸£°Ô Çغ¸ÀÚ #¿ø¹® ; http://intel.tistory.com/2460582
IWebBrowser2* pWebBrowser = NULL;
BSTR bstrURL = NULL; BSTR bstrHeader = NULL; VARIANT vtPostData = {0}; VARIANT vtEmpty; VARIANT vtHeader;
bstrURLÇÏ°í, bstrHeader´Â ÇÊ¿äÇÑ °ªÀ¸·Î ä¿ì°í...(Navigate ÇÒ ¶§ ÇÊ¿ä)
±× ´ÙÀ½ »ý¼º.
hr = ::CoCreateInstance( __uuidof(InternetExplorer), NULL, CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER,
¶ç¿ï À¥ ºê¶ó¿ìÀúÀÇ Å©±â¸¦ ¼³Á¤
pWebBrowser->put_Left(200);
´Ù¸¥ °ªµéµµ ¼³Á¤ ȤÀº µðÆúÆ®·Î ³õ°í »ç¿ë.pWebBrowser->put_Top(300); pWebBrowser->put_Width(578); pWebBrowser->put_Height(298);
VariantInit( &vtEmpty );
±× ´ÙÀ½ ºê¶ó¿ìÀú¿¡¼ ÇÊ¿ä¾ø´Â °Íµé »èÁ¦.VariantInit( &vtPostData ); VariantInit( &vtHeader ); V_VT( &vtHeader ) = VT_BSTR; V_BSTR( &vtHeader ) = bstrHeader;
pWebBrowser->put_ToolBar(VARIANT_FALSE); // ÀͽºÇ÷ξî Åø¹Ù ¾ø¾Ú
ÀÌ·¸°Ô ÇÏ°í NavigatepWebBrowser->put_MenuBar(VARIANT_FALSE); // ¸Þ´º¹Ù ¾ø¾Ú pWebBrowser->put_AddressBar(VARIANT_FALSE); // ÁÖ¼Òâ ¾ø¾Ú pWebBrowser->put_StatusBar(VARIANT_FALSE); // »óŹ٠¾ø¾Ú pWebBrowser->put_Resizable(VARIANT_FALSE); //¸®»çÀÌÁî ºÒ°¡ pWebBrowser->put_Visible ( (VARIANT_BOOL) TRUE );
hr = pWebBrowser->Navigate( bstrURL, &vtEmpty, &vtEmpty, &vtPostData, &vtHeader );
À§ ó·³ Çϸé Åø¹Ùµµ ¾ø°í, ¸Þ´º¹Ùµµ ¾ø°í, ÁÖ¼Òâµµ ¾ø°í, »óŹٵµ ¾ø°í, ¸®»çÀÌÁîµµ ¾ÊµÇ´Â ºê¶ó¿ìÀú°¡ ¶á´Ù.
¸¶Áö¸·À¸·Î...
HWND hIE;
À§ ÄÚµå´Â ¹æ±Ý Àü¿¡ ¶ç¿î ºê¶ó¿ìÀú¸¦ ÃÖ»ó´Ü¿¡ ¶ç¿ì°Ô ÇÏ´Â ÄÚµåÀÌ´Ù.hr=pWebBrowser->get_HWND((long *)&hIE); ::SetWindowPos(hIE, HWND_TOPMOST, 0, 0,0 ,0 , SWP_NOMOVE | SWP_NOSIZE);
int WINAPI PostPageUseIE( IN LPCTSTR pszURL, IN LPBYTE pbPostData, IN LPCTSTR pszRes )
{
int result;
finish:IWebBrowser2* pWebbrowser = NULL; COleVariant vtURL; COleVariant vtEmpty; IDispatch* pDispatch = NULL; IHTMLDocument2* pHtmlDocument2 = NULL; int i; IHTMLElement* pHtmlElement = NULL; BSTR bstrText; CString sText; READYSTATE rs; VARIANT vtPostData; SAFEARRAY* psa = NULL; LPBYTE pbValue = NULL; COleVariant vtHeader( _T( "Content-Type: application/x-www-form-urlencoded" ) ); CString strRes = pszRes/*_T("Status=Success")*/; CString sURL = pszURL; // // IE °´Ã¼ »ý¼º // result = CoCreateInstance( CLSID_InternetExplorer, if( FAILED( result ) ) {
result = ERRORMSG( result, _T( "Can not create Webbrowser control" ) );
}STACKTRACE( _T( "CoCreateInstance()" ) ); goto finish; // // È£ÃâµÇ´Â ºê¶ó¿ìÀú ȸéÀ» º¼·Á¸é TRUE ·Î ¼³Á¤ // pWebbrowser->put_Visible( FALSE ); // // ¹ÙÀ̳ʸ® POST DATA ¸¦ Àü´ÞÇϱâ À§Çؼ SAFEARRAY¸¦ »ý¼ºÇÑ´Ù // psa = SafeArrayCreateVector( VT_UI1, 0, strlen( (LPSTR)pbPostData ) ); if( psa == NULL ) {
result = ERRORMSG( ERROR_NOT_ENOUGH_MEMORY, NULL );
}DEBUGINFO( _T( "mem size = %d" ), strlen( (LPSTR)pbPostData ) ); STACKTRACE( _T( "SafeArrayCreateVector()" ) ); goto finish; SafeArrayAccessData( psa, (LPVOID*)&pbValue ); CopyMemory( pbValue, pbPostData, strlen( (LPSTR)pbPostData ) ); SafeArrayUnaccessData( psa ); vtPostData.vt = VT_ARRAY; vtPostData.parray = psa; // // URL ¼³Á¤ // vtURL = sURL; // // NULL °ª ¼³Á¤ // vtEmpty.Clear(); // // HTTP ¿äû // result = pWebbrowser->Navigate2( vtURL, vtEmpty, vtEmpty, &vtPostData, vtHeader ); if( FAILED( result ) ) {
result = ERRORMSG( result, _T( "Can not navigate license issue url" ) );
}STACKTRACE( _T( "IWebBrowser2::Navigate2()" ) ); goto finish; // // 10Ãʵ¿¾È ºê¶ó¿ìÀú°¡ ¸ðµç ÀÏÀ» ÇÒ ¶§±îÁö ´ë±â // rs = READYSTATE_UNINITIALIZED; for( i = 0; i < 100; i++ ) { } if( rs != READYSTATE_COMPLETE ) {
//
}// ¹®¼¸¦ ´Ù ¹ÞÁö ¸øÇÔ. // result = ERRORMSG( ERROR_CAN_NOT_COMPLETE, _T( "Can not download license issuer url" ) ); goto finish; // // ¼º°øÇß´ÂÁö ½ÇÆÐÇß´ÂÁö ¾Ë±â À§Çؼ HTML ³»¿ëÀ» ºÁ¾ß ÇÑ´Ù // result = pWebbrowser->get_Document( &pDispatch ); if( FAILED( result ) ) {
result = ERRORMSG( result, _T( "Can not get document of IWebbrowser2" ) );
}STACKTRACE( _T( "IWebbrowser2::get_Document()" ) ); goto finish; result = pDispatch->QueryInterface( IID_IHTMLDocument2, (void**)&pHtmlDocument2 ); if( result != 0 ) {
result = ERRORMSG( result, _T( "Can not query IHtmlDocument2 interface from IDispatch" ) );
}STACKTRACE( _T( "IDispatch::QueryInterface()" ) ); goto finish; result = pHtmlDocument2->get_body( &pHtmlElement ); if( result != 0 ) {
result = ERRORMSG( result, _T( "Can not get body html" ) );
}STACKTRACE( _T( "IHTMLDocument2::get_body()" ) ); goto finish; result = pHtmlElement->get_innerText( &bstrText ); if( result != 0 ) {
result = ERRORMSG( result, _T( "Can not get inner text of html" ) );
}STACKTRACE( _T( "IHTMLElement::get_innerText()" ) ); goto finish; sText = bstrText; // // HTML ¹®¼ ³»¿ë Áß¿¡¼ ¼º°ø ¸Þ¼¼Áö°¡ ÀÖ´ÂÁö È®ÀÎ // if( sText.Find( strRes ) < 0 ) {
result = ERRORMSG( ERROR_INTERNAL_ERROR, _T( "invalid response." ) );
}DEBUGINFO( sText ); goto finish; result = 0;
if( result != 0 )
}{
STACKTRACE( _T( "PostPageUseIE()" ) );
}if( psa != NULL ) {
SafeArrayDestroy( psa );
}if( pWebbrowser != NULL )
pWebbrowser->Quit();
SAFE_RELEASE( pHtmlElement );SAFE_RELEASE( pHtmlDocument2 ); SAFE_RELEASE( pDispatch ); SAFE_RELEASE( pWebbrowser ); return result;
ÀÌ ÇÔ¼öÀÇ ÀåÁ¡Àº IE ControlÀ» ±×´ë·Î »ç¿ëÇϱ⠶§¹®¿¡, ÁÖ¼Ò°¡ http, https ±¸ºÐÀ» ÇÏÁö ¾Ê°í, Àß µ¿ÀÛÇÑ´Ù. ÇÏÁö¸¸ »ç¿ë½Ã âÀÇ Æ÷Ä¿½º°¡ ±ôºýÀδٴ ´ÜÁ¡µµ ÀÖ±ä ÇÔ.
LPBYTE PostWebPage( LPCTSTR pszURL , LPBYTE pbPostData )
{
int result;
finish:DWORD dwLength; int nContentLength; BYTE baBuffer[ 64 ]; DWORD dwServiceType; INTERNET_PORT nPort; HINTERNET hInternet = NULL; HINTERNET hConnect = NULL; HINTERNET hRequest = NULL; CString sServer, sObject; CString strHeaders = _T( "Content-Type: application/x-www-form-urlencoded" ); LPBYTE pbContent = NULL; CString sLicenseXML; LPSTR pszFirst = NULL, pszLast = NULL; CString sLog ; DWORD dwFlags = 0 ; CString ss; // // URL È£Ãâ // hInternet = InternetOpen( _T( "Mozilla" ), INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0 ); if( hInternet == NULL ) { } result = AfxParseURL( pszURL, dwServiceType, sServer, sObject, nPort ); if( result == FALSE ) { } hConnect = InternetConnect( hInternet, sServer, nPort, NULL, NULL, INTERNET_SERVICE_HTTP, 0, NULL ); if( hConnect == NULL ) { } // // ¹Ýµå½Ã Æ÷½ºÆ® ¹æ½ÄÀ¸·Î // hRequest = HttpOpenRequest( hConnect, _T( "POST" ), sObject, NULL, NULL, NULL,INTERNET_FLAG_NO_CACHE_WRITE , NULL ); if( hRequest == NULL ) { } // // À¥¼¹ö¿¡ µ¥ÀÌŸ¸¦ Àü¼Û // result = HttpSendRequest( hRequest, strHeaders, strHeaders.GetLength(), (LPVOID)pbPostData, strlen( (LPSTR)pbPostData ) ); if( result == FALSE ) { } // // HTTP STATUS ÄÚµå // dwLength = sizeof( baBuffer ); result = HttpQueryInfo( hRequest, HTTP_QUERY_STATUS_CODE, (LPVOID)baBuffer, &dwLength, NULL ); if( result == FALSE ) { } if( strcmp( (LPCSTR)baBuffer, "200" ) != 0 ) {
//
}// HTTP Request °¡ ½ÇÆÐÇß´Ù. ¿Ö??? // //CString s = (LPCSTR)baBuffer; result = ERROR_HTTP_INVALID_QUERY_REQUEST; goto finish; dwLength = sizeof( baBuffer ); result = HttpQueryInfo( hRequest, HTTP_QUERY_CONTENT_LENGTH , (LPVOID)baBuffer, &dwLength, NULL ); if( result == FALSE ) { } nContentLength = atoi( (LPSTR)baBuffer ); pbContent = new BYTE[ nContentLength + 1 ]; if( pbContent == NULL ) {
result = ERROR_NOT_ENOUGH_MEMORY;
}goto finish; result = InternetReadFile( hRequest, pbContent, nContentLength, &dwLength ); if( result == FALSE ) { } pbContent[ nContentLength ] = '\0'; result = 0;
if( hInternet != NULL )
}
InternetCloseHandle( hInternet );
if( hConnect != NULL )
InternetCloseHandle( hConnect );
if( hRequest != NULL )return pbContent;
»ç¿ë¹æ¹ýÀº ¾Æ·¡¿Í °°ÀÌ...
LPBTYEpbPostData = new BYTE[ 512 ];
CString strRes; memset( pbPostData, 0, sizeof( BYTE ) * 512 ); sprintf( (char*)pbPostData, "id=%s&pw=%s", loginDlg.GetID(), strPass64 );
strRes = PostWebPage( À¥ÁÖ¼Ò, pbPostData );
strRes¿¡ Post¹æ½ÄÀ¸·Î ³¯¸° À¥ÆäÀÌÁöÀÇ ÀÀ´ä°ªÀÌ µé¾î¿Â´Ù. LPBYTEÇüÀ» ¸®ÅÏÇÏÁö¸¸, ÀÚµ¿Çüº¯È¯ µÇ¾î µé¾î°£´Ù.
3.5 ÆÄÀÏ ¹ÞÀ» ¶§ Æú´õ ¼±ÅÃÇϴ â #Ãâó ; http://intel.tistory.com/2460623long SelectDownloadFolder() {
// TODO: Add your dispatch handler code here
}int result; TCHAR szDir[ 4096 ]; BROWSEINFO bi; LPITEMIDLIST pidl = NULL; ZeroMemory( &bi, sizeof( BROWSEINFO ) ); bi.hwndOwner = this->GetSafeHwnd(); bi.lpfn = NULL; bi.lParam = 0; bi.lpszTitle = _T( "Choose download folder" ); bi.ulFlags = BIF_NEWDIALOGSTYLE; pidl = SHBrowseForFolder( &bi ); if( pidl != NULL ) {
//
// »ç¿ëÀÚ°¡ µð·ºÅ丮¸¦ ¼±ÅÃÇß´Ù // result = SHGetPathFromIDList( pidl, szDir ); //szDir¿¡ ÀúÀåµÈ Æú´õ°¡ µé¾î°¨. 3.6 Programming the MSHTML Web Browser Control with C++ #http://www.adp-gmbh.ch/win/misc/mshtml/index.html
It is possible to render HTML in an ordinary Windows program with MSHTML. This makes it possible to have a web look and feel in a program. Because I think this is quite interesting, I decided to write some C++ classes that make it possible to use MSHTML in an easy way. I found some ideas on how to do that with
Embed an HTML Control in your own window using plain C .
Test program
This test programm displays a simple HTML document in a window. The HTML document consists of three links. These links are fully operational.
MSHTMLTest.cpp #include <windows.h> #include "HTMLWindow.h" int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE /*unused__*/, LPSTR /*lpszCmdLine*/, int /*nCmdShow*/) { HTMLWindow* html_window = new HTMLWindow ( // Parameter html_or_url: "<html><head>" "<title>MSHTMLTest</title>" // seems a little useless in this context "</head><body>" "<h1>This is a test</h1>" "I offer the following links:" "<ul>" "<li><a href='http://www.google.com'>www.google.com</a>" "<li><a href='http://www.adp-gmbh.ch'>www.adp-gmbh.ch</a>" "<li><a href='http://www.yahoo.com'>www.yahoo.com</a>" "</ul>" "</body></html>", // Parameter title "MSHTMLTest", hInstance, false // indicates: this not an url, but html ); MSG msg; while (GetMessage(&msg, 0, 0, 0)) { TranslateMessage(&msg); if (msg.message >= WM_KEYFIRST && msg.message <= WM_KEYLAST) { ::SendMessage(html_window->hwnd_, msg.message, msg.wParam, msg.lParam); } DispatchMessage(&msg); } return 0; }Displaying an HTML document
The following program displayes an URL. So, it can be called like:
DisplayHTML.exe www.your-favorite-url.zzzIf the URL happens to be an HTML file on the harddisk, call it like so: DisplayHTML.exe file://c:/path/to/your/document.htmlDisplayHTML.cpp #include <windows.h> #include "HTMLWindow.h" int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int) { if (__argc < 2) { ::MessageBox(0, "DisplayHTML.exe html-document", "Specify HTML document to be displayed", 0); return -1; } HTMLWindow* html_window = new HTMLWindow ( __argv[1], "DisplayHTML", hInstance, true // it is an url ); MSG msg; while (GetMessage(&msg, 0, 0, 0)) { TranslateMessage(&msg); if (msg.message >= WM_KEYFIRST && msg.message <= WM_KEYLAST) { ::SendMessage(html_window->hwnd_, msg.message, msg.wParam, msg.lParam); } DispatchMessage(&msg); } return 0; } Downloading MSHTMLTest The sources (including makefile) as well as the exes can be downloaded here: MSHTMLTest. I compiled it with the mingw compiler. |
ÇÒ ¼ö ÀÖ´Ù°í ¹Ï´Â »ç¶÷ÀÌ ¼º°øÇÑ´Ù(¿ùÅÍ D.À©Æ²) µüÁö_Softimage Ã¥°¥ÇÇ_book_KnowHow edu2014_Storytelling HelpOnLists |