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.

348 questions
121
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,400
  • 2
  • 11
  • 11
38
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
  • 71,849
  • 51
  • 176
  • 230
35
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,976
  • 26
  • 91
  • 136
13
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,112
  • 1
  • 9
  • 32
13
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
12
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
  • 892
  • 1
  • 18
  • 37
12
votes
6 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
  • 10,285
  • 26
  • 94
  • 138
12
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
  • 10,583
  • 18
  • 76
  • 124
11
votes
5 answers

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,293
  • 3
  • 17
  • 42
11
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
  • 133
  • 9
10
votes
2 answers

Where to call base.WndProc() or base.DefWndProc()?

I have some questions regarding overriding the WndProc method of a Windows Form / NativeWindow. What exactly is the difference between WndProc and DefWndProc (edit: I thought it is called "DefaultWndProc" before)? I can only override WndProc, but…
Ray
  • 7,940
  • 7
  • 58
  • 90
8
votes
1 answer

Win32 Capturing child Window messages in parent window

In my Win32 application, a child window is created by a third party SDK.The Window creation process is transparent and I cannot associate a WndProc method with the child Window. I want to be able to capture child window messages in parent window.…
Farooq Zaman
  • 495
  • 1
  • 6
  • 21
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
  • 106,305
  • 20
  • 172
  • 230
7
votes
1 answer

hook into wndproc of another application?

I have a small question hoping someone will help me. Is there any way to hook into other applications WNDPROC? The situation is that I want to insert a menu in the other app menubar and I want to define the commands for every menu item. I was able…
K7rim
  • 147
  • 10
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
  • 4,057
  • 2
  • 21
  • 37
1
2 3
23 24