devxlogo

Implementing a Toolbar

Implementing a Toolbar

Question:
I am using VB 3.0 professional edition. I would like toimplement cut/copy/paste on a toolbar. My form has multipletext boxes. If the user wants to paste to a field, theyclick on the insertion point, then click on the paste button.How can I tell which field they were on? ActiveControl gets set to -1.

Answer:
Do you actually have buttons in the toolbar, or are you using pictures? If you use buttons, the activecontrol will actually change. Pictures can’t be set to the activecontrol, so the problem goes away. I think most of the 3rd party toolbars (I use Sheridan’s) use pictures instead of buttons.

However, if you do want to implement a toolbar without a specialized control, you’ll need to keep track of which control last had the focus. Once the user presses a button, use the last control that was used for cut/copy/paste.

See also  Comparing different methods of testing your Infrastructure-as-Code
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist