I'd like to close a dialog that pops up automatically, but I'm having some trouble getting it to work. My Win32 programming is a bit rusty after several years of limited usage.
I'm using FindWindowEx to get handles to the dialog and the button I want to click. I was under the impression that sending a WM_COMMAND to the dialog, with the button handle in the wParam parameter would do the trick.
Window window = Window.FindWindow("TSomeDialog", null);
Window cancelButton = Window.FindWindow("TButton", "Cancel", window);
Message message = Message.Create(window.HWnd, 0x0111, cancelButton.HWnd, IntPtr.Zero);
PostMessage(message);
public void PostMessage(Message message)
{
// Win32 API import
PostMessage(message.HWnd, message.Msg, message.WParam, message.LParam);
}
Window is a class that implements IWin32Window and wraps some Win32 API calls. I have inlined the constant for WM_COMMAND (0x111).
What am I doing wrong? :)