Setting flags.

  • Thread starter Thread starter Nick
  • Start date Start date
N

Nick

I want to call and API function. And this is just an example, there are
a lot of them that require flags.

This one is from user32.dll

BOOL AnimateWindow(
HWND hwnd,
DWORD dwTime,
DWORD dwFlags
);

I import it like this:

[DllImport("user32.dll",EntryPoint="AnimateWindow")]
public static extern bool AnimateWindow(IntPtr h_Window,int time,int flags);

and then call it:
AnimateWindow(this.Handle,300,1|8);

Now that last argument im basically guessing and checking the result. If
I put 1 it slides, if I put 1|8 it also slides but differently.

Im sure there is a better way to translate "AW_SLIDE|AW_VER_NEGATIVE"
for use in C#.

Someone please enlighten me...

Thanks.
Nick Z.
 
Look in the winuser.h file that comes with the Platform SDK and you'll find
the definitions for the flags there. Then just declare them as constants in
a class and use the constants instead of the numbers.

Arild
 
Nick.

Use these constants in ur class


private const long AW_HOR_POSITIVE = 1
private const long AW_HOR_NEGATIVE = 2
private const long AW_VER_POSITIVE = 4
private const long AW_VER_NEGATIVE = 8
private const long AW_CENTER = 16
private const long AW_HIDE = 65536
private const long AW_ACTIVATE = 131072
private const long AW_SLIDE = 262144
private const long AW_BLEND = 524288
 
Nick said:
I want to call and API function. And this is just an example, there are
a lot of them that require flags.

This one is from user32.dll

BOOL AnimateWindow(
HWND hwnd,
DWORD dwTime,
DWORD dwFlags
);

I import it like this:

[DllImport("user32.dll",EntryPoint="AnimateWindow")]
public static extern bool AnimateWindow(IntPtr h_Window,int time,int
flags);

and then call it:
AnimateWindow(this.Handle,300,1|8);

Now that last argument im basically guessing and checking the result. If
I put 1 it slides, if I put 1|8 it also slides but differently.

Im sure there is a better way to translate "AW_SLIDE|AW_VER_NEGATIVE"
for use in C#.

www.pinvoke.net is a great place to find information on P/Invoke issues:

http://www.pinvoke.net/print.aspx/Enums.AnimateWindowFlags
 
Nick said:
I want to call and API function. And this is just an example, there are
a lot of them that require flags.

This one is from user32.dll

BOOL AnimateWindow(
HWND hwnd,
DWORD dwTime,
DWORD dwFlags
);

I import it like this:

[DllImport("user32.dll",EntryPoint="AnimateWindow")]
public static extern bool AnimateWindow(IntPtr h_Window,int time,int
flags);

and then call it:
AnimateWindow(this.Handle,300,1|8);

Now that last argument im basically guessing and checking the result. If
I put 1 it slides, if I put 1|8 it also slides but differently.

Im sure there is a better way to translate "AW_SLIDE|AW_VER_NEGATIVE"
for use in C#.

Someone please enlighten me...

Thanks.
Nick Z.

Thank you for the informative replies. Just grabbed myself the Platform SDK and pinvoke.net made my favorites.

Nick Z.
 
Back
Top