Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Command button properties

Posted on 2005-04-21
8
Medium Priority
?
1,654 Views
Last Modified: 2013-12-25
Hi there

I have several command buttons which I need to set certain properties.

I already have some code that aligns the caption on the command button to the left, this is:

Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public Const GWL_STYLE = (-16)

lngOldValue = GetWindowLong(cmd_btn1.hWnd, GWL_STYLE)
SetWindowLong cmd_btn1.hWnd, GWL_STYLE, lngOldValue Or &H100

How do I set the background and foreground colours etc???

By simply typing "cmd_btn1.BackColor = RGB(148, 185, 226)", then I essentially overwrite what I have done in the above code and hence my caption returns to centre.

I don't really understand what GWL_STYLE is and I am assuming that I somehow have to incorporate my colour scheme using this method somehow?

Any help would be great!!!

Cheers

Andy
0
Comment
Question by:Colly321
8 Comments
 
LVL 14

Expert Comment

by:Shiju Sasidharan
ID: 13834169
Change Style Propery of button to
   1 -Graphical
and try
0
 

Author Comment

by:Colly321
ID: 13834222
Nah thats not it - it allows me to change the colours etc, but I no longer can set the caption to be left justified???
0
 
LVL 10

Accepted Solution

by:
edwardiii earned 2000 total points
ID: 13834855
Hi, Colly321.

This does seem somewhat involved.  For example, to set the ForeColor of a command button, see this URL:

     http://vbnet.mvps.org/index.html?code/subclass/buttoncolour.htm

This link also discusses this topic, and itself links to a 3rd party solution:

     http://www.mcse.ms/message293460.html (http://www.lebans.com/cmdbutton.htm)

Or, along shijusn's comment, go with the Style Property of "Graphical" and show an image on the command button (e.g. with the image being a snapshot of text that is aligned and colored as you wish).
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Colly321
ID: 13834961
Hi edwardiii

I think it comes down to either:

1. Colouring the background and accepting the caption is going to be aligned centre

or

2. Aligning the caption left, and accepting the standard windows colour.

I personally don't want to create images, which although they may look nice, they create more work in the long run, especially if the text needs changing on them?

Your 2 links aren't really what I want?

Cheers

Andy
0
 
LVL 10

Expert Comment

by:edwardiii
ID: 13836422
A third option, with the (http://www.lebans.com/cmdbutton.htm) link as an example, is to obtain a third-party button code, which will allow you to do everything you want.  Short of third-party code, you may be able to get the ForeColor API to work in tandem with your existing Left-alignment code, but setting BackColor hasn't been addressed at all.

Leave this post up for a while; another expert may provide exactly what you need.  You may even contact the page admin (bingie) to verify.  But thus far, everything I'm scanning online seems to indicate the fastest, easiest way to get what you want is to acquire a third-party solution as with lebans.com:)
0
 
LVL 48

Expert Comment

by:Mikal613
ID: 13844228
www.fpoint.com

USe there command buttons. Anything you can ever dream of doing with a button is there.
0
 
LVL 18

Expert Comment

by:Sethi
ID: 13863960
Here are a few excellent free XP controls that I use and the command button is too good. You can give it an XP or a classic look as well:
http://home.pages.at/vbmaster/Downloads.html
http://www.innovasys.com/
0
 

Author Comment

by:Colly321
ID: 13892653
Hi guys

Thanks for all your help, I have pretty much given up on this - there are ways to do both my requests, but it is pretty tricky to acheive both.

I think that the best way to think about it is to remember that it is a Windows program - not a Director style CD-ROM!!!!

My clients like the fancy graphics etc which I think is not always the best method of doing things!!!

Cheers

Andy
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month20 days, 17 hours left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question