Click here to Skip to main content
15,897,371 members
Home / Discussions / C#
   

C#

 
GeneralRe: Grid View Event.. Pin
Rahul DSG14-Jun-09 21:31
Rahul DSG14-Jun-09 21:31 
AnswerRe: Grid View Event.. Pin
deepseeindeepsy14-Jun-09 21:49
deepseeindeepsy14-Jun-09 21:49 
GeneralRe: Grid View Event.. Pin
Rahul DSG14-Jun-09 21:56
Rahul DSG14-Jun-09 21:56 
GeneralRe: Grid View Event.. Pin
Mycroft Holmes14-Jun-09 22:00
professionalMycroft Holmes14-Jun-09 22:00 
GeneralRe: Grid View Event.. Pin
deepseeindeepsy14-Jun-09 22:02
deepseeindeepsy14-Jun-09 22:02 
AnswerRe: Grid View Event.. Pin
Henry Minute15-Jun-09 0:14
Henry Minute15-Jun-09 0:14 
AnswerRe: Grid View Event.. Pin
Kaushal Arora15-Jun-09 2:53
Kaushal Arora15-Jun-09 2:53 
QuestionWhy I can't get the WM_CREATE msg in the PreFilterMessage method Pin
hwswin14-Jun-09 19:49
hwswin14-Jun-09 19:49 
I can get the WM_CREATE msg in WndProc when I click button1,but it didn't fired at the PreFilterMessage.

Follow is the source code.Thanks!

    static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            filter ft = new filter();
            Application.AddMessageFilter(ft);

            Form1 f = new Form1();
            f.Show();
            Application.Run();
        }
    }

    public class filter : IMessageFilter
    {

        #region IMessageFilter 成员

        const int WM_CREATE = 0x00001;
        public bool PreFilterMessage(ref Message m)
        {
<code>            if (m.Msg == WM_CREATE)
            {
                MessageBox.Show("A");
                return true;
            }</code>
            return false;
        }

        #endregion
    }

    public partial class Form1 : Form
    {
        #region Designer
        /// <summary>
        /// 必需的设计器变量。
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// 清理所有正在使用的资源。
        /// </summary>
        /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows 窗体设计器生成的代码

        /// <summary>
        /// 设计器支持所需的方法 - 不要
        /// 使用代码编辑器修改此方法的内容。
        /// </summary>
        private void InitializeComponent()
        {
            this.button1 = new System.Windows.Forms.Button();
            this.SuspendLayout();
            // 
            // button1
            // 
            this.button1.Location = new System.Drawing.Point(0, 0);
            this.button1.Name = "button1";
            this.button1.Size = new System.Drawing.Size(75, 23);
            this.button1.TabIndex = 0;
            this.button1.Text = "button1";
            this.button1.UseVisualStyleBackColor = true;
            this.button1.Click += new System.EventHandler(this.button1_Click);
            // 
            // Form1
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(609, 265);
            this.Controls.Add(this.button1);
            this.Name = "Form1";
            this.Text = "Form1";
            this.Load += new System.EventHandler(this.Form1_Load);
            this.ResumeLayout(false);

        }

        #endregion

        private System.Windows.Forms.Button button1;
        #endregion

        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
        }


        private void button1_Click(object sender, EventArgs e)
        {
            Form1 f = new Form1();
            f.Show();
        }

        const int WM_CREATE = 0x00001;
        protected override void WndProc(ref Message m)
        {
<code>            if (m.Msg == WM_CREATE)
            { MessageBox.Show("B"); }
            base.WndProc(ref m);</code>
        }
    }

AnswerRe: Why I can't get the WM_CREATE msg in the PreFilterMessage method Pin
N a v a n e e t h14-Jun-09 20:58
N a v a n e e t h14-Jun-09 20:58 
GeneralRe: Why I can't get the WM_CREATE msg in the PreFilterMessage method Pin
hwswin14-Jun-09 21:21
hwswin14-Jun-09 21:21 
GeneralRe: Why I can't get the WM_CREATE msg in the PreFilterMessage method Pin
hwswin14-Jun-09 22:19
hwswin14-Jun-09 22:19 
GeneralRe: Why I can't get the WM_CREATE msg in the PreFilterMessage method Pin
N a v a n e e t h14-Jun-09 22:34
N a v a n e e t h14-Jun-09 22:34 
GeneralRe: Why I can't get the WM_CREATE msg in the PreFilterMessage method Pin
N a v a n e e t h14-Jun-09 23:11
N a v a n e e t h14-Jun-09 23:11 
AnswerRe: Why I can't get the WM_CREATE msg in the PreFilterMessage method Pin
hwswin15-Jun-09 15:25
hwswin15-Jun-09 15:25 
QuestionTake picture from Webcam (problem) Pin
S K Y14-Jun-09 18:04
S K Y14-Jun-09 18:04 
AnswerRe: Take picture from Webcam (problem) Pin
Christian Graus14-Jun-09 18:22
protectorChristian Graus14-Jun-09 18:22 
GeneralRe: Take picture from Webcam (problem) Pin
S K Y14-Jun-09 19:14
S K Y14-Jun-09 19:14 
QuestionWebBrowser in VS2008 Pin
trinm198714-Jun-09 14:56
trinm198714-Jun-09 14:56 
AnswerRe: WebBrowser in VS2008 Pin
Christian Graus14-Jun-09 17:52
protectorChristian Graus14-Jun-09 17:52 
AnswerRe: WebBrowser in VS2008 Pin
trinm198714-Jun-09 20:29
trinm198714-Jun-09 20:29 
QuestionDisplay a grid of all character of a font Pin
baranils14-Jun-09 12:04
baranils14-Jun-09 12:04 
AnswerRe: Display a grid of all character of a font Pin
PIEBALDconsult14-Jun-09 15:12
mvePIEBALDconsult14-Jun-09 15:12 
AnswerRe: Display a grid of all character of a font Pin
_Maxxx_14-Jun-09 15:21
professional_Maxxx_14-Jun-09 15:21 
GeneralRe: Display a grid of all character of a font Pin
Luc Pattyn14-Jun-09 15:29
sitebuilderLuc Pattyn14-Jun-09 15:29 
GeneralRe: Display a grid of all character of a font Pin
_Maxxx_14-Jun-09 16:56
professional_Maxxx_14-Jun-09 16:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.