Last active
February 27, 2021 02:21
-
-
Save thoughtcroft/f5850fba733eb0a2513cc5872166080b to your computer and use it in GitHub Desktop.
2005-11-25-set-text-edit-mode.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Public Enum TextEditMode | |
temcInvalid = 0 | |
temcLockedTrue = 2 ^ 0 | |
temcLockedFalse = 2 ^ 1 | |
temcEnabledTrue = 2 ^ 2 | |
temcEnabledFalse = 2 ^ 3 | |
temcEnterWithEdit = temcLockedFalse + temcEnabledTrue | |
temcEnterNoEdit = temcLockedTrue + temcEnabledTrue | |
temcNoEnterNormal = temcLockedTrue + temcEnabledFalse | |
temcNoEnterDimmed = temcLockedFalse + temcEnabledFalse | |
End Enum | |
Public Function SetTextEditMode( _ | |
ByRef ctl As Control, _ | |
Optional ByVal temMode As TextEditMode) As TextEditMode | |
' Set or return the value of Enabled and Locked properties | |
' in a text based control to manage how it looks as follows: | |
' Enabled? Locked? Result? | |
' Yes Yes Can enter, can't edit, normal | |
' Yes No Can enter, can edit, normal | |
' No Yes Can't enter, can't edit, normal | |
' No No Can't enter, can't edit, dimmed | |
' If no mode requested then returns the current settings | |
' Developed by Warren Bain on 21/10/2005 | |
' Copyright (c) Thought Croft Pty Ltd | |
' All rights reserved. | |
' Check we can do this for this type of control | |
Select Case ctl.ControlType | |
Case acComboBox, acCheckBox, acListBox, acTextBox | |
If IsMissing(temMode) Then | |
' Let them know what is set | |
SetTextEditMode = IIf(ctl.Enabled, temcEnabledTrue, temcEnabledFalse) + _ | |
IIf(ctl.Locked, temcLockedTrue, temcLockedFalse) | |
Else | |
' Set the controls parameters | |
ctl.Enabled = temMode And temcEnabledTrue | |
ctl.Locked = temMode And temcLockedTrue | |
SetTextEditMode = temMode | |
End If | |
Case Else | |
SetTextEditMode = temcInvalid | |
End Select | |
End Function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment