Click here to Skip to main content
15,886,761 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
GeneralDocking custom controls Pin
Rhy Mednick26-May-04 13:25
Rhy Mednick26-May-04 13:25 
GeneralRe: Docking custom controls Pin
Aaron Eldreth27-May-04 11:31
Aaron Eldreth27-May-04 11:31 
GeneralLooking for an elegant ".NET Framework" Framework Pin
jafet_san26-May-04 9:59
jafet_san26-May-04 9:59 
GeneralRe: Looking for an elegant ".NET Framework" Framework Pin
TigerNinja_26-May-04 11:47
TigerNinja_26-May-04 11:47 
GeneralRe: Looking for an elegant ".NET Framework" Framework Pin
Steven Campbell28-May-04 18:04
Steven Campbell28-May-04 18:04 
GeneralRe: Looking for an elegant ".NET Framework" Framework Pin
Carl Mercier31-May-04 6:52
Carl Mercier31-May-04 6:52 
GeneralA simple question about PictureBox Pin
Member 94012526-May-04 3:23
Member 94012526-May-04 3:23 
GeneralRe: A simple question about PictureBox Pin
Aaron Eldreth27-May-04 11:22
Aaron Eldreth27-May-04 11:22 
VB
<br />
' This is where on the item the user clicked the mouse.<br />
    Dim Xstart As Integer<br />
    Dim Ystart As Integer<br />
    ' This is whether or not the user has the mouse down on<br />
    ' The items<br />
    Dim movin As Boolean<br />
    ' This controls if the panel moves in increments or<br />
    ' straight 1x1 pixels<br />
    Const Increment As Integer = 10<br />
    Const TrueMotion As Boolean = False<br />
    ' MOE (Margin Of Error) is the number of pixels the user<br />
    ' Can be off for a event to trigger (check the OnMouseUp event)<br />
    Const MOE As Integer = 5<br />
    Private Sub Panel_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles pnlMain.MouseMove<br />
        If movin Then<br />
            ' This gets what panel the event fired for<br />
            ' (So you can use the AddHandler function)<br />
            Dim ThisPanel As Panel = CType(sender, Panel)<br />
            Dim moveX As Integer<br />
            Dim moveY As Integer<br />
            If TrueMotion Then<br />
                moveX = Me.MousePosition.X - Xstart<br />
                moveY = Me.MousePosition.Y - Ystart<br />
            Else<br />
                ' This rounds the position to the nearest<br />
                ' multiple of Increment.<br />
                ' It works fine, just is complicated<br />
                moveX = Me.MousePosition.X - Xstart - ((Me.MousePosition.X - Xstart) Mod Increment)<br />
                moveY = Me.MousePosition.Y - Ystart - ((Me.MousePosition.Y - Ystart) Mod Increment)<br />
            End If<br />
            ThisPanel.Top = moveY<br />
            ThisPanel.Left = moveX<br />
            ' pnlWhite is above pnlMain, and pnlBlack is <br />
            ' INSIDE pnlWhite, so pnlBlack makes it look like<br />
            ' pnlMain is changing colors to black.<br />
            pnlBlack.Left = ThisPanel.Left - pnlWhite.Left<br />
            pnlBlack.Top = ThisPanel.Top - pnlWhite.Top<br />
            ' If ThisPanel is close enough to pnlWhite<br />
            ' (with MOE), show the close label.<br />
            If ThisPanel.Top + MOE >= pnlWhite.Top And ThisPanel.Top - MOE <= pnlWhite.Top And ThisPanel.Left + MOE >= pnlWhite.Left And ThisPanel.Left - MOE <= pnlWhite.Left Then<br />
                Label1.Visible = True<br />
            Else<br />
                Label1.Visible = False<br />
            End If<br />
        End If<br />
    End Sub<br />
<br />
    Private Sub Panel_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles pnlMain.MouseDown<br />
        ' Start movin'<br />
        movin = True<br />
        Dim ThisPanel As Panel = CType(sender, Panel)<br />
        ThisPanel.BorderStyle = BorderStyle.FixedSingle<br />
        Xstart = Me.MousePosition.X - ThisPanel.Left<br />
        Ystart = Me.MousePosition.Y - ThisPanel.Top<br />
    End Sub<br />
