Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Checkbox vertical alignment

Received: by 10.180.96.6 with SMTP id do6mr645555wib.1.1351610844661;
        Tue, 30 Oct 2012 08:27:24 -0700 (PDT)
Path: ha8ni87407wib.1!nntp.google.com!feeder3.cambriumusenet.nl!feed.tweaknews.nl!217.73.144.44.MISMATCH!feeder.ecngs.de!ecngs!feeder2.ecngs.de!78.46.240.70.MISMATCH!weretis.net!feeder4.news.weretis.net!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail
From: "Mike Williams" <M...@WhiskyAndCoke.com>
Newsgroups: microsoft.public.vb.general.discussion
Subject: Re: Checkbox vertical alignment
Date: Tue, 30 Oct 2012 15:27:32 -0000
Organization: A noiseless patient Spider
Lines: 67
Message-ID: <k6orks$ior$1@dont-email.me>
References: <k6nci8$s76$1@dont-email.me> <k6oafp$7aj$1@speranza.aioe.org> <k6odav$m52$1@dont-email.me> <k6opf6$2uc$1@dont-email.me>
Mime-Version: 1.0
Injection-Date: Tue, 30 Oct 2012 15:27:24 +0000 (UTC)
Injection-Info: mx04.eternal-september.org; posting-host="e14007e54b6c9d9c4a7c508461bd6e4f";
	logging-data="19227"; mail-complaints-to="ab...@eternal-september.org";	posting-account="U2FsdGVkX1986d75bU66wglhPI4119wedZx2lyXZSus="
X-MimeOLE: Produced By Microsoft MimeOLE V6.0.6002.18463
In-Reply-To: <k6opf6$2uc$1@dont-email.me>
X-Newsreader: Microsoft Windows Mail 6.0.6002.18197
Cancel-Lock: sha1:LD0iirYtCWFixO+cBjToMp3VA/0=
X-Priority: 3
X-MSMail-Priority: Normal
Content-Type: text/plain;
	format=flowed;
	charset="utf-8";
	reply-type=response
Content-Transfer-Encoding: 7bit


"Tim Rude" <timrude.nos...@nospam.hotmail.com> wrote in message 
news:k6opf6$2uc$1@dont-email.me...
> "Mike Williams" <M...@WhiskyAndCoke.com> wrote in message 
> news:k6odav$m52$1@dont-email.me...
>> Yes, it does exactly what the OP wants.
>> Mike
>
> Well, I must be doing something wrong then because I can't get
> it to work. Here's my sample code for a Form with a checkbox
> (Check1) and two buttons (Command1(0) and Command1(1))
> in a control array.

Add a third CommandButton to your existing Form (Command1(2)) and use the 
following code instead of the code you are currently using (it uses the same 
code as you have already got for setting the size and caption of the 
CheckBox, but the rest is different). While you're at it, set the CheckBox's 
BackColor to cyan (or some other colour which contrasts with the BackColor 
of your Form) so that you can see more clearly see what happens with respect 
to the positioning of the text within the CheckBox.

Mike

Option Explicit
Private Declare Function GetWindowLong Lib "user32" _
   Alias "GetWindowLongA" (ByVal hwnd As Long, _
   ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" _
   Alias "SetWindowLongA" (ByVal hwnd As Long, _
   ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Const GWL_STYLE  As Long = (-16)
Private Const BS_TOP As Long = &H400&
Private Const BS_BOTTOM As Long = &H800&
Private Const BS_VCENTER As Long = &HC00&

Private Sub Form_Load()
With Check1
   .Height = 1575
   .Width = 1995
   .Caption = "This checkbox has a very long caption that " _
        & "wraps to multiple lines and does ugly things " _
        & "with the box alignment."
End With
Command1(0).Caption = "BS_TOP"
Command1(1).Caption = "BS_BOTTOM"
Command1(2).Caption = "BS_VCENTER"
End Sub

Private Sub Command1_Click(Index As Integer)
Dim style As Long
style = GetWindowLong(Check1.hwnd, GWL_STYLE)
Select Case Index
   Case 0
     SetWindowLong Check1.hwnd, GWL_STYLE, _
         (style And Not BS_BOTTOM) Or BS_TOP
   Case 1
     SetWindowLong Check1.hwnd, GWL_STYLE, _
         (style And Not BS_TOP) Or BS_BOTTOM
   Case 2
     SetWindowLong Check1.hwnd, GWL_STYLE, _
         style Or BS_VCENTER
End Select
Check1.Refresh
End Sub