基本信息
源码名称:C++ MFC调用Javascrip函数
源码大小:0.05M
文件格式:.zip
开发语言:C/C++
更新时间:2019-11-02
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
///-////////////////////////////////////////////////////////////////////////////////////////////////
/// Autor: David Elias Flores Escalante
/// Company: TeleTracking SAC
/// URL: http://teletrackingsac.dnsalias.net
/// Date: 24/08/2008
/// File name: main.cpp
/// License: Free, but autor and company must be mentioned.
///-////////////////////////////////////////////////////////////////////////////////////////////////
#include <windows.h>
#include "dWebCtrl.h"
#include "resource.h"
/// Declare Windows procedure
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
char szDirectorioTrabajo[MAX_PATH]={'\0'};
HINSTANCE hInst;
/// Make the class name into a global variable
char szClassName[ ] = "DaveWareBrowserApp";
dWebCtrl WebBrowser;
///-////////////////////////////////////////////////////////////////////////////////////////////////
/// WinMain
///-////////////////////////////////////////////////////////////////////////////////////////////////
int WINAPI WinMain (HINSTANCE hThisInstance,
HINSTANCE hPrevInstance,
LPSTR lpszArgument,
int nCmdShow)
{
HWND hwnd; /* This is the handle for our window */
MSG messages; /* Here messages to the application are saved */
WNDCLASSEX wincl; /* Data structure for the windowclass */
hInst=hThisInstance;
/* The Window structure */
wincl.hInstance = hThisInstance;
wincl.lpszClassName = szClassName;
wincl.lpfnWndProc = WindowProcedure; /* This function is called by windows */
wincl.style = CS_DBLCLKS; /* Catch double-clicks */
wincl.cbSize = sizeof (WNDCLASSEX);
/* Use default icon and mouse-pointer */
wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
wincl.lpszMenuName = "IDR_CUSTOM_POPUP"; /* No menu */
wincl.cbClsExtra = 0; /* No extra bytes after the window class */
wincl.cbWndExtra = 0; /* structure or the window instance */
/* Use Windows's default colour as the background of the window */
wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;
/* Register the window class, and if it fails quit the program */
if (!RegisterClassEx (&wincl))
return 0;
/* The class is registered, let's create the program*/
hwnd = CreateWindowEx (
0, /* Extended possibilites for variation */
szClassName, /* Classname */
"DaveWare: Calling Javascript functions from Plain C ", /* Title Text */
WS_OVERLAPPEDWINDOW, /* default window */
CW_USEDEFAULT, /* Windows decides the position */
CW_USEDEFAULT, /* where the window ends up on the screen */
544, /* The programs width */
375, /* and height in pixels */
HWND_DESKTOP, /* The window is a child-window to desktop */
NULL, /* No menu */
hThisInstance, /* Program Instance handler */
NULL /* No Window Creation data */
);
/* Make the window visible on the screen */
ShowWindow (hwnd, nCmdShow);
UpdateWindow (hwnd);
/* Run the message loop. It will run until GetMessage() returns 0 */
while (GetMessage (&messages, NULL, 0, 0))
{
/* Translate virtual-key messages into character messages */
TranslateMessage(&messages);
/* Send message to WindowProcedure */
DispatchMessage(&messages);
}
/* The program return-value is 0 - The value that PostQuitMessage() gave */
return messages.wParam;
}
///-////////////////////////////////////////////////////////////////////////////////////////////////
/// Windows Procedure
///-////////////////////////////////////////////////////////////////////////////////////////////////
LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message) /* handle the messages */
{
case WM_COMMAND:
switch LOWORD(wParam)
{
case IDM_COMMAND_ALERT:
WebBrowser.ExecuteScript("javascript:message('David is the best');");
break;
case IDM_FILE_EXIT:
SendMessage(hwnd,WM_DESTROY,(WPARAM)0,(LPARAM)0);
break;
}
break;
case WM_CREATE:
{
GetCurrentDirectory(MAX_PATH-1,szDirectorioTrabajo);
WebBrowser.Iniciar(hwnd,hInst);
break;
}
case WM_SIZE:
WebBrowser.OnResize(0,0);
break;
case WM_QUIT:
case WM_DESTROY:
PostQuitMessage (0); /* send a WM_QUIT to the message queue */
break;
default: /* for messages that we don't deal with */
return DefWindowProc (hwnd, message, wParam, lParam);
}
return 0;
}