Example #1
0
        public bool SetBorderStyle(IntPtr mNewStyle)
        {
            if (mNewStyle != IntPtr.Zero && myHandle != IntPtr.Zero)
            {
                //Set_GWLStyle
                //cPInvoke.SetWindowLongPtr(appIntPtr, cWindowHandleFlags.WindowLongFlags.GWL_STYLE, StyleIntPTR)
                Nativ.SetWindowLongPtr(myHandle, Enums.WindowLongFlags.GWL_STYLE, mNewStyle);

                //LoadClickable
                //Return cPInvoke.ShowWindow(appIntPtr, cWindowHandleFlags.ShowWindowCommands.Show)
                Nativ.ShowWindow(myHandle, Enums.ShowWindowCommands.Show);

                //if there is a problem with the border this could possible solve it
                //TA_Window_API.cHandleWindow.Set_WindowPosition(myHandleTasks.Handle, TA_Window_API.cWindowHandleFlags.HWND_NOTOPMOST, CInt(Me.txtXCor.Text), CInt(Me.txtYCor.Text), CInt(Me.txtWidth.Text), CInt(Me.txtHeigh.Text), inrWinPos)

                return(true);
            }
            else
            {
                if (mNewStyle == IntPtr.Zero)
                {
                    Log.cLogger.Log("Can't set Border Style because no intptr for Border Style is set");
                }
                else
                {
                    Log.cLogger.Log("Can't set Border Style because no intptr Handle is set");
                }
                return(false);
            }
        }
Example #2
0
        public static void Update(IntPtr iptrThumb, AWC.WindowHandle.NativStructs.RECT _rec)
        {
            if (iptrThumb != IntPtr.Zero)
            {
                System.Drawing.Size size = new System.Drawing.Size();
                Nativ.DwmQueryThumbnailSourceSize(iptrThumb, ref size);

                NativStructs.ThumbnailProperties props = new NativStructs.ThumbnailProperties();
                props.Visible       = true;
                props.TNP           = NativStructs.Dwm_TNP.Visible | NativStructs.Dwm_TNP.Recdestination | NativStructs.Dwm_TNP.Opacity;
                props.opacity       = 255;
                props.rcDestination = _rec;

                if (size.Height < _rec.Height)
                {
                    props.rcDestination.Bottom = props.rcDestination.Top + size.Height;
                }

                if (size.Width < _rec.Width)
                {
                    props.rcDestination.Right = props.rcDestination.Left + size.Width;
                }

                //calculate scalingfor the Thumb to center it
                double radio   = (size.Height / _rec.Height);
                int    nWidth  = (int)(size.Width / radio);
                int    nHeight = (int)(size.Height / radio);

                if (nHeight > _rec.Height || nWidth < 0 || nHeight < 0)
                {
                    radio   = (size.Width / _rec.Width);
                    nWidth  = (int)(size.Width / radio);
                    nHeight = (int)(size.Height / radio);
                }

                if (_rec.Width > nWidth)
                {
                    props.rcDestination.Left += (_rec.Width - nWidth) / 2;
                }

                if (_rec.Height > nHeight)
                {
                    props.rcDestination.Top += (_rec.Height - nHeight) / 2;
                }

                props.rcDestination.Width  = _rec.Width;
                props.rcDestination.Height = _rec.Height;

                AWC.WindowHandle.Nativ.DwmUpdateThumbnailProperties(iptrThumb, ref props);
            }
            else
            {
                throw new ArgumentNullException("iptrThumb, ctrl", "Can't Update Thumbnail");
            }
        }
Example #3
0
 public bool SetSizeLocation(IntPtr iprInsertAfter, int iNewPosX, int iNewPosY, int iNewSizeX, int iNewSizeY, int iNewFlags)
 {
     if (myHandle != IntPtr.Zero)
     {
         return(Nativ.SetWindowPos(myHandle, iprInsertAfter, iNewPosX, iNewPosY, iNewSizeX, iNewSizeY, iNewFlags));
     }
     else
     {
         Log.cLogger.Log("Can't set Size Location because no intptr Handle is set");
         return(false);
     }
 }
