Prevent Input in Text Area

BlitzPlus Forums/BlitzPlus Beginners Area/Prevent Input in Text Area

SebHoll(Posted 2005) [#1]
Hi,
I am making a program where I have a text area that contains text that I want people to be able to highlight and scroll but not edit. (A bit like using the DisableGadget() function but without greying the box and preventing scrolling/selection.) I have seen the ActivateGadget() command that allows keyboard input into a text area/text field. What I need is the opposite of this command, i.e. the command to disallow keyboard input to it? (I was hoping there was a DeactivateGadget()). I thought another way of doing this is by checking to see whether or not the text area has focus and if it has, set the focus to another gadget on the form, but I can't find a command that will set the focus elsewhere.

Please Help - I am stuck at this point

Seb


Kev(Posted 2005) [#2]
hi seb

blitzplus .decls


.lib "user32.dll"
user32_SendMessage%(hWnd%,Msg%,wParam%,lParam%):"SendMessageA"



an example

Const ES_READONLY = $800
Const EM_SETREADONLY = $CF

; Example provided by Mag, added to documentation by Mark Tiffany 
win = CreateWindow ("Test Text Area",0,0,300,300) ; create a window first 
txtbox = CreateTextArea(0,0,200,200,win) ; <--- CREATE TEXTAREA (Multi line text field) 

hwnd = QueryObject(txtbox,1)

user32_SendMessage(hwnd,EM_SETREADONLY,1,0)
user32_SendMessage(hwnd,ES_READONLY,1,0)

SetGadgetText txtbox,"Type anything (multiline) "+Chr$(13)+"And press Get Text button" ;put some text on that textare for info 
gt=CreateButton("Get Text",200,0,80,20,win);create button 
Repeat 
id=WaitEvent() ;wait for user action (in a form of event) 
If id=$803 Then End ;to quit program when receive Window close event 
If id=$401 And EventSource()=gt Then ;when ok is press 
Notify "This is your text in TextArea:"+Chr$(13)+TextAreaText$(txtbox);<<--TO GET TEXT FROM TEXTFIELD 
End If 
Forever 




SebHoll(Posted 2005) [#3]
ah, thanks! - Where do you get this from Kev? (All this wide-spread knowledge). Are you a professional programmer or something?

Thanks Anyways

Seb


Kev(Posted 2005) [#4]
hi

im not a professional programmer ive just been coding for about 15years its knowledge picked up over the years, i also have a love for the windows api. software protection, ect..

kev


Alaric(Posted 2006) [#5]
Nice bit of code for GUI only programs, but is there anyway to change the focus back to your main program after the user selects the text inside of the box? I've got an RPG I'm working on and need a place to put the text so I thought I'd use your lib. However, after the user clicks the text box the keyboard keys no longer have any effect due to the text area having focus. Is there any way around this? I'd imagine that there has to be a lib out there somewhere...