Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

Bug VB6

6 réponses
Avatar
Gilles RONSIN
Bonjour,

je pose juste la question au cas où quelqu'un y a déjà été confronté
et a une solution :

Je suis en cours de développement d'un programme d'analyse de signaux
et pour des questions de facilité j'utilise VB6SP5 pour ses facilités
graphiques, hors dès que je fait une modification mineure du source
(modification d'une constante, d'un calcul) l'exécution suivante
échoue pour des problèmes de syntaxe des lignes contenant la méthode
".line" par le compilateur !!! Bien évidemment la syntaxe est
correcte, si je sauve, quitte vb et relance, tout fonctionne
normalement jusqu'à la prochaine modification !!! mais à chaque fois
ça m'oblige à refaire une acquisition...question ergonomie et
efficacité il y a mieux.

Merci pour vos réponses

--
Embryon de site : http://gilles.ronsin.free.fr
Nouvelles astuces : Interprêtation des évenements XP et intégration
ICQ dans Opera
Les gens qui ne rient jamais, ne sont pas des gens sérieux.

6 réponses

Avatar
JeanP
bonjour,
j'ai eu le même problème et je devais quitter le programme et le
relancer.(mais l'erreur était aléatoire, pas à chaque modif).
Depuis j'évite, si c'est possible, le .line
bon boulot.
Jean
"Gilles RONSIN" a écrit dans le message de news:

Bonjour,

je pose juste la question au cas où quelqu'un y a déjà été confronté
et a une solution :

Je suis en cours de développement d'un programme d'analyse de signaux
et pour des questions de facilité j'utilise VB6SP5 pour ses facilités
graphiques, hors dès que je fait une modification mineure du source
(modification d'une constante, d'un calcul) l'exécution suivante
échoue pour des problèmes de syntaxe des lignes contenant la méthode
".line" par le compilateur !!! Bien évidemment la syntaxe est
correcte, si je sauve, quitte vb et relance, tout fonctionne
normalement jusqu'à la prochaine modification !!! mais à chaque fois
ça m'oblige à refaire une acquisition...question ergonomie et
efficacité il y a mieux.

Merci pour vos réponses

--
Embryon de site : http://gilles.ronsin.free.fr
Nouvelles astuces : Interprêtation des évenements XP et intégration
ICQ dans Opera
Les gens qui ne rient jamais, ne sont pas des gens sérieux.


Avatar
Gilles RONSIN
"JeanP" , le jeu. 08 avr. 2004
14:11:32, écrivait ceci:

bonjour,


salut,

j'ai eu le même problème et je devais quitter le programme et le
relancer.(mais l'erreur était aléatoire, pas à chaque modif).
Depuis j'évite, si c'est possible, le .line
bon boulot.



Hélàs je visualise les mesures sous forme graphique, je ne peux pas
m'en passer.
merci pour ton témoignage... je me sens moins seul ;-)

--
Embryon de site : http://gilles.ronsin.free.fr
Nouvelles astuces : Interprêtation des évenements XP et intégration ICQ
dans Opera
Les gens qui ne rient jamais, ne sont pas des gens sérieux.
Avatar
François Picalausa
Hello,

Tu peux toujours le faire par API.
Voici un exemple:
Option Explicit

Private Type POINTAPI
x As Long
y As Long
End Type

Private Declare Function LineTo _
Lib "gdi32" _
( _
ByVal hdc As Long, _
ByVal x As Long, _
ByVal y As Long _
) _
As Long
Private Declare Function Polyline _
Lib "gdi32" _
( _
ByVal hdc As Long, _
lpPoint As POINTAPI, _
ByVal nCount As Long _
) _
As Long
Private Declare Function MoveToEx _
Lib "gdi32" _
( _
ByVal hdc As Long, _
ByVal x As Long, _
ByVal y As Long, _
lpPoint As Any _
) _
As Long
Private Declare Function Rectangle _
Lib "gdi32" ( _
ByVal hdc As Long, _
ByVal X1 As Long, _
ByVal Y1 As Long, _
ByVal X2 As Long, _
ByVal Y2 As Long _
) _
As Long

Private Sub Form_Load()
Me.AutoRedraw = True

'Trace une ligne simple de 50,50 à 100,100
MoveToEx Me.hdc, 50, 50, ByVal 0&
LineTo Me.hdc, 100, 100

'Trace une série de lignes
Dim tblPoints(3) As POINTAPI

tblPoints(0).x = 0
tblPoints(0).y = 0

tblPoints(1).x = 50
tblPoints(1).y = 50

tblPoints(2).x = 100
tblPoints(2).y = 0

tblPoints(3).x = 150
tblPoints(3).y = 50

Polyline Me.hdc, tblPoints(0), 4

'Trace un rectangle de 100,100 à 150, 150
Rectangle Me.hdc, 100, 100, 150, 150

Me.Refresh
End Sub

--
François Picalausa (MVP VB)
http://faq.vb.free.fr --- http://msdn.microsoft.com
http://apisvb.europe.webmatrixhosting.net

"Gilles RONSIN" a écrit dans le message de
news:
"JeanP" , le jeu. 08 avr. 2004
14:11:32, écrivait ceci:
Depuis j'évite, si c'est possible, le .line


Hélàs je visualise les mesures sous forme graphique, je ne peux pas
m'en passer.


Avatar
Gilles RONSIN
"François Picalausa" , le jeu. 08 avr. 2004
14:43:50, écrivait ceci:

Hello,



Salut François (et bon anniversaire en retard)

Tu peux toujours le faire par API.
Voici un exemple:



Merci pour ces lignes, elles respectent le picture.scale ?


--
Embryon de site : http://gilles.ronsin.free.fr
Nouvelles astuces : Interprêtation des évenements XP et intégration ICQ
dans Opera
Les gens qui ne rient jamais, ne sont pas des gens sérieux.
Avatar
François Picalausa
Hello,

Voici un exemple de code qui permet de le respecter (cet exemple a été fait
pour un système d'axes centrés à l'origine)
(placer 6 command buttons sur une form):
Option Explicit

Private Const MM_TEXT = 1
Private Const MM_LOMETRIC = 2 'Each logical unit is mapped to 0.1
millimeter.
'Positive x is to the right; positive y is
up.
Private Const MM_HIMETRIC = 3
Private Const MM_LOENGLISH = 4
Private Const MM_HIENGLISH = 5
Private Const MM_TWIPS = 6
Private Const MM_ISOTROPIC = 7
Private Const MM_ANISOTROPIC = 8
Private Const MM_MIN = MM_TEXT
Private Const MM_MAX = MM_ANISOTROPIC
Private Const MM_MAX_FIXEDSCALE = MM_TWIPS

Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type

Private Type SIZE
cx As Long
cy As Long
End Type

Private Type POINTAPI
x As Long
y As Long
End Type

Private Declare Function GetClientRect _
Lib "user32" _
( _
ByVal hwnd As Long, _
lpRect As RECT _
) _
As Long

Private Declare Function SetMapMode _
Lib "gdi32" _
( _
ByVal hdc As Long, _
ByVal fnMapMode As Long _
) _
As Long

Private Declare Function SetViewportExtEx _
Lib "gdi32" _
( _
ByVal hdc As Long, _
ByVal nXExtent As Long, _
ByVal nYExtent As Long, _
lpSize As Any _
) _
As Long

Private Declare Function SetWindowExtEx _
Lib "gdi32" _
( _
ByVal hdc As Long, _
ByVal nXExtent As Long, _
ByVal nYExtent As Long, _
lpSize As Any _
) _
As Long

Private Declare Function SetViewportOrgEx _
Lib "gdi32" _
( _
ByVal hdc As Long, _
ByVal x As Long, _
ByVal y As Long, _
lpPoint As Any _
) _
As Long

Private Declare Function SetWindowOrgEx _
Lib "gdi32" _
( _
ByVal hdc As Long, _
ByVal x As Long, _
ByVal y As Long, _
lpPoint As Any _
) _
As Long

Private Declare Function LineTo _
Lib "gdi32" _
( _
ByVal hdc As Long, _
ByVal x As Long, _
ByVal y As Long _
) _
As Long
Private Declare Function Polyline _
Lib "gdi32" _
( _
ByVal hdc As Long, _
lpPoint As POINTAPI, _
ByVal nCount As Long _
) _
As Long
Private Declare Function MoveToEx _
Lib "gdi32" _
( _
ByVal hdc As Long, _
ByVal x As Long, _
ByVal y As Long, _
lpPoint As Any _
) _
As Long
Private Declare Function Rectangle _
Lib "gdi32" ( _
ByVal hdc As Long, _
ByVal X1 As Long, _
ByVal Y1 As Long, _
ByVal X2 As Long, _
ByVal Y2 As Long _
) _
As Long

Private Sub Command1_Click()
Me.AutoRedraw = True
Me.Cls

Dim OldMode As Long

OldMode = SetMapMode(Me.hdc, MM_LOMETRIC)

Draw 1, -1

SetMapMode Me.hdc, OldMode

Me.Refresh
End Sub

Private Sub Command2_Click()
Me.AutoRedraw = True
Me.Cls

Dim OldMode As Long

OldMode = SetMapMode(Me.hdc, MM_TWIPS)

Draw Screen.TwipsPerPixelX, -Screen.TwipsPerPixelY

SetMapMode Me.hdc, OldMode

Me.Refresh
End Sub

Private Sub Command3_Click()
Me.AutoRedraw = True
Me.Cls

Dim OldMode As Long

OldMode = SetMapMode(Me.hdc, MM_TEXT)

Draw 1, 1

SetMapMode Me.hdc, OldMode

Me.Refresh
End Sub

Private Sub Command4_Click()
Me.AutoRedraw = True
Me.Cls

Me.ScaleWidth = 300
Me.ScaleHeight = 300

Dim OldMode As Long, OldVPSize As SIZE, ClientRECT As RECT
Dim OldWinSize As SIZE

GetClientRect Me.hwnd, ClientRECT
OldMode = SetMapMode(Me.hdc, MM_ANISOTROPIC)
SetWindowExtEx Me.hdc, Me.ScaleWidth, Me.ScaleHeight, OldWinSize
SetViewportExtEx Me.hdc, ClientRECT.Right, ClientRECT.Bottom, OldVPSize

Draw 1, 1

SetWindowExtEx Me.hdc, OldWinSize.cx, OldWinSize.cy, ByVal 0&
SetViewportExtEx Me.hdc, OldVPSize.cx, OldVPSize.cy, ByVal 0&
SetMapMode Me.hdc, OldMode

Me.Refresh
End Sub

Private Sub Draw(FactorX As Single, FactorY As Single)
'Trace une ligne simple de 50,50 à 100,100
MoveToEx Me.hdc, 50 * FactorX, 50 * FactorY, ByVal 0&
LineTo Me.hdc, 100 * FactorX, 100 * FactorY

'Trace une série de lignes
Dim tblPoints(3) As POINTAPI

tblPoints(0).x = 0
tblPoints(0).y = 0

tblPoints(1).x = 50 * FactorX
tblPoints(1).y = 50 * FactorY

tblPoints(2).x = 100 * FactorX
tblPoints(2).y = 0

tblPoints(3).x = 150 * FactorX
tblPoints(3).y = 50 * FactorY

Polyline Me.hdc, tblPoints(0), 4

'Trace un rectangle de 100,100 à 150, 150
Rectangle Me.hdc, 100 * FactorX, 100 * FactorY, 150 * FactorX, 150 *
FactorY
End Sub

Private Sub DrawVB(FactorX As Single, FactorY As Single)
'Trace une ligne simple de 50,50 à 100,100
Me.Line (50 * FactorX, 50 * FactorY)-(100 * FactorX, 100 * FactorY)

'Trace une série de lignes
Dim tblPoints(3) As POINTAPI

Me.Line (0 * FactorX, 0 * FactorY)-(50 * FactorX, 50 * FactorY)
Me.Line (50 * FactorX, 50 * FactorY)-(100 * FactorX, 0 * FactorY)
Me.Line (100 * FactorX, 0 * FactorY)-(150 * FactorX, 50 * FactorY)

'Trace un rectangle de 100,100 à 150, 150
Me.Line (100 * FactorX, 100 * FactorY)-(150 * FactorX, 150 * FactorY),
0, B
End Sub

Private Sub Command5_Click()
Me.Cls
Me.ScaleMode = 3
DrawVB 1, 1
End Sub

Private Sub Command6_Click()
Me.Cls
Me.ScaleWidth = 300
Me.ScaleHeight = 300
DrawVB 1, 1
End Sub

----------------------------------------------------------------------------
-
Ca, c'est si tu veux jouer directement avec GDI pour changer de système.
Une autre possibilité est d'utiliser VB pour effectuer des convertion:
Debug.Print Me.ScaleX(50, vbTwips, vbPixels)
Debug.Print Me.ScaleY(50, vbUser, vbPixels)
et ensuite, utiliser ces mesure en pixels avec GDI

--
François Picalausa (MVP VB)
http://faq.vb.free.fr --- http://msdn.microsoft.com
http://apisvb.europe.webmatrixhosting.net

"Gilles RONSIN" a écrit dans le message de
news:
"François Picalausa" , le jeu. 08 avr. 2004
14:43:50, écrivait ceci:

Hello,



Salut François (et bon anniversaire en retard)

Tu peux toujours le faire par API.
Voici un exemple:



Merci pour ces lignes, elles respectent le picture.scale ?


Avatar
Gilles RONSIN
"François Picalausa" , le jeu. 08 avr. 2004
17:21:57, écrivait ceci:

Hello,



Encore merci pour ta réponse plus que complète (on dirait du Bellamy :-))
J'ai tout ce qu'il me faut et même plus pour les app suivantes

A bientôt


--
Embryon de site : http://gilles.ronsin.free.fr
Nouvelles astuces : Interprêtation des évenements XP et intégration ICQ
dans Opera
Les gens qui ne rient jamais, ne sont pas des gens sérieux.