Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  HOME    TRACKER    Visual Basic

Command Button Focus

When a command button has focus it has that dotted line around the text.
Is there a way to get rid of that (fairly easy) so it doesn't ever show that dotted line.

Just curious


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Command Button Focus
This may sound like a dumb question - but how do you remove the checked box around a command button which denotes it has focus ?

How Can I Set Command Button Focus To None?
I know some like third command button ocx control have this feature, but what a pity in vb standard can't settable, does anybody who know how can I do it?

To Get Focus To A Command Button
Hi everybody,

I am working on a vb project to upload data. While uploading data, a progressbar shows the progress. I have placed a command button which will be made visible when the uploading begins. Command button is placed to stop the uploading if the user desires. My problem is, i am not able to get the focus to this button when the uploading begins. When progress bar is running, how to shift the focus to command button. Please help.

thanks in advance

Move Focus From Command Button ???
How would I move the focus from a command button, so that the button becomes a momentary click command and does not retain the tab focus ?

I want the button to trigger an event, however I do not want the focus to remain on the button after it has been clicked ?

How would I code this, so that I can specify which control to move to ?

Focus Rectangles On A Command Button...
Just a small thing:

How can i get rid of the focus rectangles on a command button?

When the buttons are too small, they are kinda annoying!

Thanks in advance.


Command Button Focus Indication
You know how a command button gets that "rectangle" of hash-lines when it gets focus...

Is there a way to easily stop that?

I am going to change the color to indicate what command button is clicked - I don't want that rectangle focus indicator to be on the buttom.

Get Rid Of Focus Rectangle On Command Button
I'm making my own UpDown control. It consists of a label and two command buttons (up & down). Couple questions:

1. Everytime I press one of the command buttons - the button gets the focus and shows that ugly rectangle around it. How can I prevent that (like in MS version of the UpDown control)

2. Also, when I hold my mouse down on one of the buttons, I'd like my control to count continuosly (much like the MS version of UpDown control).

What Is The Command To Set The Focus Of This VBScript Msgbox To The NO Button Instead
What is the command to set the focus of this VBScript msgbox to the NO button instead of the YES?


<SCRIPT ID=clientEventHandlersVBS LANGUAGE=vbscript>
dim blnTest
blnTest = false

function form1_onsubmit()
if blnTest = true then
if msgbox("Are you sure you want to delete?" & vbcrlf & vbcrlf & _
"This action can NOT be undone!", vbyesno, "Confirm Delete") = vbyes then
Form1_OnSubmit = true
Form1_OnSubmit = false
end if
Form1_OnSubmit = false
end if

End function

Sub lstJob_onclick
blnTest = true
End Sub

Calendar/Command Button Focus Problem
I have a calendar on a form and two buttons (say). After clicking on a calendar date I click on either button, which causes the calendar to lose focus - but I have to click again to actually activate the button.
Is there any way round this?


Funny Tab & Focus Nature Of MSForms Command Button!!

I am using MSForms command Button only because i want ForeColor for the btn and the VB btn doesn't let me set. (and going the subclassing way is too much trouble for too small a gain!)

The problem:
It looks like MSForms's btn always sets the Focus to the next control in the tab order, irrespective of i use tab or shift-tab. For shift-tab it should actually go back in tab order, right?

So what happens is if i have say a text box as the next tab element, and i keep presseing shift-tab the focus gets locked between these two controls. It keeps shifting back and forth only!! ( and not thru all the controls).

Has anybody else experienced this? Is there a work around? or am i seeing things:-)

It has another funny property of appearing depressed when double clicked!. To avoid this you have to set Cancel to true in the dbl click event handler. Funny you can't do this from Properties!

Removing "focus Rectangle" From VB Command Button
When the focus is on a push button, a thin dotted rectangle appears on the button. Is there a way to not have that rectangle appear?

How To Create Own Style Command Button The Command Button Properties Can Set By User?
how to create style command button the command button properties can set by user?

is it something related to .ocx file extension?

like caption can set by user
height,width can set by user
command button button can set by user...

Converting A Custom Command Button To A Standard VB Command Button
Hey there,
The task at hand is as follows: I have a large VB project with many forms that use a custom command button (it is the Gurhan Button, a freeware control available from PSC and other places). What I want to do is replace the Gurhan button en masse to the standard VB button.

What I have done is written a simple VB program that reads in the .frm files of the project as text, and made the appropriate replacements. This works fine except for the Picture property. In other words, a line like this:

Picture = "Form1.frx":11B4

causes problems in the converted project.
When I open the new form, I get the "There were errors, check log file for details" message. The log file message, not very useful, contains lines like this:
Line 12: Property Picture in GurhanButton1 could not be set.

Now, I am not an expert on frx files, but I would think that the reference to "Form1.frx":11B4 in the Picture property refers to its location in the file? And if so, the frx file is not being changed, so I am at a loss as to why VB cannot set the property. Any ideas?

Enabling Command Button By Clicking Another Command Button.
Hi again, i was just helped on this site majorly thankyou ! I have one more question:

See the image below. I want to make for example; when you click "dan" and "kwan" it enables you to click the things valued at "dan" and "kwan" i.e. "dario hat" for example. Also, how to make it so "dario hat" is valued at "dankwan". If your curious, we had to make our own currency lol.

Command Button Event Occurs Only When The Button Is Double Clicked !

I am using a MonthView Control and Two Command Buttons (Ok & Cancel) inside a Frame, Its designed as the MonthView Control will display 2 Columns and 1 Row. Now what happens is when i change a date in the MonthView Control, then i need to double click the Command Button, then only the Command Event occurs (Either its Ok or Cancel Button). If i didn't change the Date in the Monthview Control, then i am able to do the CommandButton Event work with the single MouseClick. I think if i change Date in the Calendar (i.e MonthView Control), then there is some thing affected in the Focus of the Command Button, after I change the date and press the command button, the button seems to be selected (marked) but the event didn't occured. I tried with the BreakPoint also. Can any one help me regarding this.


Using Return/Enter Keyboard Button Instead Of Command Button (RESOLVED)
I am entering data into 4 textboxes and then performing calcs on that data using a commandbutton.
Is there a way to use the keyboard's Enter button as a proxy for the commandbutton, if and only if the focus is on one of these 4 textboxes?

I hope that's clear.


Edited by - jimvt on 6/16/2004 4:12:28 AM

Command Button Event Occurs Only When The Button Is Double Clicked !

      I am using a MonthView Control and Two Command Buttons (Ok & Cancel) inside a Frame, Its designed as the MonthView Control will display 2 Columns and 1 Row. Now what happens is when i change a date in the MonthView Control, then i need to double click the Command Button, then only the Command Event occurs (Either its Ok or Cancel Button). If i didn't change the Date in the Monthview Control, then i am able to do the CommandButton Event work with the single MouseClick. I think if i change Date in the Calendar (i.e MonthView Control), then there is some thing affected in the Focus of the Command Button, after I change the date and press the command button, the button seems to be selected (marked) but the event didn't occured. I tried with the BreakPoint also. Can any one help me regarding this.


Command Button 1 Depends On Command Button 2
hi there! hope someone can give some time w/ my prob.! Actually, I have 2 command buttons: button 1 for extracting and button 2 for printing. By the way, i just used a macro for the print button. The situation is this, before the user can extract the file, he should print it first. So I included a msgbox for that.

My question is what can i possibly add to the codes below in order to cancel the msgbox and continue w/ the extraction if the user already printed the report???

Private Sub cmdOutExcel_Click()

If MsgBox("You have to print the report before proceeding", vbOKOnly + vbInformation + vbSystemModal, "Stop") = vbOK Then
Exit Sub
End If

If MsgBox("Extract this form? If no, this will extract the source AEW table.", vbYesNo + vbQuestion + vbSystemModal, "Choose") = vbYes Then
DoCmd.OutputTo acOutputForm, "Activity Effort Worksheet", acFormatXLS
DoCmd.ApplyFilter "AEW", "BRUCode='" + CStr(bruc) + "'"
DoCmd.OutputTo acOutputTable, "AEW", acFormatXLS
End If

End Sub

How Do I Add A Wav File To A Command Button, Also Change The Color Of The Button When
I am having trouble with this. I am able to make a windows default soung by inserting the word beep, however if i want a different sound how to i define it. also i have forgotten exactly how to write the coding for changing the button color when it is selected. Any help would be greatly appreciated.

? Change The Font &amp; Button Color Of A Command Button

I would like to change the font & button color of my command buttons, Does anyone know how I can do this?

Also I am curious as how to change the color of input boxes & menu bars?

Any help is greatly appreciated! Thanks in advance!


Command Focus
I have a form with a few textboxes and combos I want to use the tab button to go to
1) Text1 then
2) Combo1 then
3) Combo2 then
4) Text2 then
5) Text3 then
6) Text4
And then the Command button to add it to the DB
Any Help would be great

