wndproc

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

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 ...

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 of code: CWindow::WndProc(UINT msg, WPARAM wParam, LPARAM) { this->DoSomething(); } ...

Is there a .NET namespace where I can find the WIN32 API message-related #defines, like WM_COMMAND, etc

I'm overriding WndProc, so I want to write code like if (m.Msg == WM_COMMAND) my special stuff else base.WndProc(ref m) ...

What do these WndProc codes mean?

I'm trying to make a window that closes when you click outside it, and at the moment I'm looking into doing that by handling the WndProc function. None of the messages I'm getting so far seem useful, but there are a few I don't understand at all. What do codes 0x0118, 0xC123, 0xC128 and 0xC12E represent? ...

How to handle WndProc messages in WPF?

Finding WPF a steep learning curve. In good ol' Windows Forms, I'd just override WndProc, and start handling messages as they came in. Can someone show me an example of how to acheive the same thing in WPF? ...

Concept of WNDCLASSEX, good programming habits and WndProc for system classes

I understand that the Windows API uses "classes", relying to the WNDCLASS/WNDCLASSEX structures. I have successfully gone through windows API Hello World applications and understand that this class is used by our own windows, but also by Windows core controls, such as "EDIT", "BUTTON", etc. I also understand that it is somehow related t...

WM_NOTIFY and superclass chaining issue in Win32

For reference I'm using the window superclass method outlined in this article. The specific issue occurs if I want to handle WM_NOTIFY messages (i.e. for custom drawing) from the base control in the superclass I either need to reflect them back from the parent window or set my own window as the parent (passed inside CREATESTRUCT for WM_(...

WndProc with no visible form?

I want to create a form on a second thread that will receive messages in it's WndProc method. What is the recommended way to create an invisible form like this? Is setting "ShowInTaskbar=false" and "Visible=false" enough, or is there a "cleaner" way? ...

How can you get the coordinates of the "X" button in a window?

For one reason or another, I have a need to detect when the user actually clicked on the X button. What I have so far is this: protected override void WndProc(ref Message m) { if (m.Msg == (int)0xa1) //WM_NCLBUTTONDOWN { Point p = new Point((int)m.LParam); p = this.PointToClient(p); ...

Drag-able WinForm Problem

I have a windows form that can be moved around by clicking and dragging on any portion of the form. I used the method of overriding WndProc, and setting the result of the NCHITTEST function to be HTCAPTION, in order to fool the form into thinking I clicked the caption - so it enables dragging. The code for this works great, and is be...

C# Form Move Stopped Event

Is there any event in C# that fires when the form STOPS being moved. Not while its moving. If there is no event for it, is there a way of doing it with WndProc? ...

C# Form Control Move

Is there anyway to control where you can move a form? So if i move a form, it can only be moved on the vertical axis and when i try to move it horizontally, nothing happens. I dont want a buggy implementation like locationchanged or move event and poping it back inline. I no there is a way using something like a WndProc override but af...

C# Tell If Form Is Maximising

Ok heres my problem. I have a form that when it is not maximised, its maximum size has to be the total height of the components inside the form. To achieve this, i use this: private void resize_form(object sender, EventArgs e) { this.MaximumSize = new System.Drawing.Size(1000, this.panel4.Height + this.label2.Height + this.HeightMin...

Using wndproc in C# to minimize form on leftclick of taskbar.

I have a C# application that is using wndproc to get a message for a right click to the taskbar, but I also need to use a left click to the taskbar so that I can minimize my form. The message value for right click on taskbar icon is WMTaskbarRClick = 0x0313. Does anyone know what the message value is for left click on taskbar icon? ...

Handling System Shutdown in WPF

How can I override WndProc in WPF? When my window close, I try to check if the file i'm using was modified, if so, I have to promt the user for "Do you want to save changes?" message, then close the file being used and the window.However, I cannot handle the case when user restarts/shutdown/logoff when my window is still open.I cannot ov...

C# ParentControlDesigner: Resize handles don't move on Resize by WndProc

I'm creating a collapsible panel control in C# and would like the expand/collapse button to function during design-time as well as run-time. I've gotten this to work fairly well, except that when the control resizes from clicking the button, the resize handles in the designer don't move. When you click on something else and then click ...

How to use WndProc from a C++ dll?

I want to handle some SAPI messages from a DLL, which is some sort of plugin. How to handle messages/events inside a VC++ dll. The SAPI event handling is shown in the example at: http://msdn.microsoft.com/en-us/library/ms720165%28VS.85%29.aspx ...

WNDPROC declaration problem, converting from C to C++

I am converting a program from C to C++. I have the compiler set to use the __fastcall calling convention by default. I used to have a declaration line as follows: INT32 PASCAL graph_window_handler(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) Later I have: wndclass.lpfnWndProc = graph_window_handler; This all compiled...

WebBrowser control: how to suppress message: do you want to close this window

Hi, I'm new to WebBrowser control. In the current project, we use WebBrowser control to integrate with existing project. All popup windows are displayed in a new windows form. When "javascript window:close" is called on the popup window, the IE instance always prompt: do you want to close this window. We're using WndProce to check WM_Des...

Pass Window handle to a thread

My C# application is using a third party executable which runs on a separate System.Diagnostic.Process and sends Windows messages to frmMain. I need to run that process in a loop on a separate thread and I am having a problem with passing Windows handle to the thread. Is what I am trying to do possible at all and if it is possible how to...