[bmx] Word wrap by col [ 1+ years ago ]

Started by BlitzBot, June 29, 2017, 00:28:41

Previous topic - Next topic

BlitzBot

Title : Word wrap
Author : col
Posted : 1+ years ago

Description : ( MaxGUI - Windows )
You can switch the word wrap feature of a TextArea gadget on and off using this code.

This code is for Windows only.


Code :
Code (blitzmax) Select
Strict

Import MaxGUI.Drivers

Global Window:TGadget = CreateWindow("Word wrap",200,0,500,500)
Global Text:TGadget = CreateTextArea(0,0,ClientWidth(Window),ClientHeight(Window)-60,Window)

' Some text
SetGadgetText Text,"Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nulla eget mauris quis dolor "+..
"ullamcorper dapibus. Duis facilisis ullamcorper metus. Pellentesque eget enim. Vivamus auctor hendrerit turpis. " + ..
"Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Vivamus tincidunt leo quis urna."

Global WordWrapChoice:TGadget = CreateButton("Word wrap",10,GadgetHeight(Text)+10,100,30,Window,BUTTON_CHECKBOX)

Repeat
WaitEvent

Select EventSource()
Case Window
If EventID() = EVENT_WINDOWCLOSE End

Case WordWrapChoice
Local hWnd = QueryGadget(Text,QUERY_HWND)

Select ButtonState(WordWrapChoice)
Case True
SendMessageW(hWnd,EM_SETTARGETDEVICE,0,0)

Case False
SendMessageW(hWnd,EM_SETTARGETDEVICE,0,1)
EndSelect
EndSelect
Forever


Comments :


TAS(Posted 1+ years ago)

 CreateTextArea() supports the two styles. TEXTAREA_WORDWRAP Long lines of text 'wrap round' onto the next lines. TEXTAREA_READONLY The text cannot be edited by the user.


MOBii(Posted 1+ years ago)

 SuperStrict:
SuperStrict

Import maxgui.Drivers


Global Window:TGadget = CreateWindow("Word wrap",200,0,500,500)
Global Text:TGadget = CreateTextArea(0,0,ClientWidth(Window),ClientHeight(Window)-60,Window)

' Some text
SetGadgetText Text,"Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nulla eget mauris quis dolor "+..
"ullamcorper dapibus. Duis facilisis ullamcorper metus. Pellentesque eget enim. Vivamus auctor hendrerit turpis. " + ..
"Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Vivamus tincidunt leo quis urna."

Global WordWrapChoice:TGadget = CreateButton("Word wrap",10,GadgetHeight(Text)+10,100,30,Window,BUTTON_CHECKBOX)

Repeat
WaitEvent()

Select EventSource()
Case Window
If EventID() = EVENT_WINDOWCLOSE End

Case WordWrapChoice
Local hWnd:Int = QueryGadget(Text,QUERY_HWND)

Select ButtonState(WordWrapChoice)
Case True
SendMessageW(hWnd, EM_SETTARGETDEVICE,0,0)

Case False
SendMessageW(hWnd , EM_SETTARGETDEVICE,0,1)
EndSelect
EndSelect
Forever
Thanks for this Example [/i]