Using A Command Button To Click Other Command Buttons? Please Help
I am creating a program and I want to make it so if I click one command button VB automatically click other command buttons

Clicking command 4 runs
command 1
command 2
command 3
in that order

Please help


A Menu Button Linked To A Command Button?
i have a command button which contains a heap of code. I also have a menu button that does the same thing as the command button. At the moment, when i edit the command button code, i just copy and paste that code to the menu item.

How would i go about linking the menu button to the command button?

Command Button And Option Button Question
Player X clicks the X option button when it is his/her turn. Then player X clicks the command button of choice which will display an X. How do I write the code when a command button has been clicked? It is a noughts and crosses game.

Simulating A Button Press On A Command Button
OK, here we go...

I have a command button that starts a database search. I have set an animation control to show a searchlight while the search is being performed, but want this to appear on the button.

The animation control has been placed over the button, but of course this stops the button being pressed. I have added in the 'click' procedure for the animation, a call to the 'click' procedure for the button, so it functions, but I want the button to look pressed for the duration of the mouse button press on the animation control.

Is there anybody who knows how?

Thanks in advance...

Button Has Focus???
Is there a way to determine if a button has the focus on a form? I know there is the button_gotfocus() function, but I need something like "button.gotfocus". Is there a way to do this? Thanks in advance!!

No Focus To Command Buttons!!!
Hi, does any one know how to create a form where the command buttons are not given focus. I am trying to create a calculator that accepts keyboard accelerators.

I have changed the forms KeyPreview setting to True and all of the other keyboard shortcuts work except the Return/Enter key. Every time I press these keys, instead of the configured event from running, it just presses the selected command button. This does not happen on Windows Calculator so it must be possible to change. I have already changed the buttons' TabStop property to False but this has no effect.

Please help! Thanx in advance!

Focus Of Command Buttons
What I am looking for is to never have focus on a command button. So if you click on 1 it wont stay set on it at all it just clicks then loses the focus. Is there a way so that a command button can never recieve the focus? Well thanks guys I appreciate it!

Set The Focus Of A Radio Button
hi all
How do you set the focus of a radio button? And how do you print the content of a list box?

Focus On Toolbar Button ?
Hi all,

How to setFocus on Button in Toolbar standard component.
like focus on button visual basic button standard ?


Map The Focus Event Of The Button
hi all,

i have one application in which i have two text box i am checking the validation on lost focus of each text box and if there is any error i set errorflag is 1 and on textchange of bothtext box i chage flag to 0 and check the validation, purpose of this flag is that untill user enter valid data we are not allow him to leave the filed
so i check her that is the flag is set to 1 then setfocus back to the control which occure the error.. it's work fine now i have clear button and exit button on my form. if there is error and i cleck clear button or exit button the focus will set back to the control which cause the error and not allow to exit or clear fileds is there any why that i find out the cleck event of clear and exit button like if btnclear.cleck then do this operation ...??

how can i identfy that clear button is cleck in the lostfocus of the textbox event is there any why pls help me regarding this thanx in advance...

Prevent Button Focus?

I was wondering how I could prevent the focus rectangle from appear on a command button. I realize I will probably have to subclass it and use some API.

Basically, what I'm trying to mimic is the behavior of the button that you see in the ComboBox control. When you click on it, no focus rectangle appears.

Also, I do not want to resort to setting the focus elsewhere after clicking the button like some of you are probably thinking I could. This does not work because I want don't even want the focus rectangle to appear on the mouse down even of the button, which it does automatically.

Any help or example would be greatly appreciated..


Focus To Submit Button
Sorry if this question has been answered before - I searched, but couldn't find it.

On my form, I'd like the user to be able to hit return/enter and have it automatically fire the submit button (or the sub that the submit button fires). How do I do this?


ps, on a side note, I'm using the Menu Editor to create my menus but the underlines for the Alt keys (&) don't show up until after the Alt key is pressed - how do I have the underlines display all the time???

"Not for philosophy does the rose give a damn."

Msgbox Button Focus
Is there a way to control the focus of the buttons
in a msgbox when there are 2 buttons?

vbYesNo box and I want to place the focus on the no button

Edited by - ootencl on 6/3/2004 12:35:31 PM

Removing Focus From All Command Buttons..
I dont want the form to have the focus on any of the command buttons.. what should i do??

How To Prevent Command Btn From Taking Focus?
I don't want some command buttons on my form to take the focus when they are clicked. Is there some easy way out, like setting some properties etc. I want only the depress and release effects, no dotted rectangle.

