cwnd

How Create derived from CWnd POP UP Window?

我的未来我决定 提交于 2020-01-06 23:52:04
问题 I created class CSurfaceWnd from CWnd by Class Wizard. I tried to create window but getting error. That's my code of creating: if(!m_pSurfaceWnd) { CString m_NameClass = AfxRegisterWndClass( CS_VREDRAW | CS_HREDRAW, ::LoadCursor(NULL, IDC_ARROW), (HBRUSH) ::GetStockObject(WHITE_BRUSH), ::LoadIcon(NULL, IDI_APPLICATION)); m_pSurfaceWnd = new CSurfaceWnd; CRect rcTemp; GetWindowRect(rcTemp); VERIFY(m_pSurfaceWnd->CreateEx(WS_EX_CLIENTEDGE, m_NameClass, NULL, WS_POPUP | WS_VISIBLE, rcTemp, mpWnd

How to redirect MFC messages to another object?

烈酒焚心 提交于 2019-12-18 05:14:08
问题 In an instance of a class derived from CWnd, is it possible to forward (redirect) all MFC messages to another object, without writing separate handlers and message mappings for each possible message? Specifically, I'd like to forward all unhandled WM_ messages to another object. If this isn't possible, then is it possible for objects to listen to events that occur within other objects? I can provide details if that would help clarify my question. Thanks. 回答1: You'll need to aim a little lower

CWnd with transparent background

心已入冬 提交于 2019-12-11 10:45:37
问题 I'd like to create a CWnd based class that will introduce a control with transparent background. There is no big deal for me to create a control and draw its content with transparent background as long as the content is static. The problem is when I want to create a control with changing content. It's becaue I don't know how to erase content of control with parent's background (which in general case may not be just a solid color). So the goal I want to achieve is to erase control before

Why is CWnd::CreateEx failing to create my window?

强颜欢笑 提交于 2019-12-11 10:44:44
问题 I'm working on a sporadic production issue that's occurring within our 32 bit MFC VC2010 application. The application is running on Windows Server 2008 R2 Standard SP1 64-bit. The issue is caused by a failure to create a CWnd derived class. When the failure occurs the AfxUnhookWindowCreate method returns false within CWnd::CreateEx. This is because the pThreadState->m_pWndInit variable is not NULL. It looks like _AfxCbtFilterHook should be setting this to NULL when HCBT_CREATEWND is hooked,

How to create C# Event to handle MFC Windows message from PostMessage()

不打扰是莪最后的温柔 提交于 2019-12-10 19:22:49
问题 I have a managed C++ DLL using WINSOCK. On receive it sends a custom message to a CWnd * via PostMessage(). This works fine when called from unmanaged C++. The target CWnd * is registered with the C++ class after construction using this code: // Registers a window (CWnd *) to receive a message when a valid // incoming data packet is received on this UdpRetrySocket. void CUdpRetrySocket::RegOnReceive(CWnd *i_pOnReceiveWnd, UINT i_RecvMsgId = WM_USER_RECV_DATA_AVAIL) { m_pOnReceiveWnd = i

Static control with WS_EX_TRANSPARENT style not repainted

不想你离开。 提交于 2019-12-08 10:00:55
问题 I am trying to create a control that implements the per-pixel alpha blend while painting a 32-bit bitmap. I extended a CWnd and use static control in the resource editor. I managed to paint the alpha channel correctly but still the static control keep painting the gray background. I overwrote the OnEraseBkgnd to prevent the control from painting the background but it didn't worked. I finally managed to do it by using WS_EX_TRANSPARENT. My problem now is that my control is placed over other

MFC: Is it safe to call CWnd methods from another thread?

不羁岁月 提交于 2019-12-07 19:41:37
问题 Actually I have two questions: Is it safe to call SendMessage from a worker thread? Do CWnd methods, like MessageBox , call API function SendMessage behind the scene? Per my understanding, when the worker thread calls SendMessage , it pushes the message into the message queue of the UI thread, and waits until this message is processed. In that case, it would be safe to do so. I'm not quite sure about this. please correct me if I was wrong. Thanks a lot. ------------------------ update -------

MFC: Is it safe to call CWnd methods from another thread?

瘦欲@ 提交于 2019-12-06 12:56:34
Actually I have two questions: Is it safe to call SendMessage from a worker thread? Do CWnd methods, like MessageBox , call API function SendMessage behind the scene? Per my understanding, when the worker thread calls SendMessage , it pushes the message into the message queue of the UI thread, and waits until this message is processed. In that case, it would be safe to do so. I'm not quite sure about this. please correct me if I was wrong. Thanks a lot. ------------------------ update ---------------------------------- As a conclusion: It's safe to call the windows API ::SendMessage and :

What is the lifetime of a CWnd obtained from CWnd::FromHandle?

落爺英雄遲暮 提交于 2019-11-30 07:27:25
问题 According to msdn, when I get a CWnd* with CWnd::FromHandle, The pointer may be temporary and should not be stored for later use. What is meant by "later use" is not clear to me. Is it only the scope of the current method? As far as I know, there is no GC in Win32! 回答1: MFC maintains a number of handle maps, from HWND to CWnd, HDC to CDC etc, which are stored in the thread state. Each handle map contains a permanent map and temporary map - permanent entries are added when you call a method

What is the lifetime of a CWnd obtained from CWnd::FromHandle?

自古美人都是妖i 提交于 2019-11-29 03:50:20
According to msdn , when I get a CWnd* with CWnd::FromHandle, The pointer may be temporary and should not be stored for later use. What is meant by "later use" is not clear to me. Is it only the scope of the current method? As far as I know, there is no GC in Win32! MFC maintains a number of handle maps, from HWND to CWnd, HDC to CDC etc, which are stored in the thread state. Each handle map contains a permanent map and temporary map - permanent entries are added when you call a method such as CWnd::Create or CDC::Attach, while temporary entries are created when you call FromHandle on a handle