TextBox ReadOnly Property

Started by Martin Francom, April 27, 2011, 04:28:46 PM

Previous topic - Next topic

Martin Francom

How do I (programatically) turn the ReadOnly property ON and OFF for a TextBox?

I have tried this but must have the wrong syntax:

   FF_Control_ReadOnlyOn (HWND_FORM1_TXT1)
   FF_Control_ReadOnlyOff (HWND_FORM1_TXT1)

What is the correct syntax?

Jean-pierre Leroy

Hi Marty,

You have to use the Windows API :

SendMessage HWND_FORM1_TXT1, %EM_SETREADONLY, %TRUE , 0  ' to turn Read Only Property On
SendMessage HWND_FORM1_TXT1, %EM_SETREADONLY, %FALSE, 0  ' to turn Read Only Property Off


Jean-Pierre

Martin Francom

#2
Jean-Pierre,
   Thanks. I thought there might be a FireFly method. 
I should have thought about the Windows API.  I want
to replace some FF_Control_Disable and FF_Control_Enable
function with functions that enable or disable the ReadOnly property.
I think what I am going to do is create two new FF functions that
do as you suggest and use the Windows API.  The reason being is that
I have a lot of changes to make and by having a function whose structure
is similar to the FF function it will be easier and faster to make the change.

here's the FF Sub I will create:



Sub FF_Control_Disable_ReadOnly ( ByVal hWndControl As Dword )
    ' Do a check to ensure that this is actually a window handle
    If IsWindow(hWndControl) Then 
       
       ' Disable the window READONLY property.
        SendMessage hWndControl, %EM_SETREADONLY, %FALSE, 0     ' to turn Read Only Property Off
       
    End If
End Sub

Sub FF_Control_Enable_ReadOnly ( ByVal hWndControl As Dword )
    ' Do a check to ensure that this is actually a window handle
    If IsWindow(hWndControl) Then 
       
       ' Enable the window READONLY property.
        SendMessage hWndControl, %EM_SETREADONLY, %TRUE, 0     ' to turn Read Only Property On
       
    End If
End Sub


 

Paul,  This won't interfere with any thing your doing will it?   

Jean-pierre Leroy

Marty another solution is to use Jose Roca wrappers for Edit Control:

There is a function called Edit_SetReadOnly() that do exactly what you need.

See the Help File