Questions tagged [wndproc]

WndProc is a .NET method that process Windows messages. It is the .NET equivalent of the C++ WindowProc method.

Official documentation including example.

For more information on how Windows messages are processed, can consult WindowProc.

325 questions
114
votes
9 answers

How to handle WndProc messages in WPF?

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?
Shuft
  • 1,320
  • 2
  • 11
  • 11
34
votes
3 answers

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

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.…
PICyourBrain
  • 9,386
  • 26
  • 87
  • 133
30
votes
11 answers

Best method for storing this pointer for use in WndProc

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…
Mark Ingram
  • 65,792
  • 48
  • 164
  • 225
12
votes
6 answers

WPF Borderless Window issues: Aero Snap & Maximizing

I've created a borderless WPF window by setting the following window properties in XAML: ... WindowStyle="None" AllowsTransparency="True" ... This causes a number of issues: 1) Resolved: It no longer has any built-in resize functionality 2)…
Chronicide
  • 1,065
  • 1
  • 9
  • 32
11
votes
1 answer

Catch windows shutdown event in a wpf application

I have a c# WPF application that needs to save data when it closes. The Window Closing/Closed events work fine if the user closes the program, but they do not get called if the user logs off/shutdown the computer. I have found ways to catch this…
zaza
  • 820
  • 1
  • 15
  • 35
11
votes
2 answers

How do I `std::bind` a non-static class member to a Win32 callback function `WNDPROC`?

I'm trying to bind a non-static class member to a standard WNDPROC function. I know I can simply do this by making the class member static. But, as a C++11 STL learner, I'm very interested in doing it by using the tools under the
hkBattousai
  • 9,613
  • 17
  • 66
  • 114
10
votes
2 answers

Why would you override wndproc

I have been looking around and haven't really seen much information on why someone would override wndproc to handle messages. So I wondering: Why do it? When to do it? Whats its general purpose in C#? I have tried using it when seeing a serial COM…
Josh Davis
  • 123
  • 9
10
votes
2 answers

C++: How to set a new wndProc for a console application?

If I have a console application with a handle to it set up like so; HWND hWnd = GetConsoleWindow(); Then how do I set up a new wndProc for the window? I tried using SetWindowLong(hWnd, GWL_WNDPROC, (LONG)conProc); With conProc being defined…
user1219742
9
votes
4 answers

C# ListView Disable Horizontal Scrollbar

is there a way I can stop the horizontal scroll bar from ever showing up in a listview? I want the vertical scroll bar to show when needed but I want the horizontal scroll bar to never show up. I would imagine it would have something to do with…
Ozzy
  • 9,483
  • 25
  • 86
  • 132
8
votes
5 answers

C++ Changing HWND Window Procedure in runtime

I'm working in an IDE which creates a hwnd and its respective WndProc LRESULT CALLBACK. I need to change the WndProc to a custom one. I've read that SetWindowLong would do the job but I can't find any working example. For example: HWND hwnd; //My…
ProtectedVoid
  • 1,161
  • 3
  • 13
  • 36
8
votes
2 answers

How to control power button press shutdown?

I'm working on a kiosk style application where I need to control the shutdown/restart of the PC when the power button is pressed. Thanks to this post, I'm about 90% of the way there. In control panel set the acpi power button press action to…
Mark
  • 101,574
  • 16
  • 158
  • 219
7
votes
3 answers

Why would Windows hooks not receive certain messages?

Microsoft does not recommend DirectInput for keyboard and mouse input. As such, I've written an input manager class that uses SetWindowsHookEx to hook into WndProc and GetMsg. I believe the hooks are set appropriately, though they look to be the…
Sion Sheevok
  • 3,799
  • 2
  • 17
  • 37
7
votes
2 answers

Intercept single or double mouse click - only execute double click code on double click

I have a situation where I am handling both single & double mouse click events on a form. In both cases something has to be loaded, however when a double click occurs, I do not wish to execute the code attached to the single click event. Is there a…
Tony The Lion
  • 57,181
  • 57
  • 223
  • 390
7
votes
4 answers

JAVA JNA WindowProc implementation

I'm trying to write a simple application in Java that will communicate with an USB device. The USB device is made by me using a Microchip Microcontroller. The communication is rather simple, since the USB device is from the HID Class, arrays of 64…
Gabor
  • 197
  • 1
  • 8
7
votes
3 answers

Get the coordinates of a WM_NCHITTEST message?

How do I get the coordinates of a WM_NCHITTEST message in C# code? I'd love to get the fastest way, because performance is a requirement.
Vercas
  • 8,248
  • 15
  • 60
  • 102
1
2 3
21 22