Dialog Extender with RichEdit Control

Started by JTaylor, December 04, 2020, 11:12:52 AM

Previous topic - Next topic

JTaylor

I have updated the Dialog Extender to include a RichEdit Control.   Example script is rte.wbt.  Will probably expand options, especially if there is interest, but thought I would throw this out there to see if anyone found it useful.

   http://www.jtdata.com/anonymous/DialogEx.zip

A related question, is there a way to assign a "Name" to a control that WinBatch would recognize or is that purely a WinBatch thing?   So I could do things like SetFocus, Resize, etc via WB Dialog Functions.   I assume notifications would not be an option?  Any other options to accomplish such a thing via an Extender?

If you get bored Tony and want to add this Control to WinBatch with nothing but basic Notifications it would be VERY helpful.  I can pick up the slack via the Extender until you have time to do more.  This would be true of some other controls as well.  Even if you skipped the documentation and just told me which ones were available.   Would find some useful but they don't always play well with the display when I create them.   Plus, there hasn't been any significant Dialog enhancements in a while and Dialogs are feeling left out :)

IPAddress
Tabs
ProgressBar
TrackBar
StatusBar
ToolTips
Animation

I would also like to reiterate my request for a native Keypress Event.

Jim

JTaylor

I did just tweak things a bit with the Control Styles.  Just realized I didn't have things like ScrollBars active along with some other things that are helpful.  Was so focused on the Text formatting i didn't experiment as much as I should.

jim

stanl

5 years ago I would have been all over a rich-text control. I hope you get some good feedback on this. It works fine in Win Forms w/Powershell.


JTaylor

Yeah...wasn't sure if anyone would find this useful or not.  Mostly a learning exercise.   I was too clueless to do anything about it five years ago.   I tried doing this before but it went nowhere fast and gave up....guess I've gotten smarter :)

Jim

stanl

Quote from: JTaylor on December 06, 2020, 01:41:43 PM
Yeah...wasn't sure if anyone would find this useful or not.  Mostly a learning exercise.   
Jim


Absolutely. I think it is commendable the work you have done with the Extender.

td

"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

kdmoyers

Thanks Jim!  This might be useful in future.
-K
The mind is everything; What you think, you become.

stanl

Jim;


Since the CLR can compile C#... might try Rich Text test with CLR.... not sure about any efficacy but sounds like fun.

JTaylor

If you get to it let me know how it turns out...if I finish the project I am on at the moment I will take a look.   Don't think I have ever tried embedding a dialog control, using C#, into a WinBatch dialog.

Jim

stanl

No, it will be a WinForm... more interested in what can be passed back and forth to WB.

td

MSFT has been flopping around on UI interfaces for several years.   ILC LLC has been patiently waiting for MSFT to settle on which of the plethora of  interfaces they pick for the long term.  They seem to be closing in on UI technology that is accessible to both .Burgerflipper and desktop applications so there is some hope of a light at the end of the tunnel.

When the light shines a little brighter WIL will get a new scriptable UI that will replace WIL Dialogs; at least on newer Windows 10 systems.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

stanl

I embarrassed myself trying to work with CLR and XAML.

td

I personally kinda like the idea of XAML, text-based representations of UI interfaces despite the wordiness but that is just a personal preference. It is by no means an indicator of what WinBatch and WIL will be using in the future.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

stanl

Not meaning to hijack Jim's thread, below got me nowhere :-[  but having fun with the Windows Community Toolkit and XAML Controls Gallery.
Code (WINBATCH) Select


XAML = $"
<Window
   xmlns="http:://schemas.microsoft.com/winfx/2006/xaml/presentation"
   xmlns::x="http:://schemas.microsoft.com/winfx/2006/xaml"
   Title="Test Window" Height="350" Width="525">
   <Grid>
   <Label x::Name="label" Content="Winbatch XAML demo." HorizontalAlignment="Center" Margin="38,10,37.4,0" VerticalAlignment="Top" RenderTransformOrigin="1.056,1.635" Cursor="" FontSize="24" FontWeight="Bold"/>
   <Border BorderBrush="Black" BorderThickness="1" Height="238" Margin="20,57,20,0" VerticalAlignment="Top"/>
  </Grid>
