SendMessage(F4)发送到窗口时失败 [英] SendMessage (F4) fails when sending it to window

查看:271
本文介绍了SendMessage(F4)发送到窗口时失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Visual Studio 6(VC ++ 6.0)我使用的ActiveX日期控件,我无法显示扩展默认情况下( 3006216 )。或者,我试图发送一个键盘消息(F4)到我的窗口打开控件,但没有发生任何事情,当我这样做...

  // try 1:使用标准窗口句柄
LRESULT result = :: SendMessage(m_hWnd,VK_F4,0,0);
// try 2:use只使用SendMessage
result = SendMessage(VK_F4);

结果总是0 - 我可以做什么来测试/验证邮件发送?

感谢acvance中许多...



Olli

解决方案

好的 - 这个问题有两种方法(感谢所有的帮助,伙计们):



SendMessage正确的消息和正确的句柄:

  :: SendMessage(m_wndDatePicker.m_hWnd,WM_KEYDOWN,VK_F4,0); 

或者使用SendInput:

  // important:设置焦点以控制第一个
m_wndDatePicker.SetFocus();

INPUT * key;

key = new INPUT;
key-> type = INPUT_KEYBOARD;
key-> ki.wVk = VK_F4;
key-> ki.dwFlags = 0;
key-> ki.time = 0;
key-> ki.wScan = 0;
key-> ki.dwExtraInfo = 0;

SendInput(1,key,sizeof(INPUT));


Working with Visual Studio 6 (VC++ 6.0) I'm using an ActiveX datepicker control which I fail to show expanded by default (3006216). Alternatively I'm trying to send a keyboard message (F4) to my window to open up the control, but nothing happens when I do so...

// try 1: use the standard window handle
LRESULT result = ::SendMessage(m_hWnd,VK_F4, 0, 0);
// try 2: use just use the SendMessage
result = SendMessage(VK_F4);

result is always 0 - what can I do to test/verify the message sending?

Thanks in acvance a lot...

Olli

解决方案

Okay - there's two approaches on this issue (thanks for all the help, guys!):

First: Use "::SendMessage" with correct message AND correct handle:

::SendMessage(m_wndDatePicker.m_hWnd, WM_KEYDOWN, VK_F4, 0);

Alternatively use "SendInput":

// important: set focus to control first    
m_wndDatePicker.SetFocus(); 

INPUT *key;

key = new INPUT;
key->type = INPUT_KEYBOARD;
key->ki.wVk = VK_F4;
key->ki.dwFlags = 0;
key->ki.time = 0;
key->ki.wScan = 0;
key->ki.dwExtraInfo = 0;

SendInput(1,key,sizeof(INPUT));

这篇关于SendMessage(F4)发送到窗口时失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