Quantcast
Channel: Windows Desktop Development for Accessibility and Automation forum
Viewing all articles
Browse latest Browse all 585

UI Automation Client-Side Provider for Windows Forms Custom Control using C#

$
0
0

Hi Folks - I been looking for information on client-side providers using C# for Window Forms Custom Controls so i can get information of inner elements at this control. I have been able to make to work some simple samples but not sure how i can get inner information from that custom control. The control does its rendering by customized draws of text and rectangles and other kinds of elements by using the overrided OnPaint method and here is where im not sure how to proceed. Unfortunatelly i do not have code of that custom control so the only way to approach this as I understand is by using Client-Side Providers where there Server-Side Providers is for controls were code is available which is not my case.

Wonder if some one can light me how to do this using C# language.

Here is a simple custom control wich draws a simple text, the objective is to get the value of that text element.

public partial class CompositeCustomControl : Control
    {
        public CompositeCustomControl()
        {
            InitializeComponent();
        }

        protected override void OnPaint(PaintEventArgs pe)
        {
            Font drawFont = new Font("Arial", 20);

            SolidBrush drawBrush = new SolidBrush(Color.Black);
            Pen blackPen = new Pen(Color.Black);

            float x = 5.0F;
            float y = 5.0F;
            float width = 200.0F;
            float height = 50.0F;
            RectangleF drawRect = new RectangleF(x, y, width, height);

            pe.Graphics.DrawRectangle(blackPen, x, y, width, height);

            StringFormat drawStringFormat = new StringFormat();
            drawStringFormat.Alignment = StringAlignment.Center;

            pe.Graphics.DrawString("Sample string", drawFont, drawBrush, drawRect, drawStringFormat);
        }
    }
Thanks in advance for any help.



Viewing all articles
Browse latest Browse all 585

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>