I have an windows app on .net 2.0. On Form1, I open a PrintDialog. How can I get that dialog's handle from my code?
I have tried a lot of win32 functions: EnumWindows, EnumChildWindows, FindWindow, FindWindowEx but it cannot find my PrintDialog. All I can find is just Form1 and its children are controls on it. There's no way I can get PrintDialog's handle.
Some code that i have tried:
Import win32:
[DllImport("user32.dll", SetLastError = true)]
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
calling win32 functions:
using (PrintDialog dlg = new PrintDialog
{
AllowCurrentPage = false,
AllowSomePages = true,
AllowSelection = false
})
{
IntPtr printHandle = CustomPrintDialog.FindWindow("#32770", "Print");
// some logic with printHandle go here
if (dlg.ShowDialog(this)==DialogResult.OK){
// some logic go here
}
}
I have checked with Spy++, there is still a PrintDialog window. That PrintDialog window has Parent Window's handle exactly same as Form1's handle.
Does anyone can help me to get a PrintDialog's handle from its parent window?