Pb affichage dialog box en mode release

cs_naoem Messages postés 2 Date d'inscription mardi 6 avril 2004 Statut Membre Dernière intervention 7 juillet 2004 - 7 juil. 2004 à 21:06
cs_naoem Messages postés 2 Date d'inscription mardi 6 avril 2004 Statut Membre Dernière intervention 7 juillet 2004 - 7 juil. 2004 à 21:52
bonjour,
je m'explique: j'ai fait un programme avec un menu qui ouvre des dialogbox (jusqu'ici tout va bien)...

en mode debug, il n'y a pas de pb, les fenetres s'ouvrent correctement..
des que je passe en mode release, il n'y a plus que les champs qui s'affichent et le background de la fenetre associée est blanc. je me doute que ca vient du style de la fenetre ou bien du handle mais je trouve pas...

le code est tout bête:

DialogBox (hInst, "DP_WRITE_DATA",hWnd, (DLGPROC)DP_OutSlvProc);

et la def de la fonction DP_OutSlvProc:
char DP_OutSlvProc (HWND hDlg, UINT message, WPARAM wParam, LONG lParam)

je fait bien l'init dialog (WM_INITDIALOG) dedans...

merci

3 réponses

cs_AlexMAN Messages postés 1536 Date d'inscription samedi 21 décembre 2002 Statut Membre Dernière intervention 24 mai 2009 1
7 juil. 2004 à 21:22
Montre nous ta DlgProc plz...

Merci ++

Alhexman
0
BruNews Messages postés 21040 Date d'inscription jeudi 23 janvier 2003 Statut Modérateur Dernière intervention 21 août 2019
7 juil. 2004 à 21:39
et commence aussi par virer le cast (DLGPROC) dans:
DialogBox(hInst, "DP_WRITE_DATA", hWnd, DP_OutSlvProc);
S'il y en a besoin, signe que ta dlgproc est mal prototypee, t'obligera a en mettre une correcte.

ciao...
BruNews, Admin CS, MVP Visual C++
0
cs_naoem Messages postés 2 Date d'inscription mardi 6 avril 2004 Statut Membre Dernière intervention 7 juillet 2004
7 juil. 2004 à 21:52
voila la fonction :

char DP_OutSlvProc (HWND hDlg, UINT message, WPARAM wParam, LONG lParam)

{
char result;
static HWND hComb,CyclicHwnd;
static unsigned int OutLen;
WORD i;
char CharBuf[1000];
long SlvAdr_l;
char *achHlp;


result = 1; /* Default value */

switch (message)
{
case WM_INITDIALOG:
{

/* set default output length */

OutLen = 255;
wsprintf (CharBuf,"1 ");
SendMessage ( GetDlgItem(hDlg,IDC_LENGTH),
WM_SETTEXT,
0,
(LPARAM)(LPSTR) CharBuf);

/* Set Focus */

hComb = GetDlgItem (hDlg, IDC_COMBO_WR_ADDR_SLV);
SetFocus (hComb);

for (i=0;i<126;i++)
{
wsprintf (CharBuf,"Slv %d",i);

if (Init_SlvBuff[i] == DPR_SLV_READY)
{
SendMessage (hComb,
CB_ADDSTRING,
0,
(LPARAM)(LPSTR)CharBuf);
}
}

/* Default in edit control */

wsprintf (CharBuf,"00 ");
SendMessage ( GetDlgItem(hDlg,IDC_DATA_WR),
WM_SETTEXT,
0,
(LPARAM)(LPSTR) CharBuf);

result = 0;
break;
}

case WM_COMMAND:
{
switch (LOWORD(wParam))
{

case IDC_LENGTH:
{
unsigned int k;

/* Get output bytes from edit control */
SendMessage (GetDlgItem(hDlg,IDC_LENGTH),
WM_GETTEXT,
10, /* max. text length */
(LPARAM)(LPSTR) CharBuf);
OutLen = atoi (CharBuf);

if (OutLen > 246)
{
OutLen = 246;
}
if (OutLen == 0)
{
OutLen = 1;
}

/* Show Default Values in edit control */

wsprintf (CharBuf,"00 ");
for (k=1;k<OutLen;k++)
{
lstrcat (CharBuf, "00 ");
}
SendMessage ( GetDlgItem(hDlg,IDC_DATA_WR),
WM_SETTEXT,
0,
(LPARAM)(LPSTR) CharBuf);
break;
}

case IDC_COMBO_WR_ADDR_SLV:
{
char Index;
if (HIWORD (wParam) == LBN_DBLCLK)
{
/* the same as IDOK */
PostMessage (hDlg,
WM_COMMAND,
IDOK,
(LPARAM) 0);
break;
}

if (HIWORD(lParam) == LBN_SELCHANGE)
{
Index = (char)SendMessage (hComb,
CB_GETCURSEL,
10,
(LPARAM)(LPSTR) CharBuf);
if (Index == CB_ERR)
{
break;
}
SendMessage (hComb,
CB_GETLBTEXT,
Index,
(LPARAM)(LPSTR) CharBuf);
}
break;
}

case IDC_BUTTON_WRITE:
{
/* Get actual string of the edit control */
SendMessage (hComb,
WM_GETTEXT,
10, /* max. text length */
(LPARAM)(LPSTR) CharBuf);

/* Slave address valid ? */

if ( strnicmp((const char far *)CharBuf,
(const char far *)"Slv ",
(size_t) 4 ) != 0)
{
/* invalid string */
MessageBox(hDlg,
(LPSTR) "address is out of range or unknown",
(LPSTR)"wrong slave address!",
MB_OK );

return (result);
}

achHlp = &CharBuf[3];
SlvAdr_l = strtoul ((char far *)&CharBuf[4],&achHlp,10); if ( ((SlvAdr_l 0) && (achHlp &CharBuf[4])) ||
(SlvAdr_l > 125)
)
{
/* invalid string */
MessageBox(hDlg,
(LPSTR) "address is out of range or unknown",
(LPSTR)"wrong slave address!",
MB_OK );
return (result);
}

Slave_add_g = (char)SlvAdr_l;

/* Get output bytes from edit control */
SendMessage (GetDlgItem(hDlg,IDC_DATA_WR),
WM_GETTEXT,
900, /* max. text length */
(LPARAM)(LPSTR) CharBuf);
if (GetStringValue ((char *)Slv_Module[Slave_add_g].buf_2_write ,(char *)CharBuf, (char)OutLen) == 0)
{
MessageBox( hDlg,
(LPSTR) "default value (0) is assumed for all output bytes",
(LPSTR)"Wrong syntax for output bytes!",
MB_OK );
for (i = 0; i < OutLen;i++)
{
Slv_Module[Slave_add_g].buf_2_write[i] = 0;
}
}

Slv_Module[Slave_add_g].nb_octets = OutLen;

/* Set the data to the adressed slave */
Send_Data ();

break;
}

case IDCANCEL:
case IDOK:
{
EndDialog(hDlg,IDOK);
break;
}

default:
{
result = 0;
break;
}
}
}

default:
{
result = 0;
}
}
return (result);
}

je reessaie demain..
0
Rejoignez-nous