Article | 41018074 |
Type | HowTo |
Product | Engine |
Version | 4.0.1.1018 |
Date Added | 4/15/2003 |
Submitted by | Med Khaled ABDELKEFI |
Keywords |
In an empty VisualBasic project add a form and in this form a VectorDraw Proffesional or Standard control and a simple TextBox.
The commands that will be working is line, circle and Zoom Extends. Add the code below :
Private Sub Text1_KeyUp(KeyCode As Integer, Shift As Integer) If KeyCode = 13 Then If UCase(Text1.Text) = "LINE" Then Text1.Text = "" VDPro1.CommandAction.CmdLine "USER" Exit Sub End If If UCase(Text1.Text) = "ZE" Then Text1.Text = "" VDPro1.CommandAction.Zoom "E", 0, 0 Exit Sub End If If UCase(Text1.Text) = "CIRCLE" Then Text1.Text = "" VDPro1.CommandAction.CmdCircle "USER", "USER" Exit Sub End If VDPro1.PostCommandString Text1.Text ' write in the textbox 10,10 before pressing <enter> Key Text1.Text = "" End If End Sub
Open a new Delphi project and add a VectorDraw Standard component (vdStd1) and a editBox. An on the OnKeyDown event of this edit box write the code below :
procedure TForm1.KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin if key=13 then // enter pressed begin if UpperCase(edcmd.Text) = 'LINE' then begin edcmd.Text :=''; VDstd1.CommandAction.CmdLine('USER'); exit; end ; if UpperCase(edcmd.Text) = 'ZE' then begin edcmd.Text :=''; VDstd1.CommandAction.Zoom('E',0,0); exit; end ; if UpperCase(edcmd.Text) = 'CIRCLE' then begin edcmd.Text :=''; VDstd1.CommandAction.CMDCIRCLE('USER','USER'); exit; end ; VDstd1.PostCommandString (edcmd.Text); //' write in the textbox 10,10 before pressingKey edcmd.Text:=''; end; end;
Now in the text box write :
Line<enter>
10,20,0<enter>
5,0,0<enter>
<enter>
and a line from 10,20 to 5,0 will be drawn
or :
circle<enter>
5,5,0<enter>
3<enter>
<enter>
and a circle with center the point 5,5 and radious 3 will be drawn
or :
ZE<enter>
and a Zoom extends will be done.