The CustomButton template is just that: a template. It was designed to replicate a VB button's actions, it does not include usable code to draw the caption, icons, or anything else related to the display of the button. Some drawing code is provided for example purposes only. Why? These routines cannot be easily provided in a template because some users may want captions aligned one way or the other, support unicode or not, allow caption-less/image-only buttons, and a myriad of other scenarios. The button's display is your responsibility, the button's actions are mine.
I think that if you want to create your own custom button, this template is a perfect starting point. It does all the hard work of making the button responsive to the user and to the coder. I have attempted to replicate the VB button's actions exactly and believe I have done it 100%, or at least 99.9%. Events are fired in the same order as VB's button, overridable event parameters are supported same as VB's button, and in the case of MouseEnter/MouseLeave events, I used my own logic since VB buttons don't provide these.
There are 2 CustomButton templates. The one with the project has minimal drawing routines added to it so that it can be used with the sample project and is for the sample project only. It is derived from the raw template. The other, in the ResuableTemplate folder, is the raw template.
You can even add the raw template (.ctl file) to your VB templates folder [C:\Program Files\Microsoft Visual Studio\VB98\Template\Userctls]. And it will appear when you opt to Add|User Control from your project tree/explorer.
Edited: Error noted by PatVB. When usercontrol is used to unload a form it is on by clicking the control, an error stating that the control is no longer sited occurs. This is happening because the mouse up of the click event is trying to send the form a MouseUp event. But since the control is "unloaded", the error occurs. The patch is simple:
1. As the first line of the UserControl_MouseUp event, add: On Error GoTo EH
2. As the very last line in the same event, add: EH:
Last edited by LaVolpe; Apr 22nd, 2010 at 02:26 PM.
Insomnia is just a byproduct of, "It can't be done"
The CustomButton template is just that: a template. It was designed to replicate a VB button's actions, it does not include usable code to draw the caption, icons, or anything else related to the display of the button. Some drawing code is provided for example purposes only. Why? These routines cannot be easily provided in a template because some users may want captions aligned one way or the other, support unicode or not, allow caption-less/image-only buttons, and a myriad of other scenarios. The button's display is your responsibility, the button's actions are mine.
I think that if you want to create your own custom button, this template is a perfect starting point. It does all the hard work of making the button responsive to the user and to the coder. I have attempted to replicate the VB button's actions exactly and believe I have done it 100%, or at least 99.9%. Events are fired in the same order as VB's button, overridable event parameters are supported same as VB's button, and in the case of MouseEnter/MouseLeave events, I used my own logic since VB buttons don't provide these.
There are 2 CustomButton templates. The one with the project has minimal drawing routines added to it so that it can be used with the sample project and is for the sample project only. It is derived from the raw template. The other, in the ResuableTemplate folder, is the raw template.
You can even add the raw template (.ctl file) to your VB templates folder [C:\Program Files\Microsoft Visual Studio\VB98\Template\Userctls]. And it will appear when you opt to Add|User Control from your project tree/explorer.
I am trying to modify the Ctrl to add a Bitmap picture on it. When I run it, Igert this error message: "Line 9: Property Picture in CustomButton had an invalid file reference.". I am sure that I'm doing something wrong...any ideas
I reload the program without the error. But I am stuck trying to put another skin on the Ctrl.
The problem is, I set the picture property of the template to a bitmap and size it accordingly. When I run the test program, the bitmap is showing on a corner of the ctrl as oppose to over the whole ctrl....Any ideas
Thanks for your reply....I am under the gun trying to put a skin on a CommandButton control.
Set the control's AutoRedraw to True. Use PaintPicture to stretch the image to the control's dimensions. Please post additional questions in the VB6 forum as it appears you do not have a specific issue with the control's functionality; but rather with VB in general.
If you do post in the VB6 forum, be sure to give plenty of details and some sample code of what you are trying to do.
Insomnia is just a byproduct of, "It can't be done"