Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- List<IntPtr> result = new List<IntPtr>();
- GCHandle listHandle = GCHandle.Alloc(result);
- try
- {
- IntPtr Window_hWnd = CloseMessageBox.FindWindowByCaption("#32770", "LastQuestion"); //Could use null as the first argument too. "#32770" represents classname Dialog.
- CloseMessageBox.EnumChildWindows(Window_hWnd, (hWnd, lParam) =>
- {
- StringBuilder sb = new StringBuilder();
- foreach (var control in GCHandle.FromIntPtr(lParam).Target as List<IntPtr>)
- {
- CloseMessageBox.GetWindowText(control, sb, 250);
- if (sb.Equals("&No"))
- {
- CloseMessageBox.PostMessage(hWnd, CloseMessageBox.MouseDown, 0, 0);
- CloseMessageBox.PostMessage(hWnd, CloseMessageBox.MouseUp, 0, 0);
- }
- }
- return false;
- }, GCHandle.ToIntPtr(listHandle));
- //if (hWnd != IntPtr.Zero)
- //CloseMessageBox.PostMessage(Window_hWnd, CloseMessageBox.SysCommand , CloseMessageBox.Close, 0);
- }
- catch (Exception e)
- {
- MessageBox.Show(e.ToString());
- }
- finally
- {
- if (listHandle.IsAllocated)
- listHandle.Free();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement