Hi, SMALL BASIC programmer, welcome.
Did you know that SMALL BASIC can also make a draag-n-drop program?
Here is the code:
'1. Preparing the graphics windows
GraphicsWindow.Show()
GraphicsWindow.Width = Desktop.Width
GraphicsWindow.Height = Desktop.Height
GraphicsWindow.Top = 0
GraphicsWindow.Left = 0
'2. Define the program header introduction
TextWindow.WriteLine("Hello Welcome to drag and drop program")
TextWindow.WriteLine("Created by Jesus Christ, the Lord and Messiah")
TextWindow.WriteLine("==============================================")
'2. Interactive session with user
TextWindow.WriteLine("1. Enter the url of the background that you like: ")
u_bground = TextWindow.Read()
'u_bground = "C:\Users\Totardo\Downloads\download (6).jpg"
TextWindow.WriteLine("2. Enter the url of the icon to drag-and-drop that you like: ")
u_icon = TextWindow.Read()
'u_icon = "C:\Users\Totardo\Downloads\download.jpg"
TextWindow.WriteLine("3. Enter the the x position of the icon to drag and drop (itdad_x): ")
itdad_x = TextWindow.read()
'itdad_x = 100
TextWindow.WriteLine("4. Enter the y position of the icon to drag and drop (itdad_y): ")
itdad_y = TextWindow.Read()
'itdad_y = 100
TextWindow.WriteLine("5. Enter the width of the itdad (w_itdad): ")
w_itdad = TextWindow.Read()
'w_itdad = 396
TextWindow.WriteLine("6. Enter the height of the itdad (h_itdad): ")
h_itdad = TextWindow.Read()
'h_itdad = 100
'3. Drawing background and icon and place the icon
GraphicsWindow.DrawImage(u_bground,0,0)
s_icon = Shapes.AddImage(u_icon)
Shapes.Move(s_icon,itdad_x,itdad_y)
'4. Define the event handler
GraphicsWindow.MouseDown = md
i = 0
follow_mouse = 0
'5. Define the main loop
loopz:
while follow_mouse <> 0
Shapes.Move(s_icon,GraphicsWindow.mousex,GraphicsWindow.mousey)
TextWindow.WriteLine("This is follow mouse from the main program: " + follow_mouse)
'Program.Delay(1000)
endwhile
Goto loopz
'6. Define the sub procedure md for mouse down
Sub md
'6.1 Toggle the keydown switch on and off
If keydown = 1 Then
keydown = 0
Else
keydown = 1
EndIf
'TextWindow.WriteLine("Key is: " + keydown)
'6.2 do something based on the switch on or off
If keydown = 1 Then
TextWindow.WriteLine("Its down")
'TextWindow.WriteLine("This is follow mouse: "+ follow_mouse)
'mx = Mouse.MouseX
mx = GraphicsWindow.MouseX
my = GraphicsWindow.mousey
'TextWindow.WriteLine("This is mouse x: " + mx)
'TextWindow.WriteLine("This is mouse y: " + my)
'TextWindow.WriteLine("This is total width: " + (itdad_x + w_itdad))
'TextWindow.WriteLine("This is total height: " + (itdad_y + h_itdad))
'TextWindow.WriteLine(GraphicsWindow.width/2+","+GraphicsWindow.Height/2)
'GraphicsWindow.DrawLine(itdad_x,0,itdad_x,GraphicsWindow.Height)
'GraphicsWindow.DrawLine(itdad_x+w_itdad,0,itdad_x+w_itdad, GraphicsWindow.Height)
'GraphicsWindow.DrawLine(0,itdad_y,GraphicsWindow.width,itdad_y)
'GraphicsWindow.DrawLine(0,itdad_y+h_itdad,GraphicsWindow.width,itdad_y+h_itdad)
'If mx lebih besar pojok dan lebih kecil sama dengan w_itdad
itdad_x = Shapes.GetLeft(s_icon)
itdad_y = Shapes.GetTop(s_icon)
If mx >= itdad_x And mx <= itdad_x + w_itdad Then
'TextWindow.WriteLine("Inside the width")
if my >= itdad_y And my <= (itdad_y + h_itdad) Then
'TextWindow.WriteLine("Inside the height")
'TextWindow.WriteLine("Its connect!")
If follow_mouse = 0 Then
follow_mouse = 1
EndIf
EndIf
EndIf
Else
If follow_mouse = 1 Then
follow_mouse = 0
EndIf
EndIf
'TextWindow.WriteLine("This is follow mouse on a sub: " + follow_mouse)
'Shapes.HideShape(s_icon)
'Shapes.ShowShape(s_icon)
EndSub
Did you know that SMALL BASIC can also make a draag-n-drop program?
Here is the code:
'1. Preparing the graphics windows
GraphicsWindow.Show()
GraphicsWindow.Width = Desktop.Width
GraphicsWindow.Height = Desktop.Height
GraphicsWindow.Top = 0
GraphicsWindow.Left = 0
'2. Define the program header introduction
TextWindow.WriteLine("Hello Welcome to drag and drop program")
TextWindow.WriteLine("Created by Jesus Christ, the Lord and Messiah")
TextWindow.WriteLine("==============================================")
'2. Interactive session with user
TextWindow.WriteLine("1. Enter the url of the background that you like: ")
u_bground = TextWindow.Read()
'u_bground = "C:\Users\Totardo\Downloads\download (6).jpg"
TextWindow.WriteLine("2. Enter the url of the icon to drag-and-drop that you like: ")
u_icon = TextWindow.Read()
'u_icon = "C:\Users\Totardo\Downloads\download.jpg"
TextWindow.WriteLine("3. Enter the the x position of the icon to drag and drop (itdad_x): ")
itdad_x = TextWindow.read()
'itdad_x = 100
TextWindow.WriteLine("4. Enter the y position of the icon to drag and drop (itdad_y): ")
itdad_y = TextWindow.Read()
'itdad_y = 100
TextWindow.WriteLine("5. Enter the width of the itdad (w_itdad): ")
w_itdad = TextWindow.Read()
'w_itdad = 396
TextWindow.WriteLine("6. Enter the height of the itdad (h_itdad): ")
h_itdad = TextWindow.Read()
'h_itdad = 100
'3. Drawing background and icon and place the icon
GraphicsWindow.DrawImage(u_bground,0,0)
s_icon = Shapes.AddImage(u_icon)
Shapes.Move(s_icon,itdad_x,itdad_y)
'4. Define the event handler
GraphicsWindow.MouseDown = md
i = 0
follow_mouse = 0
'5. Define the main loop
loopz:
while follow_mouse <> 0
Shapes.Move(s_icon,GraphicsWindow.mousex,GraphicsWindow.mousey)
TextWindow.WriteLine("This is follow mouse from the main program: " + follow_mouse)
'Program.Delay(1000)
endwhile
Goto loopz
'6. Define the sub procedure md for mouse down
Sub md
'6.1 Toggle the keydown switch on and off
If keydown = 1 Then
keydown = 0
Else
keydown = 1
EndIf
'TextWindow.WriteLine("Key is: " + keydown)
'6.2 do something based on the switch on or off
If keydown = 1 Then
TextWindow.WriteLine("Its down")
'TextWindow.WriteLine("This is follow mouse: "+ follow_mouse)
'mx = Mouse.MouseX
mx = GraphicsWindow.MouseX
my = GraphicsWindow.mousey
'TextWindow.WriteLine("This is mouse x: " + mx)
'TextWindow.WriteLine("This is mouse y: " + my)
'TextWindow.WriteLine("This is total width: " + (itdad_x + w_itdad))
'TextWindow.WriteLine("This is total height: " + (itdad_y + h_itdad))
'TextWindow.WriteLine(GraphicsWindow.width/2+","+GraphicsWindow.Height/2)
'GraphicsWindow.DrawLine(itdad_x,0,itdad_x,GraphicsWindow.Height)
'GraphicsWindow.DrawLine(itdad_x+w_itdad,0,itdad_x+w_itdad, GraphicsWindow.Height)
'GraphicsWindow.DrawLine(0,itdad_y,GraphicsWindow.width,itdad_y)
'GraphicsWindow.DrawLine(0,itdad_y+h_itdad,GraphicsWindow.width,itdad_y+h_itdad)
'If mx lebih besar pojok dan lebih kecil sama dengan w_itdad
itdad_x = Shapes.GetLeft(s_icon)
itdad_y = Shapes.GetTop(s_icon)
If mx >= itdad_x And mx <= itdad_x + w_itdad Then
'TextWindow.WriteLine("Inside the width")
if my >= itdad_y And my <= (itdad_y + h_itdad) Then
'TextWindow.WriteLine("Inside the height")
'TextWindow.WriteLine("Its connect!")
If follow_mouse = 0 Then
follow_mouse = 1
EndIf
EndIf
EndIf
Else
If follow_mouse = 1 Then
follow_mouse = 0
EndIf
EndIf
'TextWindow.WriteLine("This is follow mouse on a sub: " + follow_mouse)
'Shapes.HideShape(s_icon)
'Shapes.ShowShape(s_icon)
EndSub
Tidak ada komentar:
Posting Komentar