Reputation: 38
How can I draw a .png file to a certain window like for an example notepad?
HWND hWnd = FindWindow(0, "Untitled - Notepad");
void DrawTohWnd()
{
Image^ newImage = Image::FromFile("smile.png");
//Draw newImage to Window (Notepad)...
//...
}
Upvotes: 0
Views: 348
Reputation: 244971
The easiest way is to use the Graphics::DrawImage
method and pass in your Image
object (along with any other desired parameters specifying drawing options).
But that requires you to have an instance of the Graphics
class corresponding to your window (HWND
). You can get one by calling the Graphics::FromHwnd
method.
Do be careful with the code you have written, though. Searching for windows by their caption is an inherently fragile method—windows change titles often.
Upvotes: 2