Bonjour,

J'ai voulu rajouter un slider associer à une Edit box mais j'obtiens 2 erreurs et 6 warnings......il me semble que j'ai pas mal d'erreur et warnings de conversion, comment les éviter...... j'utilise des float,CString.

Edit Box -->IDC_SLIDER_VALUE --> m_SliderValue
Slider --> IDC_Slider --> m_slider



Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
Mes warnings:'=' : truncation from 'const double' to 'float
                    'initializing' : truncation from 'const double' to 'float'
                   '=' : conversion from 'double' to 'float', possible loss of data ]
Mes erreurs: [ error C2677: binary '*' : no global operator defined which takes type 'class CString' (or there is no acceptable conversion)

Mon code:

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
void CSimul_AngleDlg::OnCalcul() 
{
UpdateData(TRUE);
//Déclaration des constantes
float PI=3.141592654;
float cos45= 0.7071067812;
 
//Calcul des coefficient de la droite
float a,b,Force_directe,Force_Etal;
a=(m_ff2-m_ff1)/(m_fv2-m_fv1);
b=-a;
 
//Calcul des angles 
float alpha1,alpha2;
alpha1=m_fAngle/2;
alpha2=cos(alpha1*PI/180.0);
 
//Calcul de la force étalonnée
//Selection unité
CString sUnit;
switch(m_iUnit){
case 0 : sUnit="daN";break;
case 1 : sUnit="lbs";break;	
default: sUnit=" ";}
 
m_sUnit=m_sUnit2=sUnit; 
 
	if (m_iUnit==0)
	{
                Force_directe=(a*m_SliderValue+ b);               // Mon erreur 
	Force_Etal=Force_directe/cos45/alpha2;
	}
	else 
	{
	Force_directe=(a*m_SliderValue+ b)*2.2;          // mon erreur
                Force_Etal=(Force_directe/cos45/alpha2)*2.2;
	}
 
//Affichage
	m_FE.Format("%.3f",Force_Etal);
	m_FD.Format("%.3f",Force_directe);
	m_A2.Format("%.3f",alpha2);
UpdateData(FALSE);	
}
 
void CSimul_AngleDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) 
	{
	if(nSBCode == SB_THUMBPOSITION) { 
	m_SliderValue.Format("%ld", nPos);
    UpdateData(false); 
	}
	else { 
                       CDialog::OnHScroll(nSBCode, nPos, pScrollBar); 
	      }
 
}