windows-messages

Get 30th bit of the lParam param in WM_KEYDOWN message

て烟熏妆下的殇ゞ 提交于 2019-12-21 20:37:35
问题 I need to get the 30th bit of the lParam param passed with the WM_KEYDOWN message. This bit as written here allows me to know if the key was pressed before. Is this code right to get it? (lParam >> 30) & 1 回答1: I would just use lParam & 0x40000000 . If that's non-zero, then b30 was set (I consider that the thirty first bit of the thirty two, by the way). And there's more likelihood that it will be a {logical-and, compare} operation rather than {shift, logical-and, compare} . Mind you, there's

Capturing WndProc message of a certain button click

醉酒当歌 提交于 2019-12-21 06:29:11
问题 I have a cancel button on my form. I want to determine inside the WndProc method that this Cancel button is clicked and write some code for it. This is absolutely necessary because otherwise I'm not able to cancel all other control validation events that are yet to be performed. Please help. .NET - 2.0, WinForms 回答1: This is how you could parse the WndProc message for a left-click on a child control: protected override void WndProc(ref Message m) { // http://msdn.microsoft.com/en-us/library

How to receive WM_POWERBROADCAST inside of a thread?

岁酱吖の 提交于 2019-12-20 02:43:15
问题 I've been beating my head for over a day now, going through tons of resources trying to figure out how to receive the WM_POWERBROADCAST Windows message from within a thread. Currently, I am using AllocateHWnd(WndMethod) inside of a stand-alone component. When I create an instance of said component in a standard VCL Forms Application, everything works fine, and I receive the WM_POWERBROADCAST message every time, as needed. However, when I create an instance of the very same component from

WM_TOUCH vs WM_POINTER

橙三吉。 提交于 2019-12-19 10:19:25
问题 Which one should I use? I'm only using Windows 8.x, so I don't care about the fact that WM_POINTER is not backwards compatible with Windows 7 etc. I also don't care about gestures; only about raw touches. WM_POINTER's only clear advantage seems to be that it unifies touch and mouse input (but that's easy to work around with WM_TOUCH because mouse events can be checked with GetMessageExtraInfo()). Ease of use is also not an issue; I've been using WM_TOUCH already and I'm just wondering if I

Form WM_KEYDOWN and WM_KEYUP messages aren't captured in WndProc

爷,独闯天下 提交于 2019-12-19 04:35:43
问题 Form keydown and keyup messages aren't captured: public partial class Form1 : Form { const int WM_KEYDOWN = 0x100; const int WM_KEYUP = 0x101; protected override void WndProc(ref Message m) { if (m.Msg == WM_KEYDOWN) { log("down"); } if (m.Msg == WM_KEYUP) { log("up"); } base.WndProc(ref m); } } 回答1: You should override ProcessCmdKey instead This example is extracted from this article public partial class Form1 : Form, IMessageFilter { const int WM_KEYDOWN = 0x100; const int WM_KEYUP = 0x101;

How to stop the automatic scrolling of a Memo control?

不打扰是莪最后的温柔 提交于 2019-12-19 02:52:11
问题 In Windows 7, a memo control ( TMemo ) will scroll automatically after text is insterted ( Memo.Lines.Add(Path); ), which I do not want, because scrolling is done by myself. How can I stop the automatic scrolling? 回答1: Normally, adding text to a memo control scrolls the memo to the bottom of the inserted text. To prevent that, call Lines.BeginUpdate before adding text, and call EndUpdate afterwards: procedure TForm1.Button1Click(Sender: TObject); begin Memo1.Lines.BeginUpdate; try Memo1.Lines

How does the message queue work in Win32?

妖精的绣舞 提交于 2019-12-18 16:52:10
问题 I read some stuff on Win32 and how the message loop works, and there's something that is still unclear to me: What exactly is stored in the message queue? The integer value that corresponds to a message ( WM_COMMAND , WM_CREATE , etc) or a pointer to a MSG structure containing the message integer value and other stuff like wParam , lParam , etc? 回答1: To answer your question narrowly, each message in the queue stores, at the least, a window handle to which the message is directed, the message

why not to send WM_PAINT manually

99封情书 提交于 2019-12-18 07:16:10
问题 I have read that I should never send WM_PAINT manually and should call InvalidateRect instead but didn't found anything about why not, however. So why not? update works with InvalidateRect but not with SendMessage(WM_PAINT) LRESULT CALLBACK window_proc(HWND wnd, UINT msg, WPARAM w_param, LPARAM l_param) { switch (msg) { case WM_PAINT: PAINTSTRUCT ps; HDC hdc = BeginPaint(wnd, &ps); Polyline(..); EndPaint(wnd, &ps); return 0; case WM_USER: // SendMessage(wnd, WM_PAINT, NULL, NULL); //

How to catch WM_DEVICECHANGE in a control other than TForm?

ぃ、小莉子 提交于 2019-12-14 02:33:21
问题 Until today I was using the following code to catch WM_DEVICECHANGE message in application main form and it worked pefectly. But if I try to use this in my custom control I don't get notifyed on device insert or remove. What is happening ? TDriveBar = class(TCustomPanel) private procedure WMDeviceChange(var Msg: TMessage); message WM_DEVICECHANGE; end; implementation procedure TDriveBar.WMDeviceChange(var Msg: TMessage); const DBT_DEVICEARRIVAL = $8000; DBT_DEVICEREMOVECOMPLETE = $8004; DBT

How to capture mouse windows messages out of the application?

折月煮酒 提交于 2019-12-13 23:58:50
问题 First of all sorry 'cause maybe this could be a too localized question for C# but anyways I didn't find info about this for VB.NET and I don't understand in a good level C# code. Basically I need to capture/process some mouse messages out of the application. How I could do it? This is just a code example of what I need to reproduce but outside the application: Protected Overrides Sub WndProc(ByRef m As Message) Select Case m.Msg Case &H200 ' WM_MOUSEMOVE MsgBox("Mouse Move") Case &H201 ' WM