|
How do I catch windows messages in c#??
In MFC, I would do this:
// to catch windows messages
MSG msg;
while( PeekMessage( &msg,NULL,0,0,PM_REMOVE ) )
{
TranslateMessage( &msg );
DispatchMessage( &msg );
}
Thanks.
|
|
|
|
|
Within the application context, see the documentation for IMessageFilter . This installs a filter that allows you to process messages before they are dispatch from the pump.
For all applications (and a myriand of other things), you can install a Windows hook using a P/Invoked SetWindowsHookEx (and there is one or two articles about this on CP, posted just last month) but I doubt that's what you meant (just thought I'd throw in that many "old" ways are still possible).
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
in c# u can override WndProc methode of ur component.
for example u want to catch the WM_CHAR message:
<br />
private const int WM_CHAR = 0x0102<br />
<br />
protected override void WndProc(ref Message m) <br />
{<br />
switch (m.Msg)<br />
{<br />
case WM_CHAR:<br />
break; <br />
}<br />
base.WndProc(ref m);<br />
}<br />
good luck, i think it helps you to solve ur problem .
|
|
|
|
|
i want that by clicking on the button, it does not get the focus.
does any WM_message exist witch will be send wenn a component gets the focus?
|
|
|
|
|
This is the C# forum and, therefore, for .NET programming. Forget Windows messages when possible. Use the GotFocus event and set the focus to something else (you can't cancel it this way). If you just want to cancel focus, you can derive from Button and do several things, like call the protected method SetStyle such as:
public class MyButton : Button
{
public MyButton()
{
this.SetStyle(ControlStyles.Selectable, false);
}
} You could also override CreateParams and use a redefined BS_NOTIFY to remove that style from the button:
public class MyButton : Button
{
private const int BS_NOTIFY = 0x4000;
public MyButton()
{
}
protected override CreateParams CreateParams
{
get
{
System.Windows.Forms.CreateParams cp = base.CreateParams;
cb.Style &= ~BS_NOTIFY;
return cb;
}
}
}
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
thank u that is that i need LOL
|
|
|
|
|
Thanks, oOoman for the question! Thanks, Heath, for the answer.
I stumbled on the first solution (GotFocus) after fighting with the system. in fact it turns out to be unreliable, i end up using Validating and Leave events (not that i really know why, just the docs describe what the sequencing is and these events seem to occur when you think the focus events should!).
The VS system and its documentation is overall wonderful for designing UI, but inappropriate focus is bound to be a source of wasted days for people learning-- Heath, your post ought to be included in every tutorial!
", and Toto too."
(reassurance by Glenda, the good witch of the North)
|
|
|
|
|
i am happy that it was useful for u too
|
|
|
|
|
and where can i find the values of all BS_constants?
|
|
|
|
|
In applicable header files in the Platform SDK. The BS constants are found in winuser.h.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
thank u it was really fast
|
|
|
|
|
Dear, Sir
How to display store procedure list in Ms Access?
Thank You.
|
|
|
|
|
Stored procedures in MS Access? No such thing. Now, if this is an MS Access front-end (a.k.a., "project") to a SQL Server database, you can call the sp_stored_procedures stored proc (see SQL documentation for details) through a command object, or use the following SQL query directly on the current database's sysobjects table:
select name from sysobjects where xtype = 'P'
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Read the article from the link below:
http://www.devcity.net/net/article.aspx?alias=msaccess_sp
I wouldn't call it stored procedure, as it seems to have certain limitation on what it can do.
However, it has some similarities to stored procedure.
Note:
I have tested it using Access 2002 and it is basically a stored query (i.e. a query you created and saved in access database), so if you understand the SQL language, just write the statement manually and save it as a query. Give it a different name if you want, it doesn't matter.
|
|
|
|
|
When i want to alter the value of two integer variable (i and j), I use the follow
int k = i;
i = j;
j = k;
Please help me. How to alter two Button Control (button1 and button2)?
Thank You.
Sorry for bad English.
|
|
|
|
|
Why would you want to swap which variable points to which button ? What sort of button ? In a form, or in ASP.NET ? Why ?
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
You need to understand reference types. While the intrinsics like int , long , byte , char , etc. are value types (they stored the value), other variables you declare (like Button b1 = new Button() ) are reference types:
Button b1 = new Button();
Button b2 = new Button();
b1.Text = "Button 1";
b2.Text = "Button 2";
b2 = b1;
Console.WriteLine(b2.Text); Both b1 and b2 reference the Button originally assigned to b1 . If you set b1 to null , b2 still holds a reference to it. The GC (garbage collector) will clean-up the Button originally assigned to b2 because nothing references it anymore.
Don't forget the importance of reading the docs before jumping into it. It's important to understand the concepts - not just of programming, but programming with the .NET framework and object-oriented development (OOD/OOP).
If you're looking to change the strings, do what you did with the ints, but remember that strings are reference types like most other objects. Being immutable, though, changing the value in the string isn't possible so they store values in a similar fashion as value types, but they can still be referenced by many different variables:
string s1 = b1.Text;
b1.Text = b2.Text;
b2.Text = s1;
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
how do i get the listviewitem text from the form TDSS and pass into the label
TDSS DB = new TDSS();
for(int i = 0; i>DB.CustomerQ.Items.Count;i++)
{
label1.Text = DB.CustomerQ.Items[0].SubItems[0].Text;
label3.Text = DB.TaxiQ.Items[0].SubItems[2].Text;
}
this.Close();
Da Intern
|
|
|
|
|
Hi. I have a desire to create a new front end for our Web access for Exchange 2000. I plan on using a flash frontend, and a web service to do this. However, I hit a slight problem. Its easy enough to find out how to send an email by smtp through exchange, but receiving one? It appears as if this is so complex that no one bothers. There are lots of companies that are trying to sell controls that just send the email, not actually receive it - which seems a bit odd to me.
Anyway, the short of this is, if you know anything at all about what is involved in receiving an Exchange email, please let me know. I have tried finding anything useful, but so far I know how to send an email.
|
|
|
|
|
Sending an email is by far much easier than receiving one. When you send, you use the oldest protocol usually. Receiving requires support for a lot of different things, including authentication, group resolution on the server and much more.
Why are you trying to change the Exchange server like this? There are much easier ways. Exchange is meant to handle incoming email (and outgoing, but CDO on a lot of systems usually works fine for this). You can add extensions to Exchange to make it work different and route messages in many different ways. It's been tested for many years and continues to evolve. You wanna change all that with untested code? I would hope you have a damn good reason.
Even handling SPAM on the server can be done with extensions. I just saw an article about Exchange plug-ins here on CP the other day. Changing the front-end is not the right way. There are many layers of abstraction that can be overridden.
If you want to know how to receive mail, see RFC 821. There's no one answer to this. As I stated before, you have to support as much as possible to be complete and accept mail from many different types of servers and clients, and should also support ESMTP for enhanced and secure transfers, which is becoming increasingly popular these days, especially with SPAM running rampant.
Still feel like changing all this that Exchange already has in it? Make sure you read RFC 821 and the MANY, MANY RFCs that extend it before answering.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Hi. Thanks for the reply. At first look, I was going to tell you that you did not understand what I meant. Then I realised what exactly you were saying. That got me looking a bit further than I had. I found that for my webmail, I dont need to use SMTP, as IMAP4 will serve the same purpose perfectly. So thanks for getting me to look a bit further.
|
|
|
|
|
I'm not sure you see the distinction here, but I'm glad I could "prompt" you to look further. SMTP stands for the Simple Mail Transfer protocol (no offense if you already knew that). It's simply for transfering mail from one server to another, or from client to server. All your protocols like POP3, IMAPv4, HTTPMail, and any number of proprietary protocols (like Exchange) are what clients use to access mail.
Looking back at your first post, I see what you meant but since you mentioned something to the effect of writing your own SMTP service, I could only infer that you want to replace the front-end for mail transfer. Sorry about that.
As far as different client front-ends, there are a number of articles here on CP and in many other places. POP3 clients are common (because they're easier) but there's some IMAP examples out there that may be of help. Good luck!
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Well, now that the 2.0 specs are out (a few days ago) and I'm sure we all read them ( right? ), I'm curious how they'll introduce the base class libraries with generic support. I mean, it's pretty obvious the BCL was written in C# so while IL apparently supports generics, C# didn't and so the BCL didn't include generics...right?
So, upon the introduction of generics, how will this affect VB.NET and other languages targeting the CLR? Will inference be relied upon for forward compatibility with apps compiled against older libraries running against the new ones, or will they simply just be cut-off? Frankly, I'm a little leary of simply relying on inference for forward compatibility.
In any case, and perhaps someone can correct me, I'm curious why they didn't extend generics to allow interfaces to force certain constructors. Perhaps this okay, though. ISerializable wants a ctor that takes two params (everyone should know what they are) but it doesn't have to be public, limiting access by compilers ( and coders that rely only such compilers and...dare I say it...IntelliSense! ).
So, what's everyone else's thoughts? If you're a n00b, I highly suggest you at least read the C# specifications at http://msdn.microsoft.com/vcsharp/team/language/default.aspx[^].
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Heath Stewart wrote:
Well, now that the 2.0 specs are out (a few days ago) and I'm sure we all read them ( right? ), I'm curious how they'll introduce the base class libraries with generic support. I mean, it's pretty obvious the BCL was written in C# so while IL apparently supports generics, C# didn't and so the BCL didn't include generics...right?
System.Collections.Generic
Heath Stewart wrote:
In any case, and perhaps someone can correct me, I'm curious why they didn't extend generics to allow interfaces to force certain constructors
They did to a small extent with the new() specification. But it would have been nice to be able to say new(typeof(Int32)) and such.
Jared
jparsons@jparsons.org
www.prism.gatech.edu/~gte477n
|
|
|
|
|
Where did you see the namespace reference? Did I pass over it in the specs (though I wouldn't expect to find it there). I've been reading several things about it on MSDN (and now the specs) and have seen much about what to expect (other than the language changes).
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|