I'm trying to watch WndProc as it creates an application window. I want to see all the messages that it sends, but I don't want to interrupt the sending of these messages. This seems to be happening. For example, if I use this code: - protected override void WndProc(ref Message m)
-
{
-
base.WndProc(ref m);
-
if (m.Msg == 0x84)
-
{
-
backgroundWorker1.RunWorkerAsync(m);
-
-
}
-
}
-
-
private void backgroundWorker1_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
-
{
-
Message m = (Message)e.Argument;
-
ListViewItem lvi = new ListViewItem(m.HWnd.ToString());
-
lvi.SubItems.Add(m.LParam.ToString());
-
lvi.SubItems.Add(m.Msg.ToString());
-
lvi.SubItems.Add(m.Result.ToString());
-
lvi.SubItems.Add(m.WParam.ToString());
-
-
e.Result = lvi;
-
}
That just adds the message's contents to a listview so I can see it, but now it won't let me resize my form. It adds the message to the list, but apparently it doesn't send it to the program. Is there a way I can accomplish this?
4 2972
As I understood it, calling the base class WndProc allows it to be processed. I'm not sure why that's stopping it... does taking out the code where you call the background worker make it work again?
When I tried your code, I got an exception saying the background worker was too busy. Message 0x84 comes very frequently I guess.
Maybe the list view stuff slows it down too much? I did the following and seemed to have no issues. - protected override void WndProc(ref Message m)
-
{
-
base.WndProc(ref m);
-
-
if (m.Msg == 0x84)
-
{
-
string output = String.Format("{0} - {1}, {2}, {3}, {4}",
-
m.Msg.ToString("x"),
-
m.HWnd.ToString(),
-
m.LParam.ToString(),
-
m.Result.ToString(),
-
m.WParam.ToString());
-
-
Console.WriteLine(output);
-
}
-
}
0x84 is only sent when you put your mouse in the sizing area of the form. Left, Right, Top, Bottom, Top-left, Top-right, Bottom-left, and Bottom-right. If your mouse never enters the form (or does so fast enough that it never _technically_ touches the border, then 0x84 is never sent.
And I did remove the background worker and replaced it with just a regular method call and it started to work. Weird...
It's probably because I never handled the RunWorkerComplete event, so the WndProc override never got the Message object back. Maybe...
Ah, gotcha. Yea that makes sense now that you point it out...
Yea I can't say, I don't know much about the BackgroundWorker... I haven't had occasion to use it much.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Larry Woods |
last post by:
I have a "homegrown" dll that I am using in IIS (VBScript). I need to
replace it on a production server, but I don't want to stop/restart server
in order to replace the dll.
Possible?
TIA,...
|
by: Radovan Radic |
last post by:
Hello all,
I am new to .NET and a i am moving from Delphi (finally!) to C#.
Now, i am trying to develop custom TextBox for numeric input. I have done it
almost, now i need to prevent paste so...
|
by: MrNobody |
last post by:
How do I change a window's behavior so when someone clicks the little 'X' in
the upper right corner it actually hides the dialog, instead of disposing it?
|
by: han.phony |
last post by:
Hi, I am trying to intercept the message sent back by winmm.dll's
mciSendString method when playback is finished. I tried to override the
WndProc in the form but I didn't get/intercept the message,...
|
by: Phuff |
last post by:
I have an application that should run in the system tray while open.
It is supposed to be open at all times and I need it to dissapear when
the "X" button is pushed on the form...but without...
|
by: Derrick |
last post by:
Hello all;
I'm trying to create a UI that's a little atypical. In the main form's
Paint event handler, I draw an image on the form - this is what I want to by
my "real" UI. I turned off the...
|
by: Tim |
last post by:
Can you show me how to debug a whole vb program without stopping at the end
of the first form? I have many vb forms, i.e., 5 forms, that after the first
form have done its job, the next form will...
|
by: John Wright |
last post by:
First some background:
I have been asked to develop a program that access our data warehouse. It
requires a login and password to use so we created a custom control that is
placed on the form,...
|
by: vdraceil |
last post by:
Hi experts,i know that it is possible to intercept windows messages(keyboard events,mouse events etc).is it possible to stop those messages from reaching windows and modify them?
I mean can we...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |