PjBlog的布局模型
作者:淡月清风 日期:2009-08-31
10分钟入门InstallShield
作者:淡月清风 日期:2009-08-30
在脚本中创建窗体
作者:淡月清风 日期:2009-08-22
Set ie=CreateObject("InternetExplorer.Application")
ie.Visible=False
ie.AddressBar=False
ie.MenuBar=False
ie.StatusBar=False
ie.ToolBar=False
ie.Resizable=true
ie.Left=300
ie.Top=200
ie.Width=300
ie.Height=240
ie.Silent=True
ie.Navigate "about:blank"
ie.Document.Title="VBScript 创建的窗口"
ie.Document.body.bgColor="#ECE9D8"
ie.Document.body.style.overflow="hidden"
ie.Document.body.style.borderWidth="0"
ie.Document.body.innerHtml="<b>VBScript</b>创建的窗口测试!!<br/><br/><br/><br/>" & _
"<p align='center'><input type='button' onclick=” & _
”'vbscript:msgbox(""单击事件测试!"")' value='单击这里关闭'/></p>"
ie.Visible=True
效果如下:
效果如下:
键盘钩子
作者:淡月清风 日期:2009-08-20
1. 创建钩子
HHOOK hHookKeyBoard=SetWindowsHookEx(WH_KEYBOARD,
KeyboardProc,
NULL,
GetCurrentThreadId());
ASSERT(hHookKeyBoard!=NULL);
2. 卸载钩子
if (hHookKeyBoard!=NULL)
{
UnhookWindowsHookEx(hHookKeyBoard);
}
3. 钩子处理过程
LRESULT CALLBACK KeyboardProc(
int code,
WPARAM wParam,//virtual-key code
LPARAM lParam)//keystroke-message information
{
//此时wParam和lParam中包含了击键信息
if (HC_ACTION==code)
{
//如果要屏蔽程序继续处理某些按键,则返回TRUE,例如屏蔽ESC
if (wParam == VK_ESCAPE)
{
return TRUE;
}
//This flag is always set to 0 for WM_KEYDOWN and WM_SYSKEYDOWN messages;
//it is always set to 1 for WM_KEYUP and WM_SYSKEYUP messages.
if ( lParam & 0x80000000== 0 ) //lParam & 0x80000000
{
//WM_KEYDOWN或者WM_SYSKEYDOWN
//Specifies the context code.
//The value is 1 if the ALT key is down; otherwise, it is 0.
if ( lParam & 0x20000000 == 0) //lParam & 0x20000000
{
//Alt is down
}
if ( (GetKeyState(VK_MENU) & 0x8000) == 0x8000) // & 0x8000
{
//Alt is down
}
if ( (GetKeyState(VK_CONTROL) & 0x8000) == 0x8000) // & 0x8000
{
//Ctrl is down
}
}
else
{
// WM_KEYUP或者WM_SYSKEYUP
}
}
return CallNextHookEx(hHookKeyBoard,code,wParam,lParam);
}
ActiveX控件放在容器中后,一旦控件得到了焦点,会使容器窗体收不到键盘消息,可以通过钩子用如下方法解决:
AfxGetMainWnd()->PostMessage(WM_SYSKEYDOWN/*或者*/WM_KEYDOWN,wParam,lParam);
Tags: 键盘钩子 SetWindowsHookEx WH_KEYBOARD KeyboardProc lParam >>31 == 0






