Thursday, January 13, 2011

Thursday, 1/13/11


Public Class Form1
'This has been slightly adapted by me From Visual Basic Cookbook 2005
Dim WithEvents DragBar As New PictureBox
Const HT_Caption As Integer = &H2
Const WM_NCLBUTTONDOWN As Integer = &HA1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.FormBorderStyle = 0
DragBar.BackColor = Color.Blue
DragBar.Location = New Point(50, 50)
DragBar.Width = (Me.Width * 0.9)

Me.Controls.Add(DragBar)
End Sub

Private Sub DragBar_MouseDown(ByVal sender As Object, _
ByVal e As System.Windows.Forms.MouseEventArgs) _
Handles DragBar.MouseDown
If (e.Button = Windows.Forms.MouseButtons.Left) Then
'---- Don't hold on to the mouse locally
DragBar.Capture = False

'----Trick the form into thinking it received a title click
Me.WndProc(Message.Create(Me.Handle, WM_NCLBUTTONDOWN, _
CType(HT_Caption, IntPtr), IntPtr.Zero))
'All of the activity within a Windows form happens through messages being processed through a Windows procedure, or WndProc. This method is as old as windows
End If
End Sub
End Class


Here is a javascript tutorial it took my a while to work on:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<style type="text/css" media = "screen">


</style>
<script type="text/javaScript" charset="utf-8">
function Square( side, color ){
this.side = side;
this.color = color;
}


</script>
</head>
<body>
<script type="text/javaScript" charset="utf-8">
var sq01 = new Square(140, "Green");
document.writeln( sq01.color );
document.writeln( '<div style="background-color: blue; height:50px; width:50px;"></div>' );
document.writeln( '<BR>');
document.writeln( '<div style="background-color: ' + sq01.color + '; height: 60px; width: 60px;"></div>' );
document.writeln( '<br>');
document.writeln( '<div style="background-color: ' + sq01.color + '; height: ' + sq01.side + 'px; width: ' + sq01.side + 'px; "></div>' );
</script>
</body>
</html>

1 comment:

Brad Jensen said...

It took me a minute to understand what was happening in the javascipt example here.

It seems strange that you can create new properties for a jscript object by just setting 'this.xxx' with no declaration of the property. It means you have to read the code with a very sharp eye to find the properties, which will make it harder to understand or debug.

In this example the object is used like a structure or typed variable, it doesn't really 'do' anything.