Code Adding

Nov 22, 2010 at 3:11 PM

public class CBPopupHelpForm

#region Popup Location
            Point screenPosition = ctrl.PointToScreen(new Point(ctrl.RightPopupMargin + ctrl.Width + ctrl.RightPopupMargin, -ctrl.TitlePadding.Top));
            if (screenPosition.X + Width > Screen.PrimaryScreen.WorkingArea.Width)
            {
                //if the popup will not display entirely on the screen move it to the left of the control
                int x = ctrl.PointToScreen(new Point(0, 0)).X - ctrl.LeftPopupMargin - Size.Width;
                if (x >= 0)//if the left coordinate is left of the screen (negative) display what you can on the right
                    screenPosition.X = x;
            }

            if (screenPosition.Y + Height > Screen.PrimaryScreen.WorkingArea.Height) {
                //if the popup will not display entirely on the screen move it to the top of the control
                int y = ctrl.PointToScreen(new Point(0, 0)).Y - Size.Height + ctrl.Top;
                if (y >= 0)
                    screenPosition.Y = y;
            }

            Location = screenPosition;
            #endregion