Click here to Skip to main content
15,846,211 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: How to refresh design area Pin
Ralf Meier16-Dec-17 23:19
professionalRalf Meier16-Dec-17 23:19 
AnswerRe: How to refresh design area Pin
Ralf Meier17-Dec-17 0:45
professionalRalf Meier17-Dec-17 0:45 
GeneralRe: How to refresh design area Pin
mo149217-Dec-17 5:51
mo149217-Dec-17 5:51 
PraiseRe: How to refresh design area Pin
mo149217-Dec-17 12:59
mo149217-Dec-17 12:59 
GeneralRe: How to refresh design area Pin
Ralf Meier17-Dec-17 21:44
professionalRalf Meier17-Dec-17 21:44 
AnswerRe: How to refresh design area Pin
Ralf Meier14-Dec-17 2:46
professionalRalf Meier14-Dec-17 2:46 
QuestionParentControlDesigner: How to receive message from child in design mode Pin
mo14925-Dec-17 3:38
mo14925-Dec-17 3:38 
AnswerRe: ParentControlDesigner: How to receive message from child in design mode Pin
Ralf Meier8-Dec-17 2:02
professionalRalf Meier8-Dec-17 2:02 
Each ControlDesigner has several methods to pass the Mouse-Functionality to the Control in DesignTime the same way like in RunTime-mode.
For your requirement I would suggest you use/override the Methods OnMouseDragBegin, OnMouseDragMove and OnMouseDragEnd from the Designer.
With this methods you could modify properties from the HostControl.