Setting Focus For Command Buttons
I have an on-screen numeric keypad that I want to use to input data into 4 textboxes. What is the syntax to specify that the command buttons write to whichever box the cursor is in?

Any Way To Remove The Focus Frame On A Command Box?
When you click a button, the button border will be blackened by a rectangle,

and more, windows will draw a dashed rectangle inside the button. It looks

ugly. How can I make the command button toolbar button like? Any idea will

be highly appreciated.

Where there's a wire , there's a way

Focus On Textbox &gt; Submit Button
when i fill in something at a certain textbox i want a certain commandbutton too be the submit button. How can i focus on that commandbutton when something is filled in at the textbox ?

Is It Possible To Disable Mouse Focus On A Button?
Hi, just wondering if it is possible. I am working on a program, which uses arrow keys to select the buttons instead of the mouse pointer. I want to set the focus only for the arrow keys and not the mouse pointer. Is there a way to do this? Thanks btw, and good luck!

Pressing A Button Without Giving It Focus
I am trying to add an on-screen keyboard to my program. I have copied the basic layout of a keyboard, using buttons in place of keys. The keyboard is in it's own form.

I want to be able to press a button on the keyboard and have it send a character to where ever the curser is blinking. I know I can send the character using SendKeys, however the act of pressing the button sets the focus to the button and the keyboard form, so the character is sent to this instead of to where the curser was blinking. Is there anyway to press the button without affecting the curser position, or is there another way round this?

thanks in advance

Form/button Focus Problem
i have a little vb6 app that parses rather large files. i want to include a button on the main form that will stop the file parsing at any time. i am using a progress bar on the main form to indicate file parsing progress. however, i am having difficulty in keeping a button in focus [or something] so that i can click it to stop the parsing.

also, task manager indicate that the app is not responding. how do i make this button available to use? how do i make the app show normal ops in task manager?

Remove Focus Rectangle On Button
How to remove the focused rectangle on the button (dotted line around the edge when the button got focus)?


Button Focus And Forms Move
if a button is clicked then it got focus i dont want this how to get rid from this if u dont understand then open vb and make a button run and press the button once now watch carefully it got a focus i mean inside the button a rectangle is appeared
when i open the new form then its show the vibration like effects i mean its move i want to open new form with out any moving my forms are equal of length and width i mean if two forms are identical then when open the 2nd form then no feels that these are chnged

Assigning A Run Command To A Command Button
How would I assign a simple run command (ie. start --> run) to a command button? So that when the button is clicked the window would pop up as if you had went start --> run and hit OK (ex: winipcfg or a targeted .exe).

DirListBox Right-mouse-button Change Focus
I have a DirListBox, and I want to be able to have the right-mouse-button change the row focus.

This would allow the pop-up menu to act on the row that was clicked rather than the currently highlighted (selected) row.

Any ideas?

Making The Default Button,setting The Focus

if i have a form which haas a text box and two do i make the default focus to be in the text box and the default button to be OK button, so that when i hit enter without clicking anywhere, it sort of clicks ok(enters on OK)...


Html Button- To -command Button HELP
i am trying to get a command button in vb to trigger a button on a web page. it is kind of a wierd button, but you can look at it here:


i need those buttons to work if i press down on the similar button that i make in vb:

image of buttons in vb

can anyone help me with this?

Linking Opt Button To A Command Button
I was wondering how i would code, an option button to display a message but only when i hit the Display command button ? Here is my code

Private Sub cmdDisplay_Click()

lblcode.Caption = "Catalog Code: " & txtCode.Text
lblcode.Visible = True
lblNumber.Caption = "Page Number: " & txtPage.Text
lblNumber.Visible = True
lblPart.Caption = "Part Number: " & txtNumber.Text
lblPart.Visible = True

End Sub

Private Sub optCharge_Click()

If optCharge.Value = True Then lblPayment.Caption = "Payment Type: Charge "

End Sub

Private Sub optCOD_Click()
If optCOD.Value = True Then lblPayment.Caption = "Payment Type: COD "
End Sub

Private Sub optExpress_Click()

If optExpress.Value = True Then lblShip.Caption = "Shipping Method: Express"
End Sub

Private Sub optGround_Click()
If optGround.Value = True Then lblShip.Caption = "Shipping Method: Ground"
End Sub

Private Sub optMoneyOrder_Click()

If optMoneyOrder.Value = True Then lblPayment.Caption = "Payment Type: Money Order"
End Sub

Copyright 2005-08, All rights reserved