</Window>
$"
ObjectClrOption('useany', 'System')
ObjectClrOption('useany', 'System.Xml')
ObjectClrOption('useany', 'System.Windows')
oDOc =  ObjectClrNew('System.Xml.XmlDocument')
oDoc.LoadXml(XAML)
oXML = ObjectClrNew('System.Xml.XmlNodeReader',oDoc)
;oReader = ObjectClrNew('System.Windows.Markup.XmlReader')



td

Not sure what you expected but I don't see anything in the class documentation that indicates that the "XmlDocument" class converts XML to a UI on its own.  XML based UI descriptions are analogous to RC scripts in conventional Win32 UI programming. They are descriptions that require considerable parsing and processing by the appropriate functions and/or class implementations to be converted into visual elements. 
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

stanl

Quote from: td on December 31, 2020, 07:40:13 AM
Not sure what you expected 


I expected to fail... just wanted to see how far I could get. Powershell handles it with


$windowMain=[Windows.Markup.XamlReader]::Load( $reader )


$windowMain.ShowDialog() | out-null



where $reader is the XAML, and ShowDialog() is the secret sauce. Maybe something to look forward to in 2021...

td

Not particularly useful because of a lack of support for delegates but is this what you had in mind?

Code (winbatch) Select
XAML = $"
<Window
   xmlns="http:://schemas.microsoft.com/winfx/2006/xaml/presentation"
   xmlns::x="http:://schemas.microsoft.com/winfx/2006/xaml"
   Title="Test Window" Height="350" Width="525">
   <Grid>
   <Label x::Name="label" Content="Winbatch XAML demo." HorizontalAlignment="Center" Margin="38,10,37.4,0" VerticalAlignment="Top" RenderTransformOrigin="1.056,1.635" Cursor="" FontSize="24" FontWeight="Bold"/>
   <Border BorderBrush="Black" BorderThickness="1" Height="238" Margin="20,57,20,0" VerticalAlignment="Top"/>
  </Grid>
</Window>
$"
ObjectClrOption('useany', 'System')
ObjectClrOption('useany', 'System.Xml')
ObjectClrOption('useany', 'System.Windows')
oDOc =  ObjectClrNew('System.Xml.XmlDocument')
oDoc.LoadXml(XAML)
oXML = ObjectClrNew('System.Xml.XmlNodeReader',oDoc)

; WinBatch's not so secret sauce. (mostly just convoluted)
ObjectCLrOPtion('useany', 'PresentationFramework')
objMReader = ObjectClrNew('System.Windows.Markup.XamlReader')
objWindow = objMReader.Load(oXML)
objWindow.ShowDialog()
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

stanl

sort of... except for the Unknown Name error calling ShowDialog() I first got.


[EDIT]: went back to earlier Post by Deana and this worked. Seems we were doing xaml stuff 2-3 years ago.
.... added Rich Text in xaml  ;)

Code (WINBATCH) Select


XAML = $"
<Window
   xmlns="http:://schemas.microsoft.com/winfx/2006/xaml/presentation"
   xmlns::x="http:://schemas.microsoft.com/winfx/2006/xaml"
   Title="Test Window" Height="350" Width="525">
   <Grid>
      <RichTextBox Margin="10,10,0,13" Name="RichTextBox1" HorizontalAlignment="Left" VerticalAlignment="Top" Width="500" Height="300"> 
      <FlowDocument> 
        <Paragraph> I am a flow document. Would you like to edit me? <Bold>Go ahead.</Bold> 
        </Paragraph> 
        <Paragraph Foreground="Blue"> I am blue I am blue I am blue. </Paragraph> 
      </FlowDocument> 
     </RichTextBox>
   </Grid>
</Window>
$"
Message("",XAML)


