Reputation: 81
I am working on a c#Project.
I would like to know: Which Namespace include hWnd,tWindowPlacement,TAboutBox in C# .Net?
Upvotes: 4
Views: 2312
Reputation: 3833
In order to get a window handle, or hWnd, in C#, you simply need to return the MainWindowHandle
of a Process
, like so:
public static IntPtr FindWindowByProcessId(int dwProcessId)
{
Process proc = Process.GetProcessById(dwProcessId);
return proc.MainWindowHandle;
}
You can access GetWindowPlacement
using a platform invoke:
[DllImport("user32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
internal static extern bool GetWindowPlacement(IntPtr hWnd, out WINDOWPLACEMENT lpwndpl);
And I'd guess a TAboutBox is just what is a dialog, or MessageBox
in C#.
Upvotes: 1
Reputation: 4803
For hWnd you can use the System.IntPtr
structure - the others. TAboutBox sounds like a Delphi or C++Builder class...
Upvotes: 0
Reputation: 16111
I take it you are new to .NET, and perhaps the UI libraries too? Doing a UI in .NET is different from the old windows C 'Win32' API.
Like Jon mentioned, .NET and it's UI libraries doesn't use these items. Instead of handles to windows (i.e. HWND) there are classes responsible for the user interface that you can instantiate and use. For instance in classic .NET, windows are mostly replaced by UI elements in the System.Windows.Forms namespace. To show a dialog you would build up a Form, and ultimately call .Show() on the form to display it. Your code would ultimately hold a variable that points to an object oriented instance of the Form. There would be no code that gives you back an HWND for that form. It really is a better way to code for the UI, compared to Win32.
There are other libraries for showing UI that .NET can access, such as Windows Presentation Foundation (WPF), which is a favorite of mine. Silverlight too, though I don't know anything more about Silverlight.
If you are going to learn .NET in general, than I suggest you ask a lot of questions here, and get some books too. May I suggest the first book by Jeffrey Richter called 'CLR via C#'. Of course other's may make excellent suggestions too, but that book is what I read, oh so many years ago. And of course come back here often to ask questions and search for answers.
Good luck in your path to learning .NET!
Upvotes: 4