<br />
    Private Sub Panel_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles pnlMain.MouseUp<br />
        movin = False<br />
        Dim ThisPanel As Panel = CType(sender, Panel)<br />
        ThisPanel.BorderStyle = BorderStyle.None<br />
        ' Pretty much, if the close label is shown, quit.<br />
        If ThisPanel.Top + MOE >= pnlWhite.Top And ThisPanel.Top - MOE <= pnlWhite.Top And ThisPanel.Left + MOE >= pnlWhite.Left And ThisPanel.Left - MOE <= pnlWhite.Left Then<br />
            Me.Close()<br />
        End If<br />
    End Sub<br />
<br />
    Private Sub btnNewPanel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNewPanel.Click<br />
        ' This makes the new panel.<br />
        Dim Newpanel As System.Windows.Forms.Panel<br />
        Newpanel = New System.Windows.Forms.Panel()<br />
        Newpanel.Location = New System.Drawing.Point(50, 50)<br />
        Newpanel.BackColor = System.Drawing.Color.FromArgb(255, 192, 192)<br />
        Newpanel.Size = New System.Drawing.Size(40, 40)<br />
        Me.Controls.Add(Newpanel)<br />
        ' And this gives it the events it needs.<br />
        AddHandler Newpanel.MouseUp, AddressOf Panel_MouseUp<br />
        AddHandler Newpanel.MouseDown, AddressOf Panel_MouseDown<br />
        AddHandler Newpanel.MouseMove, AddressOf Panel_MouseMove<br />
    End Sub<br />


Aaron Eldreth
TheCollective4.com
My Articles

While much is too strange to be believed,
Nothing is too strange to have happened.
- T. Hardy
GeneralRe: A simple question about PictureBox Pin
Member 94012527-May-04 16:51
Member 94012527-May-04 16:51 
GeneralA Question about Updating Components Pin
yyj_ljz25-May-04 20:25
yyj_ljz25-May-04 20:25 
GeneralA question about Remoting Pin
yyj_ljz25-May-04 15:50
yyj_ljz25-May-04 15:50 
GeneralRe: A question about Remoting Pin
Aryadip25-May-04 19:47
Aryadip25-May-04 19:47 
GeneralRe: A question about Remoting Pin
yyj_ljz25-May-04 20:31
yyj_ljz25-May-04 20:31 
GeneralRe: A question about Remoting Pin
normanordas1-Jun-04 1:02
normanordas1-Jun-04 1:02 
GeneralProject Read only. Pin
Anonymous25-May-04 9:33
Anonymous25-May-04 9:33 
GeneralRe: Project Read only. Pin
Aryadip25-May-04 19:41
Aryadip25-May-04 19:41 
GeneralA question about PictureBox Pin
24-May-04 23:52
suss24-May-04 23:52 
GeneralRe: A question about PictureBox Pin
Aaron Eldreth27-May-04 11:13
Aaron Eldreth27-May-04 11:13 
QuestionIs it possible to make a setup .exe with .NET installer? Pin
adonisv24-May-04 14:01
adonisv24-May-04 14:01 
AnswerRe: Is it possible to make a setup .exe with .NET installer? Pin
normanordas1-Jun-04 0:53
normanordas1-Jun-04 0:53 
GeneralRe: Is it possible to make a setup .exe with .NET installer? Pin
Ashraf Fathy1-Jun-04 2:26
Ashraf Fathy1-Jun-04 2:26 
GeneralCheck this out! Pin
adonisv1-Jun-04 9:27
adonisv1-Jun-04 9:27 
GeneralSetting Environment Variables... Pin
waffleman24-May-04 8:59
waffleman24-May-04 8:59 
GeneralRe: Setting Environment Variables... Pin
deeps2624-May-04 19:08
deeps2624-May-04 19:08 
GeneralHTMLDocument and scripts Pin
Aggtaa24-May-04 4:10
Aggtaa24-May-04 4:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.