Example #4
0
        private void GetPositionSize()
        {
            if (myHandle != IntPtr.Zero)
            {
                System.Runtime.InteropServices.HandleRef handleRef = new System.Runtime.InteropServices.HandleRef(System.Runtime.CompilerServices.RuntimeHelpers.GetObjectValue(new object()), myHandle);
                NativStructs.RECT mWindRECT;
                Nativ.GetWindowRect(handleRef, out mWindRECT);
                if (mWindRECT != null)
                {
                    mWindRECT.X      = mWindRECT.X + 8;
                    mWindRECT.Y      = mWindRECT.Y + 8;
                    mWindRECT.Height = mWindRECT.Height;
                    mWindRECT.Width  = mWindRECT.Width;

                    if (myWindowRectangle == null)
                    {
                        myWindowRectangle = new System.Drawing.Rectangle();
                    }
                    if (mWindRECT.X != myWindowRectangle.X || mWindRECT.Y != myWindowRectangle.Y || mWindRECT.Size != myWindowRectangle.Size || mWindRECT.Location != myWindowRectangle.Location)
                    {
                        WriteOutput(string.Format("Set new Position or Size for Window (new X:'{0}' Y:'{1}' Height:'{2}' Width:'{3}');", mWindRECT.X, mWindRECT.Y, mWindRECT.Height, mWindRECT.Width), Enums.WindowLogFlags.INFOLOG);
                        myWindowRectangle.Height   = mWindRECT.Height;
                        myWindowRectangle.Location = mWindRECT.Location;
                        myWindowRectangle.Size     = mWindRECT.Size;
                        myWindowRectangle.Width    = mWindRECT.Width;
                        myWindowRectangle.X        = mWindRECT.X;
                        myWindowRectangle.Y        = mWindRECT.Y;

                        OnWindowPositionSizeChanged(new Public.ProcessEventArgs(this));
                    }
                }
            }
            else
            {
                WriteOutput("GetPositionSize can´t execute, Window Handle is zero;", Enums.WindowLogFlags.ERRORLOG);
            }
        }
Example #5
0
        private void GetExStyle()
        {
            try
            {
                if (myHandle != IntPtr.Zero)
                {
                    List <Enums.WindowExStyle> myTempList = new List <Enums.WindowExStyle>();

                    System.Runtime.InteropServices.HandleRef handleRef = new System.Runtime.InteropServices.HandleRef(System.Runtime.CompilerServices.RuntimeHelpers.GetObjectValue(new object()), myHandle);
                    double windowLongPtr = (double)(Nativ.GetWindowLongPtr(handleRef, Enums.WindowLongFlags.GWL_EXSTYLE));
                    if (windowLongPtr < 0)
                    {
                        windowLongPtr = -(windowLongPtr * 2);
                    }

                    for (int i = Enum.GetValues(typeof(Enums.WindowExStyle)).Length - 1; i > 0; i--)
                    {
                        double EnumValue = (double)(Enum.GetValues(typeof(Enums.WindowExStyle)) as Enums.WindowExStyle[])[i];

                        if ((windowLongPtr - EnumValue) >= 0)
                        {
                            Enums.WindowExStyle val = (Enum.GetValues(typeof(Enums.WindowExStyle)) as Enums.WindowExStyle[])[i];
                            myTempList.Add(val);
                            windowLongPtr = windowLongPtr - EnumValue;
                        }
                    }

                    if (myWindowExStyleList == null)
                    {
                        WriteOutput("Window ExStyle create new List;", Enums.WindowLogFlags.INFOLOG);

                        myWindowExStyleList = new List <Enums.WindowExStyle>();

                        if (myTempList != null && myTempList.Count > 0)
                        {
                            string strtmp = "( ";
                            foreach (Enums.WindowExStyle data in myTempList)
                            {
                                strtmp += data + "  ";
                            }
                            strtmp += ");";
                            WriteOutput("Window ExStyles in List = " + strtmp, Enums.WindowLogFlags.INFOLOG);
                        }
                    }
                    else
                    {
                        if (myWindowExStyleList.Count != myTempList.Count)
                        {
                            WriteOutput("Window ExStyle changed;", Enums.WindowLogFlags.INFOLOG);

                            if (myTempList != null && myTempList.Count > 0)
                            {
                                string strtmp = "( ";
                                foreach (Enums.WindowExStyle data in myTempList)
                                {
                                    strtmp += data + "  ";
                                }
                                strtmp += ");";
                                WriteOutput("Window ExStyles in List = " + strtmp, Enums.WindowLogFlags.INFOLOG);
                            }
                        }
                        myWindowExStyleList.Clear();
                    }
                    myWindowExStyleList.AddRange(myTempList.ToArray());

                    myTempList.Clear();

                    OnWindowExStyleChanged(new Public.ProcessEventArgs(this));
                }
                else
                {
                    WriteOutput("GetExStyle can´t execute, Window Handle is zero;", Enums.WindowLogFlags.ERRORLOG);
                }
            } catch (Exception)
            { }
        }