如何从自定义控件生成新窗口... [英] How do I spawn a new window from a custom control...

查看:78
本文介绍了如何从自定义控件生成新窗口...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个自定义控件,我想从中生成一个新窗口。然后我想将一个实质图形传递给新窗口以用作光标。



我希望从控件的OnLButtonDown消息处理程序中生成新窗口。



在对我如何做到这一点进行了大量研究后,我认为这篇文章为子窗口设置光标旨在解决最接近问题的问题我找到了其他任何东西......



http://www.cplusplus.com/forum/windows/61689/ [ ^ ]



我已经复制了回拨功能并将其放置到位。



在我的OnLButtonDown函数中我有



I have a custom control from which I want to spawn a new window. Then I want to pass a substantial graphic to the new window to use as a cursor.

I'm hoping to spawn the new window from within the control's OnLButtonDown message handler.

After having done a fair amount of research into how I might do this I think this article 'Set cursor for a child window' purports to solve most nearly the problem I have than anything else I have found...

http://www.cplusplus.com/forum/windows/61689/[^]

I have replicated the call back function and put it in place.

In my OnLButtonDown function I have

HWND hDialog = CreateWindow(WC_DIALOG, _T("Win32 testing"), WS_OVERLAPPEDWINDOW | WS_VISIBLE,
                            200, 200, 500, 400, NULL, NULL, hInst, NULL);

SetWindowLongPtrW(hDialog, DWLP_DLGPROC, &CScrollBarEx::DialogProc);
::SendMessage(hDialog, WM_INIT, 0, (LPARAM)hInst);





但是我无法通过SetWindowLongPtrW调用来通过编译器。我已经在最后一个参数上尝试过多次强制转换,但无法消除以下错误...





but am having trouble getting the SetWindowLongPtrW call to get past the compiler. I have tried a number of casts etc on the last parameter but can't eliminate the following error...

cannot convert parameter 3 from 'INT_PTR (__stdcall CScrollBarEx::* )(HWND,UINT,WPARAM,LPARAM)' to 'LONG'





我准备好接受我在这里完全超出我的深度的可能事实。如果是这种情况,那么请告诉我 - 最好有一个朝向浅水的方向...



I am prepared to accept the probable fact that I am completely out of my depth here. If this is the case then please let me know - preferably with a kindly direction towards shallower water...

推荐答案

我总是在使用像这样的函数指针时遇到问题,据我所知,目标必须是静态函数。您也不需要& (addressOf运算符)。尝试:

I always have trouble using function pointers like this, and as far as I recall the target must be a static function. You also do not need the & (addressOf operator). Try:
SetWindowLongPtr(hDialog, DWLP_DLGPROC, (LONG)CScrollBarEx::DialogProc);



注意我从 SetWindowLongPtr 中删除​​了 W 后缀,最好让预处理器添加 A W 后缀基于项目的 UNICODE 的定义设置。


Note that I have removed the W suffix from SetWindowLongPtr, it is best to let the preprocessor add the A or W suffixes based on your project's setting of the define for UNICODE.


理查德,你是我的英雄。我在我的DialogProg声明中添加了'static',现在我的代码编译了。



编辑:哦是的,我也取出了&符号。



非常感谢。
Richard, you are my hero. I have added 'static' to my declaration of DialogProg and now my code compiles.

Oh yes, and I took out the ampersand, too.

Thank you very much.


这篇关于如何从自定义控件生成新窗口...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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