Button Array with faster painting

C

Carl Gilbert

Hi

I am developing a custom on screen keyboard. So far I have an array of
buttons and then using SendKeys to send the text of the button to the active
control to receive the text.

The only problem is that the application is rather slow at painting the
buttons. Ideally I wanted to allow the user to re-size the control and
change the text and style of the buttons without such rendering issues.
(I have a tool to re-size the buttons, its just the paint that is an issue
here)

Is there anyway to render a series of controls in a more efficient way than
going something like:

Friend WithEvents Button1 As Button
Me.Button1 = New Button
Me.Button1.Location = New System.Drawing.Point(32, 32)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(24, 24)
Me.Button1.TabIndex = 0
Me.Button1.Text = "Q"

and so on for all the other keys.

And then when the user clicks the CapsLock button I would then go through
all the buttons setting the text ToUpper ot ToLower.

Regards, Carl Gilbert
 
L

Larry Serflaten

Carl Gilbert said:
I am developing a custom on screen keyboard. So far I have an array of
buttons and then using SendKeys to send the text of the button to the active
control to receive the text.

The only problem is that the application is rather slow at painting the
buttons. Ideally I wanted to allow the user to re-size the control and
change the text and style of the buttons without such rendering issues.
(I have a tool to re-size the buttons, its just the paint that is an issue
here)

Is there anyway to render a series of controls in a more efficient way than
going something like:

Friend WithEvents Button1 As Button
Me.Button1 = New Button
Me.Button1.Location = New System.Drawing.Point(32, 32)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(24, 24)
Me.Button1.TabIndex = 0
Me.Button1.Text = "Q"

and so on for all the other keys.

That creates a new control, (IMHO) it does nothing about rendering.
Rendering is the action needed to make the control visible on the screen,
just the painting part, not the creation of a new control.

In any case, you could loose all your button controls, and manage the
keys yourself using regions, or simple X and Y calculations. You'd keep
a backbuffer of the keyboard image for use in the paint event, and draw
directly to the screen for user interaction. You can use the ControlPaint
class to help with drawing the 3D buttons.

A while ago someone else wanted Toolbar type buttons, where drawing
them in code was the only way to get them. Here is that example:

http://groups.google.com/[email protected]

HTH
LFS
 
C

Cor Ligthert

Carl,

As long as you are not using system.drawing for the painting of a button,
that should go fast.

In my opinion is there probably something else what stops your program
showing those buttons than the code you showed us.

Just my thought,

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top