Editor Gadget character input limit.

Just starting out? Need help? Post your questions and find answers here.
AndyMK
Enthusiast
Enthusiast
Posts: 582
Joined: Wed Jul 12, 2006 4:38 pm
Location: UK

Editor Gadget character input limit.

Post by AndyMK »

I have an editor gadget with wordwrap enabled. The size of the editor is small and fits 10 lines before the vertical scroll bar appears. I dont want the scroll bars to appear as i need to limit the text to the size of the box. Is there a simple way to do this?
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: Editor Gadget character input limit.

Post by netmaestro »

SendMessage(GadgetID(<edit>), #EM_LIMITTEXT, <max chars>, 0)

Windows only.
BERESHEIT
AndyMK
Enthusiast
Enthusiast
Posts: 582
Joined: Wed Jul 12, 2006 4:38 pm
Location: UK

Re: Editor Gadget character input limit.

Post by AndyMK »

Thank you
AndyMK
Enthusiast
Enthusiast
Posts: 582
Joined: Wed Jul 12, 2006 4:38 pm
Location: UK

Re: Editor Gadget character input limit.

Post by AndyMK »

Is there a way to limit lines? I checked the constants on msdn but could see anything related to it.
User avatar
PureLeo
Enthusiast
Enthusiast
Posts: 221
Joined: Fri Jan 29, 2010 1:05 pm
Location: Brazil

Re: Editor Gadget character input limit.

Post by PureLeo »

Something like this could be used to limit lines....

Code: Select all

  Select WindowEvent()
  	Case #PB_Event_Gadget
  		Select EventGadget()
  			Case #Editor_0
  				Select EventType()
  					Case 1024
  						If CountGadgetItems(#Editor_0)>10
  							RemoveGadgetItem(#Editor_0,11)
  						EndIf
  				EndSelect
  		EndSelect
  EndSelect

Last edited by PureLeo on Wed Aug 03, 2011 3:13 am, edited 1 time in total.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: Editor Gadget character input limit.

Post by netmaestro »

You can try this: SendMessage_(GadgetID(<edit>), #EM_SHOWSCROLLBAR, #SB_VERT, 0) where the vertical scrollbar will not show.
BERESHEIT
AndyMK
Enthusiast
Enthusiast
Posts: 582
Joined: Wed Jul 12, 2006 4:38 pm
Location: UK

Re: Editor Gadget character input limit.

Post by AndyMK »

Thanks guy's, works a treat.
Post Reply