Archived Boards > WinBatch Script Exchange

Ink Control - text recognition simple example

(1/3) > >>

....IFICantBYTE:
Was playing around with the Microsoft Ink Control.... came up with this... maybe someone can find a use for it in one of their projects.
Have fun.


--- Code: Winbatch ---;Made the following to play around with the Microsoft ink control.
;It doesn't do anything very useful as is, but could be the basis for something in a touch screen environment?
;The text recognition is pretty impressive. Hope you find it helpful one day for something ....IFICantBYTE


;Refer to : https://msdn.microsoft.com/en-us/library/ms823910.aspx


#DefineSubRoutine DlgTest(Dlg_Handle, Dlg_Message, Dlg_ID, Dlg_EventInfo, Dlg_ChangeInfo)
; Dialog messages.
MSG_INIT = 0 ; The one-time initialization.
MSG_BUTTONPUSHED = 2 ; Button press.
MSG_COMEVENT = 14 ; COM control event fired.
; Options for DialogObject function.
DLGOBJECT_ADDEVENT = 1 ;DialogObject add event.
DLGOBJECT_GETOBJECT = 3 ;DialogObject get reference to object.

COM_CHANGE = 1 ; User specified identifier for "change" event.
COM_CLICK = 2 ; User specified identifier for "click" event.

Switch Dlg_Message
        Case MSG_INIT
                DialogProcOptions( Dlg_handle, MSG_BUTTONPUSHED, 1 )
                ; Handle mouse click events.
                DialogObject(Dlg_Handle, "ComControl_1", DLGOBJECT_ADDEVENT, "Change", COM_CHANGE)
                DialogObject(Dlg_Handle, "ComControl_1", DLGOBJECT_ADDEVENT, "Click", COM_CLICK)
                ; Get an object reference to the com control.
                objCom = DialogObject(Dlg_Handle, "ComControl_1", DLGOBJECT_GETOBJECT)
                objCom.Text = "Use the mouse or draw some text directly on a touch screen in this window, then wait a couple of seconds for text recognition."
                objcom.MousePointer=2 ; 0=default dot, 1=Arrow, 2=Cross, 3=Ibeam, 4=SizeNE-SW, 5=SizeN-S, 6=SizeNW-SE, 7=SizeW-E, 8=Up, 9=Hourglass/WaitCircle, 10=NoDrop, 11=Arrow+Hourglass/WaitCircle, 12=Arrow+?, 13=Size, 14=PointingHand, 99=CustomIcon specified by MouseIcon property
                objcom.UseMouseForInput=@True
                blue = 250
                green = 200
                red = 200
                objcom.BackColor=blue*256*256+green*256+red
                objcom.Enabled=@True
                objcom.RecognitionTimeout=2000
                objcom.InkMode=2 ;0=disabled, 1=ink collected, 2=ink and single stroke gestures
                objcom.InkInsertMode=0  ;0=text, 1=ink
                objcom.Locked=@False
                objcom.SelFontName="Times"
                objcom.SelFontSize=20
                blue = 10
                green = 10
                red = 170
                objcom.SelColor=blue*256*256+green*256+red
        Break

        Case MSG_COMEVENT
                ; Correct COM control and event?
                If Dlg_ID == "ComControl_1"
                        If Dlg_EventInfo.identifier == COM_CHANGE
                                Message("CHANGE","changes detected to text in ink area")
                        ElseIf Dlg_EventInfo.identifier == COM_CLICK
;                               Message("CLICK","mouse click detected on ink area")
                        EndIf
                EndIf
        Break

        Case MSG_BUTTONPUSHED
                If Dlg_ID == "PushButton_OK"
                        text = objCom.Text
                        Message("Plain text returned",text)
                        rtftext = objCom.TextRTF
                        Message("RTF text returned",rtftext)
                EndIf
                If Dlg_ID == "PushButton_Cancel"
                        ; Release Objects.
                        Dlg_EventInfo = 0
                        objCom = 0
                        Return(-1)
                EndIf
        Break

EndSwitch
Return(-2)
#EndSubRoutine ; End of Dialog Callback.


MyDialogFormat=`WWWDLGED,6.2`

MyDialogCaption=`WIL Dialog 1`
MyDialogX=220
MyDialogY=072
MyDialogWidth=584
MyDialogHeight=359
MyDialogNumControls=003
MyDialogProcedure=`DlgTest`
MyDialogFont=`DEFAULT`
MyDialogTextColor=`DEFAULT`
MyDialogBackground=`DEFAULT,DEFAULT`
MyDialogConfig=0

MyDialog001=`171,339,036,012,PUSHBUTTON,"PushButton_OK",DEFAULT,"OK",1,10,32,DEFAULT,DEFAULT,DEFAULT`
MyDialog002=`377,339,036,012,PUSHBUTTON,"PushButton_Cancel",DEFAULT,"Cancel",0,20,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog003=`013,011,554,318,COMCONTROL,"ComControl_1",DEFAULT,"InkEd.InkEdit.1",DEFAULT,30,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
ButtonPushed=Dialog("MyDialog")

stanl:
Impressive! Thanks for sharing.

td:
Created a Tech Database article.  Script is more or less unchanged except for conversion to the new dialog constants.

http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+WinBatch/Dialog~Editor/Dialog~Editor~version~6.2/Samples+Microsoft~InkEdit~COMCONTROL.txt

JTaylor:
Finally got a chance to take a look....Very Nice!!!   

Thanks.

Jim

stanl:
Looked at the control through Tony's Type Viewer. The methods are quite limited, i.e. no save(). However, as it is a subclass of richedit maybe the WB CLR can handle it. I really have a need to use a control like that as a signature in an Excel form. Hope to find time to dig around in that area.

Navigation

[0] Message Index

[#] Next page

Go to full version