打开基本的数学输入控件
Opening a Basic Math Input Control
我希望有人可以帮助我。我的目标是使用C 打开数学输入面板,但该面板在程序退出之前仅打开一秒钟。这是我尝试的。
- cin.get((;
- 系统("暂停"(;
- getchar((;
上述所有使程序打开的尝试都导致数学输入控制窗口弹出,但保持空白。
我使用的代码直接来自此处。
https://msdn.microsoft.com/en-us/library/windows/desktop/dd317324(v = vs.85(.aspx
我正在使用Windows 10的Visual Studio Community Edition 2017。
所有帮助都将受到赞赏。
#include "stdafx.h"
#include "micaut.h"
#include "micaut_i.c"
#include "atlcomcli.h"
using namespace std;
int main()
{
CComPtr<IMathInputControl> g_spMIC; // Math Input Control
HRESULT hr = CoInitialize(NULL);
hr = g_spMIC.CoCreateInstance(CLSID_MathInputControl);
hr = g_spMIC->EnableExtendedButtons(VARIANT_TRUE);
hr = g_spMIC->Show();
return 0;
}
您的程序显示窗口,但立即终止。您将需要运行一个消息循环以服务GUI。
单线公寓中的同步(STA(通过窗口消息实现(请参阅理解和使用COM线程模型(。这要求您在每个sta线程中运行一个消息循环。
#include <windows.h>
#include <micaut.h>
#include <micaut_i.c>
#include <atlcomcli.h>
int main() {
HRESULT hr = ::CoInitialize(NULL);
CComPtr<IMathInputControl> g_spMIC; // Math Input Control
if ( SUCCEEDED( hr ) ) {
hr = g_spMIC.CoCreateInstance(CLSID_MathInputControl);
}
if ( SUCCEEDED( hr ) ) {
hr = g_spMIC->EnableExtendedButtons(VARIANT_TRUE);
}
if ( SUCCEEDED( hr ) ) {
hr = g_spMIC->Show();
}
if ( SUCCEEDED( hr ) ) {
// Message loop for STA
MSG msg{ 0 };
while ( ::GetMessageW( &msg, nullptr, 0, 0 ) ) {
// MathInputControl sends WM_USER + 2 when it should close
if ( msg.message == ( WM_USER + 2 ) )
break;
::TranslateMessage( &msg );
::DispatchMessageW( &msg );
}
::CoUninitialize();
}
}
以响应单击 CLOSS 或 CANCEL 按钮,发送WM_USER + 2
消息的数学输入控件不是已记录的合同的一部分。适当的实现将实现_imathinputControlevents,并响应其关闭事件。
相关文章:
- 在createdialog创建的窗口中捕获用于编辑控件的OnMouseMove消息
- WinAPI 在单击第一个对话框上的按钮控件并销毁第一个对话框后创建第二个对话框
- 在编译时,C++项目抛出错误 C2228,这是预期的,因为控件在运行时未达到该点
- 如何更改窗体上所有控件的标题?[C++生成器]
- 双击更改 mfc 中列表控件中的行的颜色
- 派生的 wxPanel 控件如何访问其中包含 wxDialog 中的数据?
- 如何从代码本身向 wxwidgets 中的文本控件插入字符?
- 如何在MFC中的静态文本控件上插入图标?
- 我的主窗口在创建时或单击更新区域时是否会收到编辑控件?
- 如何在Qt C++中向自定义控件添加属性?
- C/C++ 检测双击 TVItem 的常用控件
- 是否可以将来自 Win32 EDIT 控件的文本输入存储在C++ std::string 中?
- 打开基本的数学输入控件
- 保存“编辑控件”用户输入并在应用程序重新启动C++Visual Studio时进行恢复的有效方法
- 如何处理 Win32 多行编辑控件中的输入键
- 使用SendMessage将文本输入到属于另一个进程的编辑控件中
- 子类编辑控件的输入验证以仅接受浮点数
- 是否可以在CEdit控件的纯数字和字母数字输入模式之间切换
- 推荐用于在单线编辑控件中直观指示无效输入的解决方案
- 如何将用户输入捕获为变量,执行计算,然后在不使用MFC的情况下在另一个控件中显示结果