News:

Holy shit, it's 2018 2019 2020 2021 2022 2023 2024, and the US isn't a fascist country! What a time to be alive.

Main Menu

[C#] OnPaint (Other hwnd)

Started by abc, January 01, 2009, 01:39:45 PM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

abc

I was curious to know how/if it's possible to go about forcing the OnPaint() event or the Update() function to be called through another application; I have the hwnd, and hdc of my control.

MyndFyre

It's probably not possible to do this if the handle is in another application, but you could try Control.FromHandle(IntPtr).

You can also call into InvalidateRect, but once again, it may not work in another application.
Quote from: Joe on January 23, 2011, 11:47:54 PM
I have a programming folder, and I have nothing of value there

Running with Code has a new home!

Quote from: Rule on May 26, 2009, 02:02:12 PMOur species really annoys me.

iago

The normal way of getting those types of events from another application is by using system hooks (look up SetWindowsHookEx, iirc). Those functions implicitly use DLL injection to accomplish it.

At least, that's how it was done in C/C++. .NET may not be the same.

abc


MyndFyre

Quote from: Joe on January 23, 2011, 11:47:54 PM
I have a programming folder, and I have nothing of value there

Running with Code has a new home!

Quote from: Rule on May 26, 2009, 02:02:12 PMOur species really annoys me.

iago

Quote from: MyndFyre on January 06, 2009, 02:20:10 AM
Quote from: Dale on January 04, 2009, 11:19:07 PM
Thank you both.  :)
What are the results?
He gave up because it's too complicated.

(At least, that's what I would have done :D)

MyndFyre

Quote from: iago on January 04, 2009, 11:09:00 AM
The normal way of getting those types of events from another application is by using system hooks (look up SetWindowsHookEx, iirc). Those functions implicitly use DLL injection to accomplish it.

At least, that's how it was done in C/C++. .NET may not be the same.

I don't think he was trying to hook the events, merely that he was trying to get them to occur by sending the WM_PAINT message to the window.

Quote from: iago on January 06, 2009, 08:27:46 AM
Quote from: MyndFyre on January 06, 2009, 02:20:10 AM
Quote from: Dale on January 04, 2009, 11:19:07 PM
Thank you both.  :)
What are the results?
He gave up because it's too complicated.

(At least, that's what I would have done :D)
Yeah, ok.... :p
Quote from: Joe on January 23, 2011, 11:47:54 PM
I have a programming folder, and I have nothing of value there

Running with Code has a new home!

Quote from: Rule on May 26, 2009, 02:02:12 PMOur species really annoys me.

iago

Quote from: MyndFyre on January 06, 2009, 11:34:11 AM
I don't think he was trying to hook the events, merely that he was trying to get them to occur by sending the WM_PAINT message to the window.
Ah, good call, I misread the original post.

Quote from: iago on January 06, 2009, 08:27:46 AM
Yeah, ok.... :p
Note how I didn't finish it, I only went so far. ;)

abc

Well, I tried what you suggested earlier Mynd.. However no luck in it working. So I just left it the way it is now, pretty ugly but I'll get it working sometime.

Warrior

#9
Not sure, but maybe UpdateWindow will work.

Dunno, maybe you can try it in conjunction with InvalidateRect which adds the region to the update queue. I'm not certain if UpdateWindow will send a WM_PAINT regardless.

Edit: Now I'm not so sure, it seems that UpdateWindow immediately sends WM_PAINT to the message pump which redraws dirty regions, while InvalidateRect queues a WM_PAINT to the message queue..hmm

In theory UpdateWindow should immediately cause the rect you invalidate to draw, but InvalidateRect should work on it's own (albeit it does not do so immediately).

Post code?
One must ask oneself: "do I will trolling to become a universal law?" And then when one realizes "yes, I do will it to be such," one feels completely justified.
-- from Groundwork for the Metaphysics of Trolling