问题描述
我有一个自定义控件,我想从中生成一个新窗口。然后我想将一个实质图形传递给新窗口以用作光标。
我希望从控件的OnLButtonDown消息处理程序中生成新窗口。
在对我如何做到这一点进行了大量研究后,我认为这篇文章为子窗口设置光标旨在解决最接近问题的问题我找到了其他任何东西......
[]
我已经复制了回拨功能并将其放置到位。
在我的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...
推荐答案
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
.
这篇关于如何从自定义控件生成新窗口...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!