2
Reply

AnimateWindow WinApi Not Working Why?

RIGHT THEN

RIGHT THEN

Jan 31 2008 1:38 AM
6.7k

GentleMen

I could not locate Win32api Related Forum So I am posting it in this holistic c#

Since i am using winapi in c# So here is the code

        public const uint   AW_HOR_POSITIVE    =  0x00000001 ;
        public const uint   AW_HOR_NEGATIVE  =  0x00000002 ;
        public const uint   AW_VER_POSITIVE     =  0x00000004 ;
        public const uint   AW_VER_NEGATIVE   =  0x00000008 ;
        public const uint   AW_CENTER                 =  0x00000010 ;
        public const uint   AW_HIDE                       =  0x00010000 ;
        public const uint   AW_ACTIVATE             =  0x00020000 ;
        public const uint   AW_SLIDE                     =  0x00040000 ;
        public const uint   AW_BLEND                   =  0x00080000 ;

 [DllImport("User32",CharSet = CharSet.Auto)]         
 unsafe public  static extern  System.IntPtr FindWindow (

      [ MarshalAs  ( UnmanagedType.LPTStr ) ] string lpClassName,

      [MarshalAs  ( UnmanagedType.LPTStr ) ]  string lpWindowName

   )  ;

[DllImport("User32", CharSet = CharSet.Auto)]
unsafe public static extern int AnimateWindow( System.IntPtr HwndWindow,

                                                                         uint dwDurationToAnimate,

                                                                         uint dwFlags

                                                                      )  ;
       
        unsafe public void FindWindowWithGivenTitle(

                                                                                 ref bool    Successful  ,

                                                                                 string  TitleTextOfWndToFind 

                                                                              )
        {
            try
            {
                System.IntPtr Inptr1 =  new IntPtr();
                int LastError ;
                Inptr1 = FindWindow( null,  TitleTextOfWndToFind ) ;  // this works fine
                if ( Inptr1 == IntPtr.Zero )
                {
                    MessageBox.Show("Not Found");
                    Successful = false;
                    return;
                }
                else
                {
                    int RetVal4 = AnimateWindow( Inptr1,  

                                                                     ( ( uint ) ( 1600 ) ) ,

                                                                     ( ( uint )  AW_HOR_NEGATIVE ) )  ;

  //  i have tired it woithout typecasting also but does not work
      Successful = true;
      return;
 }
            }
            catch (Exception e)
            {
                CentralCommand.InErrors.ThisFileRelatedErrors(ref e);   
            }
}

is there a List somewhere from where we could know what variable name

of win api is equivalent to c# name . because when i checked many of the posts on the internet i see that everbody is using diffrent types for the the variables no consistency

like somewhere HWND is a int and somewhere is it System.IntPtr

How to go about it

Thankyou

RIGHT_THEN

 


Answers (2)