|
-
Aug 25th, 2001, 03:52 AM
#1
Thread Starter
Junior Member
Locking a checkbox via API
Hello,
I'm trying to find an API that LOCKS a checkbox in VB. There isn't a Locked property for the checkbox but I've heard it can be done. Any ideas?
-
Aug 25th, 2001, 04:34 AM
#2
PowerPoster
Why not disable the box? Use the Enabled property.
-
Aug 25th, 2001, 04:37 AM
#3
PowerPoster
Hi
Yeah u beat me to same conclusion Midgets. Or maybe this is another attempt at changing the standard operation of a checkbox to confuse users? 
Regards
Stuart
-
Aug 25th, 2001, 04:41 AM
#4
Thread Starter
Junior Member
Changing the enabled property will cause the checkbox to be grayed. I want it to be enabled but that it's value will be locked.
-
Aug 25th, 2001, 04:46 AM
#5
PowerPoster
Ok
if u dont end up going API way u can always simply have a very small checkbox with no caption and an attached label control that doubles as the checkbox caption. U can add code to the Label click event to change the checkbox value when 'enabled' and to ignore the checkbox value when 'disabled'
Regards
Stuart
-
Aug 25th, 2001, 12:23 PM
#6
Fanatic Member
Use this to drive your users nuts.
VB Code:
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
Const GWL_STYLE = -16
Const BS_AUTOCHECKBOX = 1
' Make a checkbox control read-only (or restore its
' regular behavior).
' Doesn't work well if the Style property is set to 1-Graphical
Sub MakeCheckBoxReadOnly(CheckBox As CheckBox, ByVal bReadOnly As Boolean)
Dim lStyle As Long
lStyle = GetWindowLong(CheckBox.hWnd, GWL_STYLE)
If bReadOnly Then
lStyle = lStyle Or BS_AUTOCHECKBOX
Else
lStyle = lStyle And (Not BS_AUTOCHECKBOX)
End If
SetWindowLong CheckBox.hWnd, GWL_STYLE, lStyle
End Sub
Private Sub Command1_Click()
Static b As Boolean
Call MakeCheckBoxReadOnly(Check1, b)
b = Not b
End Sub
-
Aug 31st, 2001, 09:59 AM
#7
Addicted Member
Couldn't you just use the LockWindowUpdate API call ?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|