ObjectClrOption('useany', 'System')
ObjectCLrOPtion('useany', 'PresentationFramework')
ObjectCLrOPtion('useany', 'PresentationCore')
ObjectClrOption('useany', 'System.Xml')
oReader = ObjectClrNew('System.Xml.XmlReader')
cReader = ObjectClrNew('System.IO.StringReader',XAML)
oXmlReader = oReader.Create(cReader)


;Load Xaml
oXamlReader = ObjectClrNew('System.Windows.Markup.XamlReader')
oWin = oXamlReader.Load(oXmlReader)
oWin = ObjectClrType( 'System.Windows.Window', oWin ) 
oWin.Show()
TimeDelay(5)
oWin.Close()


Exit





td

Yes, I am familiar with the previous work.  Just thought for fun I would emulate the PS methodology.  And to be clear, the script I posted does not error but is not particularly useful either.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

stanl

Quote from: td on January 01, 2021, 10:02:30 AM
  And to be clear, the script I posted does not error but is not particularly useful either.


I'm sure it did. Just not on my PC. I think: System.Xml.XmlNodeReader is a little problematic on my machine as opposed to using ObjectClrNew('System.Xml.XmlReader'). Probably a moot point. And, yes, the script can create a window and that is it, so not useful. Happy New Year!

td

I think that adding the line

Code (winbatch) Select
objWindow = ObjectClrType( 'System.Windows.Window',objWindow)

before calling ShowDialog() will fix the problem.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

stanl

Exactly! and with a little syntax checking can use System.Xml.XmlNodeReader w/out error. I'll probably bring XAML up again in a separate thread.  :-[

Ron47

I need this simple edit box in which all the controls (the MULTILINEBOX, and the pushbuttons) are resized when a user resizes the box.
Any suggestions?



MyDialogFormat=`WWWDLGED,6.2`

MyDialogCaption=`Edit Box`
MyDialogX=700
MyDialogY=087
MyDialogWidth=200
MyDialogHeight=206
MyDialogMinWidth=000
MyDialogMinHeight=000
MyDialogNumControls=004
MyDialogProcedure=`DEFAULT`
MyDialogFont=`Microsoft Sans Serif|8192|40|34`
MyDialogTextColor=`DEFAULT`
MyDialogBackground=`DEFAULT,DEFAULT`
MyDialogConfig=0
MyDialogDPI=`96,8,16`

