[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

urgent form handle question

Posted on 2004-09-06
5
Medium Priority
?
253 Views
Last Modified: 2010-08-05
HI experts!

i have a window in an MDI with the handle XXXXX

I want to access this window programmatically and close it by referring to the windows handle

any way to do this??

Thanks!
0
Comment
Question by:OptionsMM
  • 3
  • 2
5 Comments
 
LVL 10

Expert Comment

by:eternal_21
ID: 11992636
Is the window in your application, or in another one (running in Windows somewhere)?
0
 
LVL 10

Accepted Solution

by:
eternal_21 earned 2000 total points
ID: 11992668
Use these declarations:

  [System.Runtime.InteropServices.DllImport("user32.dll")]
  static extern int SendMessage(IntPtr hWnd, int msg, IntPtr wparam, IntPtr lparam);
  const int WM_CLOSE = 0x10;
  const int WM_DESTROY = 0x2;

And then call this code, where handle is the handle to the window you want to close/destroy:

  // IntPtr handle = new IntPtr(XXXXX);

  SendMessage(handle, WM_CLOSE, IntPtr.Zero, IntPtr.Zero);
or
  SendMessage(handle, WM_DESTROY, IntPtr.Zero, IntPtr.Zero);
0
 

Author Comment

by:OptionsMM
ID: 11992868
Sorry I messed the question up.  

I want to be able to turn the windows visible and invisible.

how can I do that??

Thanks for the fast reply it is very appreciated!
0
 

Author Comment

by:OptionsMM
ID: 11993007
Also,

The "handle" is stored as a string, how can I convert this to the correct type?

Thanks!!
0
 

Author Comment

by:OptionsMM
ID: 11993088
Got it!

Thanks a million!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question