Readonly textbox - minus blinking + events; how?

  • Thread starter Thread starter Atlas
  • Start date Start date
A

Atlas

I've been tryng multiple configs of a textbox to avoid user input, avoid
dimming, enable events handling but it looks like it's impossible:

- .enabled = no & .locked = yes gives readability, no blinking cursor but
prevents events handling (like doubleclick)
- .enabled = yes & .locked = yes gives readability, blinking cursor, events
handling (like doubleclick)
- .enabled = no & .locked = no gives unreadability (dimmed), no blinking
cursor, no events handling
- .enabled = yes & .locked = no gives readability, blinking cursor, events
handling (like doubleclick) and unwanted user input

Is there a simple way to make a field readonly, without cursor blinking,
with events handling?

Bye

Rookie running Access 2003 * A Smart by Design product *
 
Sounds like contraditory requirements.

If the text box can receive focus (can be clicked, can click in the box and
select text), then Windows must provide the cursor so you know where you
are.
 
Sounds like contraditory requirements.

This is how it should be:
- Readonly
- Noblink
- Can receive focus (tab stop)
- Handles events

What's wrong?

Back again to crappy model or rookie on the run?
 
Atlas said:
I've been tryng multiple configs of a textbox to avoid user input,
avoid dimming, enable events handling but it looks like it's
impossible:

- .enabled = no & .locked = yes gives readability, no blinking cursor
but prevents events handling (like doubleclick)
- .enabled = yes & .locked = yes gives readability, blinking cursor,
events handling (like doubleclick)
- .enabled = no & .locked = no gives unreadability (dimmed), no
blinking cursor, no events handling
- .enabled = yes & .locked = no gives readability, blinking cursor,
events handling (like doubleclick) and unwanted user input

Is there a simple way to make a field readonly, without cursor
blinking, with events handling?

Bye

Rookie running Access 2003 * A Smart by Design product *

You can call the Windows API hide ot show the caret in the control's
GotFocus and LostFocus events, using code llike this:

'----- start of code -----
Private Declare Function apiShowCaret Lib "user32" _
Alias "ShowCaret" _
(ByVal hwnd As Long) _
As Long

Private Declare Function apiHideCaret Lib "user32" _
Alias "HideCaret" _
(ByVal hwnd As Long) _
As Long

Private Declare Function apiGetFocus Lib "user32" _
Alias "GetFocus" _
() As Long


Private Sub Text1_GotFocus()

Dim lngRet As Long

lngRet = apiHideCaret(apiGetFocus())

End Sub


Private Sub Text1_LostFocus()

Dim lngRet As Long

lngRet = apiShowCaret(apiGetFocus())

End Sub
'----- end of code -----

A quick test suggests that some things you may do in other events may
require you to hide the caret again. For example, I displayed a MsgBox
in the control's Click event, and found that the caret reappeared
afterward.
 
Back
Top