wndproc

Best method for storing this pointer for use in WndProc

百般思念 提交于 2019-11-27 03:13:50
I'm interested to know the best / common way of storing a this pointer for use in the WndProc . I know of several approaches, but each as I understand it have their own drawbacks. My questions are: What different ways are there of producing this kind of code: CWindow::WndProc(UINT msg, WPARAM wParam, LPARAM) { this->DoSomething(); } I can think of Thunks, HashMaps, Thread Local Storage and the Window User Data struct. What are the pros / cons of each of these approaches? Points awarded for code examples and recommendations. This is purely for curiosities sake. After using MFC I've just been

Class method for WndProc

若如初见. 提交于 2019-11-26 23:32:26
问题 This article explains brilliantly the options to call a class member WndProc. I've seen this response in stackoverflow but the main problem associating class member WndProc after CreateWindow is that some messages will be lost (including the important WM_CREATE) as explained in the mentioned article. My question : I would like to hear the opinion from an expert on which of the methods exposed below or new one is the best one (performance, maintanability, ...) to create a class member WndProc.

How to receive Plug & Play device notifications without a windows form

霸气de小男生 提交于 2019-11-26 19:53:30
I am trying to write a class library that can catch the windows messages to notify me if a device has been attached or removed. Normally, in a windows forms app I would just override the WndProc method but there is not WndProc method in this case. Is there another way I can get the messages? You'll need a window, there's no way around that. Here's a sample implementation. Implement an event handler for the DeviceChangeNotifier.DeviceNotify event to get notifications. Call the DeviceChangeNotifier.Start() method at the start of your program. Call DeviceChangeNotifier.Stop() at the end of your

How to draw custom button in Window Titlebar with Windows Forms?

拥有回忆 提交于 2019-11-26 12:44:09
问题 How do you draw a custom button next to the minimize, maximize and close buttons within the Titlebar of the Form? I know you need to use Win32 API calls and override the WndProc procedure, but I haven\'t been able to figure out a solution that works right. Does anyone know how to do this? More specifically, does anyone know a way to do this that works in Vista? 回答1: The following will work in XP, I have no Vista machine handy to test it, but I think your issues are steming from an incorrect

Best method for storing this pointer for use in WndProc

空扰寡人 提交于 2019-11-26 10:23:59
问题 I\'m interested to know the best / common way of storing a this pointer for use in the WndProc . I know of several approaches, but each as I understand it have their own drawbacks. My questions are: What different ways are there of producing this kind of code: CWindow::WndProc(UINT msg, WPARAM wParam, LPARAM) { this->DoSomething(); } I can think of Thunks, HashMaps, Thread Local Storage and the Window User Data struct. What are the pros / cons of each of these approaches? Points awarded for

How to handle WndProc messages in WPF?

≡放荡痞女 提交于 2019-11-25 23:21:17
问题 In Windows Forms, I\'d just override WndProc , and start handling messages as they came in. Can someone show me an example of how to achieve the same thing in WPF? 回答1: Actually, as far as I understand such a thing is indeed possible in WPF using HwndSource and HwndSourceHook . See this thread on MSDN as an example. (Relevant code included below) // 'this' is a Window HwndSource source = HwndSource.FromHwnd(new WindowInteropHelper(this).Handle); source.AddHook(new HwndSourceHook(WndProc));