IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

VB.NET Discussion :

convertion source vb6, je coince :-(


Sujet :

VB.NET

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre éclairé
    Profil pro
    Inscrit en
    Mars 2006
    Messages
    362
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2006
    Messages : 362
    Par défaut convertion source vb6, je coince :-(
    bonjour je cherche a convertir cette source vb6 en vb.net mais je coince.
    Il sagit d'un system de zoom dans une picturebox avec regle graduée... je souhaite m'en servir dans mon projet mais pour la convertion en vb.net je bloque sur :
    .currentX
    .currentY
    .print
    .cls

    je sais qu'il faut passer par ce genre de chose:

    Public picContainer As System.Drawing.Bitmap
    Public f As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(picContainer)

    et avec f.drawline pour tracer des traits ect.... mais quand j'essai mon resultat n'est pas fonctionnel :-(

    a l'avance , merci pour votre aide


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    Option Explicit
    Public sngZPLZoom       As Single
     
    Private Sub Form_Load()
        picZPLView.Cls
        sngZPLZoom = 6
        picZPLView.Width = (txtEtiquette(0).Text * sngZPLZoom) + &H2
        picZPLView.Height = (txtEtiquette(0).Text * sngZPLZoom) + &H6
        Call Form_Resize
      End Sub
     
    Private Sub Form_Unload(Cancel As Integer)
        Unload frmPrincipal                                     ' DECHARGMENT DE LA FENETRE.
        Set frmPrincipal = Nothing                              ' RESTAURATION DE LA MEMOIRE.
        picZPLView.Cls
    End Sub
     
    Private Sub Form_Resize()
    ' DECLARATION DES VARIABLES.
        Dim lngX        As Long
        Dim lngY        As Long
        Dim lngI        As Long
        Dim lngJ        As Long
        Dim sngI        As Single
     
    ' POSITIONNEMENT DES OBJETS.
        If frmPrincipal.WindowState <> 1 Then
            lngX = frmPrincipal.Width / Screen.TwipsPerPixelX
            lngY = frmPrincipal.Height / Screen.TwipsPerPixelY
            picContainer.Width = lngX - 8
            picContainer.Height = lngY - 105
     
            picZPLView.Left = (picContainer.Width - picZPLView.Width) / 2
            picZPLView.Top = (picContainer.Height - picZPLView.Height) / 2
     
    ' AFFICHAGE DE LA REGLE DE GRANDEUR.
            picContainer.Cls
            picContainer.Line (picZPLView.Left, 0)-(picZPLView.Left, picContainer.Height), &H666666
            picContainer.Line ((picZPLView.Left + picZPLView.Width) - 1, 0)-((picZPLView.Left + picZPLView.Width) - 1, picContainer.Height), &H666666
            picContainer.Line (&H0, picZPLView.Top)-(picContainer.Width, picZPLView.Top), &H666666
            picContainer.Line (&H0, (picZPLView.Top + picZPLView.Height) - 1)-(picContainer.Width, (picZPLView.Top + picZPLView.Height) - 1), &H666666
            lngI = 0
            For sngI = ((picZPLView.Width) / txtEtiquette(0).Text) To picZPLView.Width - 1 Step ((picZPLView.Width) / txtEtiquette(0).Text)
                lngI = lngI + 1
                If lngI < 10 Then
                    If lngI <> 5 Then
                        picContainer.Line (picZPLView.Left + sngI, picZPLView.Top - 4)-(picZPLView.Left + sngI, picZPLView.Top), &H880000
                        picContainer.Line (picZPLView.Left + sngI, (picZPLView.Top + picZPLView.Height))-(picZPLView.Left + sngI, (picZPLView.Top + picZPLView.Height) + 4), &H880000
                        Else
                            picContainer.Line (picZPLView.Left + sngI, picZPLView.Top - 8)-(picZPLView.Left + sngI, picZPLView.Top), &H880000
                            picContainer.Line (picZPLView.Left + sngI, (picZPLView.Top + picZPLView.Height))-(picZPLView.Left + sngI, (picZPLView.Top + picZPLView.Height) + 8), &H880000
                    End If
                    Else
                        lngI = 0
                        lngJ = lngJ + 10
                        picContainer.Line (picZPLView.Left + sngI, picZPLView.Top - 18)-(picZPLView.Left + sngI, picZPLView.Top), &H880000
                        picContainer.Line (picZPLView.Left + sngI, (picZPLView.Top + picZPLView.Height))-(picZPLView.Left + sngI, (picZPLView.Top + picZPLView.Height) + 18), &H880000
                        picContainer.CurrentX = ((picZPLView.Left + sngI) - (picContainer.TextWidth(lngJ) / 2)) - 4
                        picContainer.CurrentY = picZPLView.Top - 32
                        picContainer.ForeColor = 0
                        picContainer.Print lngJ
                        picContainer.CurrentX = ((picZPLView.Left + sngI) - (picContainer.TextWidth(lngJ) / 2)) - 4
                        picContainer.CurrentY = picZPLView.Top - 33
                        picContainer.ForeColor = &HFFFFFF
                        picContainer.Print lngJ
                        picContainer.CurrentX = ((picZPLView.Left + sngI) - (picContainer.TextWidth(lngJ) / &H2)) - &H4
                        picContainer.CurrentY = picZPLView.Top + picZPLView.Height + &H11
                        picContainer.ForeColor = 0
                        picContainer.Print lngJ
                        picContainer.CurrentX = ((picZPLView.Left + sngI) - (picContainer.TextWidth(lngJ) / &H2)) - &H5
                        picContainer.CurrentY = picZPLView.Top + picZPLView.Height + &H10
                        picContainer.ForeColor = &HFFFFFF
                        picContainer.Print lngJ
                End If
            Next sngI
            lngI = 0
            lngJ = 0
            For sngI = ((picZPLView.Height) / txtEtiquette(1).Text) To picZPLView.Height - &H1 Step ((picZPLView.Height) / txtEtiquette(1).Text)
                lngI = lngI + 1
                If lngI < 10 Then
                    If lngI <> 5 Then
                        picContainer.Line (picZPLView.Left - 4, picZPLView.Top + sngI)-(picZPLView.Left, picZPLView.Top + sngI), &H880000
                        picContainer.Line ((picZPLView.Left + picZPLView.Width), picZPLView.Top + sngI)-((picZPLView.Left + picZPLView.Width) + &H4, picZPLView.Top + sngI), &H880000
                        Else
                            picContainer.Line (picZPLView.Left - &H8, picZPLView.Top + sngI)-(picZPLView.Left, picZPLView.Top + sngI), &H880000
                            picContainer.Line ((picZPLView.Left + picZPLView.Width), picZPLView.Top + sngI)-((picZPLView.Left + picZPLView.Width) + &H8, picZPLView.Top + sngI), &H880000
                    End If
                    Else
                        lngI = &H0
                        lngJ = lngJ + 10
                        picContainer.Line (picZPLView.Left - 18, picZPLView.Top + sngI)-(picZPLView.Left, picZPLView.Top + sngI), &H880000
                        picContainer.Line ((picZPLView.Left + picZPLView.Width), picZPLView.Top + sngI)-((picZPLView.Left + picZPLView.Width) + 18, picZPLView.Top + sngI), &H880000
                        picContainer.CurrentX = picZPLView.Left - (picContainer.TextWidth(lngJ) + &H1A)
                        picContainer.CurrentY = ((picZPLView.Top + sngI) - (picContainer.TextHeight(lngJ) / &H2))
                        picContainer.ForeColor = &H0
                        picContainer.Print lngJ
                        picContainer.CurrentX = picZPLView.Left - (picContainer.TextWidth(lngJ) + &H1B)
                        picContainer.CurrentY = ((picZPLView.Top + sngI) - (picContainer.TextHeight(lngJ) / &H2)) - &H1
                        picContainer.ForeColor = &HFFFFFF
                        picContainer.Print lngJ
                        picContainer.CurrentX = (picZPLView.Left + picZPLView.Width) + 18
                        picContainer.CurrentY = ((picZPLView.Top + sngI) - (picContainer.TextHeight(lngJ) / &H2))
                        picContainer.ForeColor = &H0
                        picContainer.Print lngJ
                        picContainer.CurrentX = (picZPLView.Left + picZPLView.Width) + &H11
                        picContainer.CurrentY = ((picZPLView.Top + sngI) - (picContainer.TextHeight(lngJ) / &H2)) - &H1
                        picContainer.ForeColor = &HFFFFFF
                        picContainer.Print lngJ
                End If
            Next sngI
        End If
     
    End Sub
     
    Private Sub cmdAction_Click(Index As Integer)
        Select Case Index
            Case &H2:    
                            sngZPLZoom = 6.2
                            picZPLView.Cls
                            picZPLView.Width = (txtEtiquette(&H0).Text * sngZPLZoom) + &H2
                            picZPLView.Height = (txtEtiquette(&H1).Text * sngZPLZoom) + &H6
                            Call Form_Resize
            Case &H3:
                            If sngZPLZoom < 10 Then
                                sngZPLZoom = sngZPLZoom + 0.2
                                picZPLView.Cls
                                picZPLView.Width = (txtEtiquette(&H0).Text * sngZPLZoom) + &H2
                                picZPLView.Height = (txtEtiquette(&H1).Text * sngZPLZoom) + &H6
                                Call Form_Resize
                            End If
            Case &H4:
                            If sngZPLZoom > 2.4 Then
                                sngZPLZoom = sngZPLZoom - 0.2
                                picZPLView.Cls
                                picZPLView.Width = (txtEtiquette(&H0).Text * sngZPLZoom) + &H2
                                picZPLView.Height = (txtEtiquette(&H1).Text * sngZPLZoom) + &H6
                                Call Form_Resize
                            End If
        End Select
    End Sub
    Fichiers attachés Fichiers attachés

  2. #2
    Membre éclairé
    Profil pro
    Inscrit en
    Mars 2006
    Messages
    362
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2006
    Messages : 362
    Par défaut
    bon je me reponds a moi même... voici le code vb.net

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    Option Explicit On
    Public Class Form1
     
        Public sngZPLZoom As Double
     
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            picZPLView.Image = Nothing
            sngZPLZoom = 6
            picZPLView.Width = (Convert.ToDouble(txtetiquette0.Text) * sngZPLZoom) + &H2
            picZPLView.Height = (Convert.ToDouble(txtetiquette0.Text) * sngZPLZoom) + &H6
            Call Form_Resize()
     
     
     
        End Sub
     
        Private Sub Form_Resize()
            Dim lngX As Long
            Dim lngY As Long
            Dim lngI As Long
            Dim lngJ As Long
            Dim sngI As Single
            Dim x As Single
            Dim y As Single
     
     
            If Me.WindowState <> 1 Then
                lngX = Me.Width
                lngY = Me.Height
                picContainer.Width = lngX - 35
                picContainer.Height = lngY - 135
     
                Dim fond As Bitmap = New Bitmap(picContainer.Width, picContainer.Height)
                picContainer.Image = fond
                Dim ft As Font = New Font("arial", 10, FontStyle.Bold)
                Dim g As Graphics = Graphics.FromImage(picContainer.Image)
     
                picZPLView.Left = picContainer.Left + ((picContainer.Width - picZPLView.Width) / 2)
                picZPLView.Top = picContainer.Top + ((picContainer.Height - picZPLView.Height) / 2)
                picContainer.Image = Nothing
     
                g.DrawLine(Pens.DarkSeaGreen, (picZPLView.Left - picContainer.Left), 0, (picZPLView.Left - picContainer.Left), picContainer.Height)
                g.DrawLine(Pens.DarkSeaGreen, (picZPLView.Left + picZPLView.Width - picContainer.Left) - 1, 0, (picZPLView.Left + picZPLView.Width - picContainer.Left) - 1, picContainer.Height)
                g.DrawLine(Pens.DarkSeaGreen, 0, (picZPLView.Top - picContainer.Top), picContainer.Width, (picZPLView.Top - picContainer.Top))
                g.DrawLine(Pens.DarkSeaGreen, 0, (picZPLView.Top + picZPLView.Height - picContainer.Top) - 1, picContainer.Width, (picZPLView.Top + picZPLView.Height - picContainer.Top) - 1)
                lngI = 0
                For sngI = ((picZPLView.Width) / txtetiquette0.Text) To picZPLView.Width - 1 Step ((picZPLView.Width) / txtetiquette0.Text)
                    lngI = lngI + 1
                    If lngI < 10 Then
                        If lngI <> 5 Then
                            g.DrawLine(Pens.Blue, picZPLView.Left + sngI - picContainer.Left, picZPLView.Top - 4 - picContainer.Top, picZPLView.Left + sngI - picContainer.Left, picZPLView.Top - picContainer.Top)
                            g.DrawLine(Pens.Blue, picZPLView.Left + sngI - picContainer.Left, picZPLView.Top + picZPLView.Height - picContainer.Top, picZPLView.Left + sngI - picContainer.Left, (picZPLView.Top + picZPLView.Height) + 4 - picContainer.Top)
                        Else
                            g.DrawLine(Pens.Blue, picZPLView.Left + sngI - picContainer.Left, picZPLView.Top - 8 - picContainer.Top, picZPLView.Left + sngI - picContainer.Left, picZPLView.Top - picContainer.Top)
                            g.DrawLine(Pens.Blue, picZPLView.Left + sngI - picContainer.Left, picZPLView.Top + picZPLView.Height - picContainer.Top, picZPLView.Left + sngI - picContainer.Left, (picZPLView.Top + picZPLView.Height) + 8 - picContainer.Top)
                        End If
                    Else
                        lngI = 0
                        lngJ = lngJ + 10
                        g.DrawLine(Pens.Blue, picZPLView.Left + sngI - picContainer.Left, picZPLView.Top - 18 - picContainer.Top, picZPLView.Left + sngI - picContainer.Left, picZPLView.Top - picContainer.Top)
                        g.DrawLine(Pens.Blue, picZPLView.Left + sngI - picContainer.Left, picZPLView.Top + picZPLView.Height - picContainer.Top, picZPLView.Left + sngI - picContainer.Left, (picZPLView.Top + picZPLView.Height) + 18 - picContainer.Top)
                        x = ((picZPLView.Left + sngI) - ((g.MeasureString(lngJ, ft).Width) / 2)) - 4 - picContainer.Left
                        y = picZPLView.Top - 32 - picContainer.Top
                        g.DrawString(lngJ, ft, New SolidBrush(Color.White), x, y)
                        x = ((picZPLView.Left + sngI) - ((g.MeasureString(lngJ, ft).Width) / 2)) - 4 - picContainer.Left
                        y = picZPLView.Top + picZPLView.Height + &H11 - picContainer.Top
                        g.DrawString(lngJ, ft, New SolidBrush(Color.White), x, y)
                    End If
                Next sngI
                lngI = 0
                lngJ = 0
                For sngI = ((picZPLView.Height) / txtetiquette1.Text) To picZPLView.Height - &H1 Step ((picZPLView.Height) / txtetiquette1.Text)
                    lngI = lngI + 1
                    If lngI < 10 Then
                        If lngI <> 5 Then
                            g.DrawLine(Pens.Blue, picZPLView.Left - 4 - picContainer.Left, picZPLView.Top + sngI - picContainer.Top, picZPLView.Left - picContainer.Left, picZPLView.Top + sngI - picContainer.Top)
                            g.DrawLine(Pens.Blue, picZPLView.Left + picZPLView.Width - picContainer.Left, picZPLView.Top + sngI - picContainer.Top, (picZPLView.Left + picZPLView.Width) + &H4 - picContainer.Left, picZPLView.Top + sngI - picContainer.Top)
                        Else
                            g.DrawLine(Pens.Blue, picZPLView.Left - &H8 - picContainer.Left, picZPLView.Top + sngI - picContainer.Top, picZPLView.Left - picContainer.Left, picZPLView.Top + sngI - picContainer.Top)
                            g.DrawLine(Pens.Blue, picZPLView.Left + picZPLView.Width - picContainer.Left, picZPLView.Top + sngI - picContainer.Top, (picZPLView.Left + picZPLView.Width) + &H8 - picContainer.Left, picZPLView.Top + sngI - picContainer.Top)
                        End If
                    Else
                        lngI = &H0
                        lngJ = lngJ + 10
                        g.DrawLine(Pens.Blue, picZPLView.Left - 18 - picContainer.Left, picZPLView.Top + sngI - picContainer.Top, picZPLView.Left - picContainer.Left, picZPLView.Top + sngI - picContainer.Top)
                        g.DrawLine(Pens.Blue, picZPLView.Left + picZPLView.Width - picContainer.Left, picZPLView.Top + sngI - picContainer.Top, (picZPLView.Left + picZPLView.Width) + 18 - picContainer.Left, picZPLView.Top + sngI - picContainer.Top)
                        x = picZPLView.Left - (g.MeasureString(lngJ, ft).Width) + &H1A - picContainer.Left - 42
                        y = ((picZPLView.Top + sngI) - ((g.MeasureString(lngJ, ft).Width)) / &H2) - picContainer.Top
                        g.DrawString(lngJ, ft, New SolidBrush(Color.White), x, y)
                        x = (picZPLView.Left + picZPLView.Width) + 18 - picContainer.Left
                        y = ((picZPLView.Top + sngI) - ((g.MeasureString(lngJ, ft).Width)) / &H2) - picContainer.Top
                        g.DrawString(lngJ, ft, New SolidBrush(Color.White), x, y)
     
                    End If
                Next
                picContainer.Image = fond
            End If
        End Sub
     
        Private Sub cmdAction1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdAction1.Click
            sngZPLZoom = 6.2
            picZPLView.Image = Nothing
            picZPLView.Width = (txtetiquette0.Text * sngZPLZoom) + &H2
            picZPLView.Height = (txtetiquette1.Text * sngZPLZoom) + &H6
            Call Form_Resize()
        End Sub
     
        Private Sub cmdAction2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdAction2.Click
            If sngZPLZoom < 10 Then
                sngZPLZoom = sngZPLZoom + 0.2
                picZPLView.Image = Nothing
                picZPLView.Width = (txtetiquette0.Text * sngZPLZoom) + &H2
                picZPLView.Height = (txtetiquette1.Text * sngZPLZoom) + &H6
                Call Form_Resize()
            End If
        End Sub
     
        Private Sub cmdAction3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdAction3.Click
            If sngZPLZoom > 2.4 Then
                sngZPLZoom = sngZPLZoom - 0.2
                picZPLView.Image = Nothing
                picZPLView.Width = (txtetiquette0.Text * sngZPLZoom) + &H2
                picZPLView.Height = (txtetiquette1.Text * sngZPLZoom) + &H6
                Call Form_Resize()
            End If
        End Sub
     
        Private Sub txtetiquette0_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtetiquette0.TextChanged
            If txtetiquette0.Text > 110 Then
                txtetiquette0.Text = 110
            End If
        End Sub
    End Class
    Cependant j'ai une question, dans l'exemple j'ulilise une picturebox (piccontainer) comme contenant pour une autre picturebox (picZPLview)
    Hors quand cette derniere est plus grande que piccontainer, elle dépasse... est vient cacher les boutons :-(
    comment faire pour qu'elle soit contenu dans piccontainer? comment ajouter des scroolbar?

    merci

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 3
    Dernier message: 04/11/2014, 17h37
  2. code source vb6
    Par marwa 18 dans le forum VB 6 et antérieur
    Réponses: 3
    Dernier message: 29/03/2010, 10h09
  3. taille du code source vb6
    Par NAIMA2 dans le forum VB 6 et antérieur
    Réponses: 8
    Dernier message: 21/03/2007, 13h58
  4. [VB6] Code source pour modifier MsgBox
    Par khany dans le forum VB 6 et antérieur
    Réponses: 5
    Dernier message: 25/02/2003, 15h13

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo