0 Members and 1 Guest are viewing this topic.
#COMPILE EXE#DIM ALL%UNICODE = 1' // Include files for external files%USEWEBBROWSER = 1 ' // Use the WebBrowser control#INCLUDE ONCE "CWindow.inc" ' // CWindow class' // Identifier%IDC_WEBBROWSER = 101' ########################################################################################' Main' ########################################################################################FUNCTION WinMain (BYVAL hInstance AS DWORD, BYVAL hPrevInstance AS DWORD, BYVAL lpszCmdLine AS WSTRINGZ PTR, BYVAL nCmdShow AS LONG) AS LONG ' // Set process DPI aware' SetProcessDPIAware ' // Create an instance of the class LOCAL pWindow AS IWindow pWindow = CLASS "CWindow" IF ISNOTHING(pWindow) THEN EXIT FUNCTION ' // Create the main window pWindow.CreateWindow(%NULL, "AddWebBrowser Template: YouTube", 0, 0, 0, 0, 0, 0, CODEPTR(WindowProc)) ' // Set the client size pWindow.SetClientSize 450, 400 ' // Center the window pWindow.CenterWindow ' // Add a WebBrowser control and display a YouTube video LOCAL hCtl AS DWORD LOCAL s AS WSTRING ' // Build the web page. Remember to always start it with "MSHTML:". s = "MSHTML:<!DOCTYPE html>" & $CRLF s += "<html>" & $CRLF s += "<head>" & $CRLF s += "<meta http-equiv='MSThemeCompatible' content='Yes'>" & $CRLF s += "<title>YouTube video</title>" & $CRLF s += "" & $CRLF s += "</head>" & $CRLF s += "<body scroll='no' style='MARGIN: 0px 0px 0px 0px'>" s += "<object width='100%' height='100%'>" & _ "<param name='movie' value='http://www.youtube.com/v/t6Lp4w8wyy0&hl=es&fs=1'></param>" & _ "<param name='wmode' value='transparent'>" & _ "</param><embed src='http://www.youtube.com/v/t6Lp4w8wyy0&hl=es&fs=1'" & _ " type='application/x-shockwave-flash' wmode='transparent' width='100%' height='100%'>" & _ "</embed></object>" s += "" & $CRLF s += "</body>" & $CRLF s += "" & $CRLF s += "</html>" & $CRLF ' // Create the control hCtl = pWindow.AddWebBrowserControl(pWindow.hwnd, %IDC_WEBBROWSER, s, NOTHING, 0, 0, pWindow.ClientWidth, pWindow.ClientHeight) ' // Default message pump (you can replace it with your own) pWindow.DoEvents(nCmdShow)END FUNCTION' ########################################################################################' ========================================================================================' Main callback function.' ========================================================================================FUNCTION WindowProc (BYVAL hwnd AS DWORD, BYVAL uMsg AS DWORD, BYVAL wParam AS DWORD, BYVAL lParam AS LONG) AS LONG STATIC hInstance AS DWORD ' // Instance handle STATIC lpc AS CREATESTRUCT PTR ' // Pointer to the creation parameters STATIC pWindow AS IWindow ' // Reference to the IWindow interface SELECT CASE uMsg CASE %WM_CREATE ' // Pointer to the creation parameters lpc = lParam ' // Instance handle hInstance = @lpc.hInstance ' // Get a reference to the IWindow interface from the CREATESTRUCT structure pWindow = CWindow_GetObjectFromCreateStruct(lParam) EXIT FUNCTION CASE %WM_SYSCOMMAND ' // Capture this message and send a WM_CLOSE message ' // Note: Needed with some OCXs, that otherwise remain in memory IF (wParam AND &HFFF0) = %SC_CLOSE THEN SendMessage hwnd, %WM_CLOSE, 0, 0 EXIT FUNCTION END IF CASE %WM_COMMAND SELECT CASE LO(WORD, wParam) CASE %IDCANCEL ' // If the Escape key has been pressed... IF HI(WORD, wParam) = %BN_CLICKED THEN ' // ... close the application by sending a WM_CLOSE message SendMessage hwnd, %WM_CLOSE, 0, 0 EXIT FUNCTION END IF END SELECT CASE %WM_SIZE IF wParam <> %SIZE_MINIMIZED THEN ' // Resize the control pWindow.MoveWindow GetDlgItem(hwnd, %IDC_WEBBROWSER), 0, 0, pWindow.ClientWidth, pWindow.ClientHeight, %TRUE END IF CASE %WM_DESTROY ' // End the application PostQuitMessage 0 EXIT FUNCTION END SELECT ' // Pass unprocessed messages to Windows FUNCTION = DefWindowProc(hwnd, uMsg, wParam, lParam)END FUNCTION' ========================================================================================