Click here to Skip to main content
15,921,990 members
Home / Discussions / C#
   

C#

 
GeneralRe: Transparent Image Pin
Matthew Hazlett25-Feb-04 14:01
Matthew Hazlett25-Feb-04 14:01 
GeneralRe: Transparent Image Pin
Verdant12325-Feb-04 16:18
Verdant12325-Feb-04 16:18 
GeneralRe: Transparent Image Pin
Kentamanos26-Feb-04 9:00
Kentamanos26-Feb-04 9:00 
GeneralRe: Transparent Image Pin
Verdant12326-Feb-04 12:22
Verdant12326-Feb-04 12:22 
GeneralGetWindow Pin
yyf25-Feb-04 10:21
yyf25-Feb-04 10:21 
GeneralRe: GetWindow Pin
Judah Gabriel Himango25-Feb-04 10:40
sponsorJudah Gabriel Himango25-Feb-04 10:40 
GeneralRe: GetWindow Pin
Heath Stewart25-Feb-04 11:52
protectorHeath Stewart25-Feb-04 11:52 
GeneralRe: GetWindow Pin
Heath Stewart25-Feb-04 11:58
protectorHeath Stewart25-Feb-04 11:58 
You'll have to P/Invoke it like so:
[DllImport("user32.dll")]
private static extern IntPtr GetWindow(
  IntPtr hWnd,
  [MarshalAs(UnmanagedType.U4)] int nCmd);
private const int GW_HWNDFIRST = 0;
private const int GW_HWNDLAST = 1;
private const int GW_HWNDNEXT = 2;
private const int GW_HWNDPREV = 3;
private const int GW_OWNER = 4;
private const int GW_CHILD = 5;
You could define those constants as a enum, then change the declaration from int to your enum in GetWindow (leave the MarshalAsAttribute as is) if you want, but it really makes no difference if these are private and you'll be the only one calling these.

You can get the window handle from Control.Handle, from which all controls (including Form) derive. You can use Control.FromHandle with the return IntPtr to get the control, which you can cast to whatever you like (like a Form).

 

Microsoft MVP, Visual C#
My Articles
GeneralRe: GetWindow Pin
yyf26-Feb-04 3:21
yyf26-Feb-04 3:21 
QuestionGet the width of a (formatted) string? Pin
Verdant12325-Feb-04 9:56
Verdant12325-Feb-04 9:56 
AnswerRe: Get the width of a (formatted) string? Pin
Judah Gabriel Himango25-Feb-04 10:42
sponsorJudah Gabriel Himango25-Feb-04 10:42 
GeneralRe: Get the width of a (formatted) string? Pin
Verdant12325-Feb-04 12:26
Verdant12325-Feb-04 12:26 
GeneralException thrown from within Application.Run(Form); Pin
jerrycainjr25-Feb-04 9:25
jerrycainjr25-Feb-04 9:25 
GeneralRe: Exception thrown from within Application.Run(Form); Pin
scadaguy25-Feb-04 10:33
scadaguy25-Feb-04 10:33 
QuestionHow to get the number of visible forms on screen ? Pin
Andres Coder25-Feb-04 9:04
Andres Coder25-Feb-04 9:04 
AnswerRe: How to get the number of visible forms on screen ? Pin
Verdant12325-Feb-04 12:38
Verdant12325-Feb-04 12:38 
GeneralRe: How to get the number of visible forms on screen ? Pin
Andres Coder25-Feb-04 21:51
Andres Coder25-Feb-04 21:51 
GeneralRe: How to get the number of visible forms on screen ? Pin
Verdant12326-Feb-04 2:25
Verdant12326-Feb-04 2:25 
Generalcool icons Pin
OmegaSupreme25-Feb-04 8:21
OmegaSupreme25-Feb-04 8:21 
GeneralRe: cool icons Pin
RNEELY25-Feb-04 8:29
RNEELY25-Feb-04 8:29 
GeneralRe: cool icons Pin
OmegaSupreme25-Feb-04 9:24
OmegaSupreme25-Feb-04 9:24 
GeneralRe: cool icons Pin
Werdna25-Feb-04 8:40
Werdna25-Feb-04 8:40 
GeneralRe: cool icons Pin
RNEELY25-Feb-04 9:16
RNEELY25-Feb-04 9:16 
GeneralRe: cool icons Pin
OmegaSupreme25-Feb-04 9:27
OmegaSupreme25-Feb-04 9:27 
GeneralDynamic display of datagrids with Checkboxes Integrated Pin
Ananthanatarajan25-Feb-04 6:36
Ananthanatarajan25-Feb-04 6:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.