Delegates

  • 18 years ago

    I'm having some trouble with a delegate in my program.


    it's defined as :


    delegate void MeProc(int HWND, uint MSG, uint WParam, int LParam);


    I've also tried:


    delegate void MeProc(ref Message m);


    I think the problem is either that or in the following code:

    Code:

    int h = FindWindow(null,textbox.Text);
    int Menu1 = GetSystemMenu(h, 0);
    AppendMenu(Menu1, 0, 666, "Hello from Michael");
    oldProc = GetWindowLong(h, -4);
    if(SetWindowLong(h, -4,new MeProc(proc1))==0) MessageBox.Show("Nope");

    something interesting though, if h is the HWND of the my program's
    window, I get a "Fatal execution engine error".  But if h is the HWND of a Internet Explorer window,
    the call fails and I see that MessageBox. This is supposed to insert a new window procedure for the window.


    I (strongly) think that I've done something wrong with the delegate.


    Does anyone have any ideas?


    thanks,
    - Mike

Post a reply

No one has replied yet! Why not be the first?

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Any fool can write code that a computer can understand. Good programmers write code that humans can understand.” - Martin Fowler