disable control

Started by raymw, January 28, 2017, 01:09:42 PM

Previous topic - Next topic

raymw

sometimes I want to disable a text box, so that the user can not alter any text their, but I want the program to still be able to change the text. The FF_CONTROL_DISABLE is not quite what I want, since it greys out the text and prevents any alterations to its contents. Any suggestions?

Paul Squires

#1
You can still alter the contents of a disabled control even after FF_CONTROL_DISABLE. If you don't want the grey background then maybe you are looking to just set the textbox as read only?
http://www.planetsquires.com/protect/forum/index.php?topic=2862.msg21332#msg21332
Paul Squires
PlanetSquires Software

raymw

Thanks for the link - I managed to get it to work using something like this (from that link  SendMessage hWndControl, %EM_SETREADONLY, %FALSE, 0     ' to turn Read Only Property Off) except that I had to remove the %'s. Is there a recommended reference to the windows api.

Paul Squires

Quote from: raymw on January 28, 2017, 06:18:38 PM
... except that I had to remove the %'s.
There is a LOT of code in these forums related to PowerBasic. Constants in PB are prefixed with a %. FreeBasic doesn't use a %.

QuoteIs there a recommended reference to the windows api.

Here is the mothership of information:
https://msdn.microsoft.com/en-us/library/windows/desktop/ff818516(v=vs.85).aspx

These are the two books that I used to really understand a lot of core WinAPI concepts:
https://www.amazon.ca/Programming-Addison-Wesley-Advanced-Newcomer-Paperback/dp/B00HUC2SJC/ref=sr_1_1?ie=UTF8&qid=1485702777&sr=8-1
https://www.amazon.ca/Programming-Windows-5th-Charles-Petzold/dp/157231995X/ref=sr_1_4?s=books&ie=UTF8&qid=1485702874&sr=1-4

Paul Squires
PlanetSquires Software

raymw

Thanks, not sure I'd understand the books, but I think when I need to, I'll try a few of the api calls.
For the sake of completeness, I've shown my subroutine for making the textbox read only (or not) which works fine with freebasic. Sub ff_control_readonly(ByVal hwndcontrol as dword,flag as boolean)
                                   'if flag is true, then control is read only
If IsWindow(hWndControl) Then
  If flag=True  Then
      FF_Control_SetColor( hwndcontrol, &Hf000000, &Hf0f0f0 )
   Else
      FF_Control_SetColor( hwndcontrol, &Hf000000, &Hffffff )   
   End If       
      SendMessage hWndControl, EM_SETREADONLY, Flag, 0         
End If

End Sub


I guess it could be 'improved', but I've not tried it with anything other than text boxes.