CALLBACK过程(使用/ clr编译的函数的无效调用约定'__stdcall':pure或/ clr:safe) [英] CALLBACK procedure (invalid calling convention '__stdcall ' for function compiled with /clr:pure or /clr:safe)
问题描述
我试图弄清楚如何在C ++表格中使用回调程序
项目
下面的代码* *的工作完全在一个控制台项目
的#include" WINDOWS.H"
BOOL CALLBACK MyEnumWindowsProc(HWND HWND,LPARAM lParam的)
{
// blablabla我们现在不在乎
返回(TRUE);
}
int main()
{
EnumWindows((WNDENUMPROC)MyEnumWindowsProc,0);
}
但是在C ++表单项目中它返回以下错误:
错误C3641:''MyEnumWindowsProc'':无效的调用约定
''__ stdcall''用于使用/ clr编译的函数:pure或/ clr:safe
我已经阅读了很多关于这个主题的文章,但仍然试图找到
答案...
谢谢!
迈克
您好SQACPP!
错误C3641: '' MyEnumWindowsProc '':无效的调用约定
'' __stdcall'的功能,使用/ clr编译:纯或/ CLR:安全
将项目中的设置切换为:
公共语言运行时支持 to/ clr
-
问候
Jochen
我关于Win32的博客和.NET
http://blog.kalmbachnet.de/
9月16日凌晨2:06,Jochen Kalmbach [MVP] < nospam-
Jochen.Kalmb ... @ holzma.dewrote:
您好SQACPP
错误C3641: '' MyEnumWindowsProc '':无效的调用约定
'' __stdcall'的功能,使用/ clr编译:纯或/ CLR:安全
将项目中的设置切换为:
公共语言运行时支持到/ clr
-
问候
Jochen
我关于Win32和.NET的博客
http://blog.kalmbachnet.de/
谢谢!它与/ clr一起工作
我想知道关于CALLBACK功能的另一件事......
例如如果我想要从我的回调打印textBox中的东西
函数如何访问我的textBox?这个> textBox1.Text或
Form1-> textBox1.Text在回调中不可用
换句话说我正在尝试打印TextBox控件中每个
窗口的句柄或标题,我不知道如何从回调(EnumWindowsProc)访问我的
TextBox。
在控制台应用程序中,我可以输出(cout)每个窗口句柄
到控制台但我无法弄清楚如何以C ++形式执行此操作
项目。有人知道如何从
回调中访问我的TextBox1吗?
再次感谢!
SQACPP写道:
我想知道关于CALLBACK功能的另一件事....
例如,如果我想从我的回调打印textBox中的东西
函数如何访问我的textBox?这个> textBox1.Text或
Form1-> textBox1.Text在回调中不可用
换句话说我正在尝试打印TextBox控件中每个
窗口的句柄或标题,我不知道如何从回调(EnumWindowsProc)访问我的
TextBox。
在控制台应用程序中,我可以输出(cout)每个窗口句柄
到控制台但我无法弄清楚如何以C ++形式执行此操作
项目。有人知道如何从
回调中访问我的TextBox1吗?
SQACPP:
我不太确定托管/非托管问题,但在Win32中你会
将指向用户定义结构的指针作为LPARAM参数传递给
EnumWindows()。这个结构可以包含你喜欢的任何东西(字符串,
窗口句柄,等等)。
-
David Wilkinson
Visual C ++ MVP
Hi,
I try to figure out how to use Callback procedure in a C++ form
project
The following code *work* perfectly on a console project
#include "Windows.h"
BOOL CALLBACK MyEnumWindowsProc(HWND hwnd, LPARAM lparam)
{
// blablabla we dont care for now
return (TRUE);
}
int main()
{
EnumWindows((WNDENUMPROC) MyEnumWindowsProc,0);
}
But in the C++ form project it return the following error :
Error C3641: ''MyEnumWindowsProc'' : invalid calling convention
''__stdcall '' for function compiled with /clr:pure or /clr:safe
I already read a lot of post on the subject but still trying to find
an answer...
Thanks!
Mike
Hi SQACPP!
Error C3641: ''MyEnumWindowsProc'' : invalid calling convention
''__stdcall '' for function compiled with /clr:pure or /clr:safeSwitch the setting in your project to:
"Common language runtime support" to "/clr"
--
Greetings
Jochen
My blog about Win32 and .NET
http://blog.kalmbachnet.de/
On Sep 16, 2:06 am, "Jochen Kalmbach [MVP]" <nospam-
Jochen.Kalmb...@holzma.dewrote:Hi SQACPP!
Error C3641: ''MyEnumWindowsProc'' : invalid calling convention
''__stdcall '' for function compiled with /clr:pure or /clr:safe
Switch the setting in your project to:
"Common language runtime support" to "/clr"
--
Greetings
Jochen
My blog about Win32 and .NET
http://blog.kalmbachnet.de/Thanks! it work with /clr
I''m wondering one another thing about CALLBACK functions....
By example if i want to print something in a textBox from my callback
function how can i access to my textBox ? This->textBox1.Text or
Form1->textBox1.Text are not available in the callback
In other word i''m trying the print the handle or the caption of each
window in a TextBox control and i dont know how to access to my
TextBox from the callback (EnumWindowsProc).
In a console application I can just output (cout) each window handle
to the console but I cant figure out how to do this in a C++ form
project. Is anybody know how to access to my TextBox1 from the
callback?
Thanks again!
SQACPP wrote:I''m wondering one another thing about CALLBACK functions....
By example if i want to print something in a textBox from my callback
function how can i access to my textBox ? This->textBox1.Text or
Form1->textBox1.Text are not available in the callback
In other word i''m trying the print the handle or the caption of each
window in a TextBox control and i dont know how to access to my
TextBox from the callback (EnumWindowsProc).
In a console application I can just output (cout) each window handle
to the console but I cant figure out how to do this in a C++ form
project. Is anybody know how to access to my TextBox1 from the
callback?SQACPP:
I''m not so sure about managed/unmanaged issues, but in Win32 you would
pass a pointer to a user-defined struct as the LPARAM parameter of
EnumWindows(). This struct can contain anything you like (strings,
window handles, whatever).
--
David Wilkinson
Visual C++ MVP
这篇关于CALLBACK过程(使用/ clr编译的函数的无效调用约定'__stdcall':pure或/ clr:safe)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!