MyDialog001=`151,183,036,012,PUSHBUTTON,"PushButton_Cancel",DEFAULT,"Cancel",0,4,@csFlat,DEFAULT,DEFAULT,DEFAULT`
MyDialog002=`001,001,200,176,MULTILINEBOX,"MultiLineBox_1",mlVariable1,DEFAULT,DEFAULT,1,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog003=`003,183,070,014,PUSHBUTTON,"Transfer",DEFAULT,"Transfer",1,2,@csFlat,DEFAULT,DEFAULT,DEFAULT`
MyDialog004=`075,183,068,012,PUSHBUTTON,"Transfercontinue",DEFAULT,"Transfer continue",2,3,@csFlat,DEFAULT,DEFAULT,DEFAULT`

ButtonPushed=Dialog("MyDialog")

JTaylor

Search for "resize controls taylor move" in the Tech Database and choose the Resize Controls option.  I wrote some UDFs for doing this very thing.

Jim

Ron47

Got it and am able to resize the controls!

But, I'm still a novice so I'm still looking at your code to figure out some things.
For one, the three pushbuttons stay on the right of box as it's expanded instead of being centered or left-aligned. - This is minor and I'm sure I can figure it out.

But, most importantly, I'm trying to get a return value for pb_go (transfer) and transfercontinue so I can execute the subroutines.

MoveFormat=`WWWDLGED,6.2`

MoveCaption=`VC Dictation Box`
MoveX=800
MoveY=038
MoveWidth=200
MoveHeight=180
MoveMinWidth=200
MoveMinHeight=180
MoveNumControls=005
MoveProcedure=`Move_Sub`
MoveFont=`DEFAULT`
MoveTextColor=`DEFAULT`
MoveBackground=`DEFAULT,DEFAULT`
MoveConfig=0
MoveDPI=`96,8,16`

Move001=`011,003,036,012,PUSHBUTTON,"pb_go",DEFAULT,"Transfer",1,2,@csFlat,DEFAULT,DEFAULT,DEFAULT`
Move002=`061,003,060,012,PUSHBUTTON,"Transfercontinue",DEFAULT,"Transfer Continue",2,3,@csFlat,DEFAULT,DEFAULT,DEFAULT`
Move003=`121,003,036,012,PUSHBUTTON,"pb_exit",DEFAULT,"Cancel",0,4,@csFlat,DEFAULT,DEFAULT,DEFAULT`
Move004=`179,003,010,012,STATICTEXT,"st_url",DEFAULT,DEFAULT,DEFAULT,30,DEFAULT,"Microsoft Sans Serif|6144|70|34","055|055|055",DEFAULT`
Move005=`001,017,198,158,MULTILINEBOX,"eb_url",url,DEFAULT,DEFAULT,1,@csCurRight,"Microsoft Sans Serif|7680|40|34",DEFAULT,DEFAULT`

ButtonPushed=Dialog("Move")


JTaylor

Assuming I understand on the button movement....Use POS_MOVE_H with all the movement values being 1.   That will make them move them the full width of the movement.

Sounds like you want to be looking at the Dynamic Dialog options if you are not.   That will give you access to the pushbutton event.     If your subroutines will take a while I recommend using

    DialogProcOptions(Mov_Handle, @dpoDisable,0)                          ; Dialog Disable (1-Disable, 2-Wait cursor, 0-Enable).

With option number 2 before you start the routine and then 0 to enable upon return.   

Jim

JTaylor

In case it is helpful, here is an example using a Dynamic Dialog.

Code (winbatch) Select


#DefineSubRoutine Move_Sub(Mov_Handle,DMsg,DCID,DEInfo,ChangeInfo)

Switch (DMsg)
    Case @deInit
    DialogProcOptions(Mov_Handle, @deTimer,0)                             ; TimerEvent (0- Off).
    DialogProcOptions(Mov_Handle, @deClose,1)                             ; Close selected (IntControl(49....) (1-On, 0-Off).
    DialogProcOptions(Mov_Handle, @dpoDisable,0)                          ; Dialog Disable (1-Disable, 2-Wait cursor, 0-Enable).
    DialogProcOptions(Mov_Handle, @dpoBkground,-1)                        ; Change Dialog Background (Bitmap File or RGB String).
    DialogProcOptions(Mov_Handle, @dePbPush,1)                            ; Pushbutton/PictureButton.
    DialogProcOptions(Mov_Handle, @deEdText,1)                            ; EditBox or Multi-LineBox.
   
   
    Break
  Case @deTimer
    Break
  Case @deClose
    Return 9
    Break
  Case @deEdText
    Switch(DialogProcOptions(Mov_Handle,@dpoCtlNumber,DCID))
      Case DialogProcOptions(Mov_Handle,@dpoCtlNumber,"eb_url")
        url = DialogControlGet(Mov_Handle,"eb_url",@dcText)
        Break
    EndSwitch
    Break
  Case @dePbPush
    Switch(DialogProcOptions(Mov_Handle,@dpoCtlNumber,DCID))
      Case DialogProcOptions(Mov_Handle,@dpoCtlNumber,"pb_go")
        button_text = DialogControlGet(Mov_Handle,"pb_go",@dcTitle)

        Break
      Case DialogProcOptions(Mov_Handle,@dpoCtlNumber,"Transfercontinue")
        button_text = DialogControlGet(Mov_Handle,"Transfercontinue",@dcTitle)

        Break
      Case DialogProcOptions(Mov_Handle,@dpoCtlNumber,"pb_exit")
        button_text = DialogControlGet(Mov_Handle,"pb_exit",@dcTitle)

        Break
    EndSwitch
    Break
EndSwitch
Return -2

#EndSubRoutine
 




Jim

Ron47

Jim,

I'll try your suggestions.
Thank you!
Ron

JTaylor

Ron47.  Finally saw your P.M. and replied.  Sorry for the delay.  Thought I would mention it here in case you missed it like I did.

jim