VB
Public Class myControlDesigner
     Inherits System.Windows.Forms.Design.ControlDesigner

     Private HostControl As RMWertAnzeigeValue2 = Nothing

     Public Overrides Sub Initialize(ByVal component As System.ComponentModel.IComponent)
         MyBase.Initialize(component)

         HostControl = DirectCast(component, RMWertAnzeigeValue2)
     End Sub


     ' schaltet im Design-Modus die Maus-Cursor-Darstellung um
     Protected Overrides Sub OnSetCursor()
         Dim myPoint As Point = HostControl.PointToClient(Cursor.Position)

         If inShiftPosition(myPoint) > 0 Then
             If Dragging_Aktiv Then
                 Cursor.Current = Cursors.Arrow
             Else
                 Cursor.Current = Cursors.SizeWE
             End If
         Else
             MyBase.OnSetCursor()
         End If
     End Sub

     ''' <summary>
     ''' gibt den Übergang an dem sich die Maus aktuell befindet zurück
     ''' 0 = kein Übergang
     ''' 1 = Übergang zwischen Beschreibung und Wert
     ''' 2 = Übergang zwischen Wert und Einheit
     ''' </summary>
     ''' <param name="p"></param>
     ''' <returns></returns>
     ''' <remarks></remarks>
     Private Function inShiftPosition(ByVal p As Point) As Integer

         If HostControl IsNot Nothing AndAlso HostControl.Activated Then
             If (p.X >= HostControl.SpaltenTrenner.Pos1 - Dragging_ShiftHysterese) AndAlso (p.X <= HostControl.SpaltenTrenner.Pos1 + Dragging_ShiftHysterese) Then
                 Return 1
             ElseIf (p.X >= HostControl.SpaltenTrenner.Pos2 - Dragging_ShiftHysterese) AndAlso (p.X <= HostControl.SpaltenTrenner.Pos2 + Dragging_ShiftHysterese) Then
                 Return 2
             Else
                 Return 0
             End If
         Else
             Return 0
         End If

     End Function

     Private Dragging_ShiftHysterese As Integer = 3
     Private Dragging_Aktiv As Boolean = False
     Private Dragging_ShiftPoint As Integer = 0
     Private Dragging_Offset As Integer = 0


     ' ggf. Start der Verschiebung der Elemente im Control
     Protected Overrides Sub OnMouseDragBegin(ByVal x As Integer, ByVal y As Integer)
         If HostControl Is Nothing Then Exit Sub
         Dim myPoint As Point = HostControl.PointToClient(New Point(x, y))
         Dragging_ShiftPoint = inShiftPosition(myPoint)

         If Dragging_ShiftPoint = 1 Then
             Dragging_Offset = HostControl.SpaltenTrenner.Pos1 - myPoint.X
             Dragging_Aktiv = True
         ElseIf Dragging_ShiftPoint = 2 Then
             Dragging_Offset = HostControl.SpaltenTrenner.Pos2 - myPoint.X
             Dragging_Aktiv = True
         Else
             MyBase.OnMouseDragBegin(x, y)
         End If
     End Sub

     ' wenn Dragging aktiv ist dann können die Übergänge verschoben werden
     Protected Overrides Sub OnMouseDragMove(ByVal x As Integer, ByVal y As Integer)
         If HostControl Is Nothing Then Exit Sub
         Dim myPoint As Point = HostControl.PointToClient(New Point(x, y))

         If Dragging_Aktiv Then
             If Dragging_ShiftPoint = 1 Then
                 HostControl.SpaltenTrenner.Pos1 = myPoint.X + Dragging_Offset
             ElseIf Dragging_ShiftPoint = 2 Then
                 HostControl.SpaltenTrenner.Pos2 = myPoint.X + Dragging_Offset
             End If
         Else
             MyBase.OnMouseDragMove(x, y)
         End If
     End Sub

     ' Dragging beendet
     Protected Overrides Sub OnMouseDragEnd(ByVal cancel As Boolean)
         Dragging_Aktiv = False

         MyBase.OnMouseDragEnd(cancel)
     End Sub

 End Class


In this code SpaltenTrenner is a class-property which is equal to your requirement - sorry that some comments are in german.
I think, it could help you to see what should be done.
RMWertAnzeigeValue2 is the type a my Control which consists of 3 sections.
GeneralRe: ParentControlDesigner: How to receive message from child in design mode Pin
mo14929-Dec-17 12:25
mo14929-Dec-17 12:25 
GeneralRe: ParentControlDesigner: How to receive message from child in design mode Pin
Ralf Meier10-Dec-17 4:09
professionalRalf Meier10-Dec-17 4:09 
QuestionDATA CAPTURE - WEB PAGE VB.NET Pin
Member 1352492016-Nov-17 4:05
Member 1352492016-Nov-17 4:05 
AnswerRe: DATA CAPTURE - WEB PAGE VB.NET Pin
Richard MacCutchan16-Nov-17 4:16
mveRichard MacCutchan16-Nov-17 4:16 
QuestionMIDI and USB Keyboard! Pin
User 989707412-Nov-17 5:25
User 989707412-Nov-17 5:25 
AnswerRe: MIDI and USB Keyboard! Pin
Richard MacCutchan12-Nov-17 7:29
mveRichard MacCutchan12-Nov-17 7:29 
GeneralRe: MIDI and USB Keyboard! Pin
User 989707412-Nov-17 8:45
User 989707412-Nov-17 8:45 
GeneralRe: MIDI and USB Keyboard! Pin
Sascha Lefèvre12-Nov-17 9:32
professionalSascha Lefèvre12-Nov-17 9:32 
GeneralRe: MIDI and USB Keyboard! Pin
User 989707412-Nov-17 9:34
User 989707412-Nov-17 9:34 
GeneralRe: MIDI and USB Keyboard! Pin
Sascha Lefèvre12-Nov-17 9:50
professionalSascha Lefèvre12-Nov-17 9:50 
GeneralRe: MIDI and USB Keyboard! Pin
User 989707412-Nov-17 9:56
User 989707412-Nov-17 9:56 
GeneralRe: MIDI and USB Keyboard! Pin
Sascha Lefèvre12-Nov-17 10:16
professionalSascha Lefèvre12-Nov-17 10:16 
GeneralRe: MIDI and USB Keyboard! Pin
User 989707413-Nov-17 0:36
User 989707413-Nov-17 0:36 
GeneralRe: MIDI and USB Keyboard! Pin
User 989707413-Nov-17 10:00
User 989707413-Nov-17 10:00 
GeneralRe: MIDI and USB Keyboard! Pin
User 989707429-Nov-17 5:16
User 989707429-Nov-17 5:16 
GeneralRe: MIDI and USB Keyboard! Pin
Sascha Lefèvre30-Nov-17 0:34
professionalSascha Lefèvre30-Nov-17 0:34 
GeneralRe: MIDI and USB Keyboard! Pin
User 989707430-Nov-17 1:10
User 989707430-Nov-17 1: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.