Dialog fenetre enfant qui bloque

Résolu
NairodDorian Messages postés 130 Date d'inscription lundi 26 juin 2006 Statut Membre Dernière intervention 18 août 2008 - 5 juin 2007 à 18:30
BruNews Messages postés 21040 Date d'inscription jeudi 23 janvier 2003 Statut Modérateur Dernière intervention 21 août 2019 - 6 juin 2007 à 09:29
Bonjour,

Mon probleme est le suivant, j'utilises les resources avec des dialog et je voudrai affiche un dialogue defini par Child dans les proprietes des resources et sans bordures dans mon dialog principal. Voici le code :

HINSTANCE hInst;


BOOL CALLBACK UserControl(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam)
{
 HDC hdc;
 PAINTSTRUCT ps;
 switch (msg) {
 case WM_COMMAND:
  switch (LOWORD(wparam)) {
  case IDCANCEL:
   EndDialog(hdlg, 0);
   return FALSE;
  }
 case WM_PAINT:
  hdc = BeginPaint(hdlg, &ps);


  // Draw code here...
  Rectangle(hdc, 0, 0, 100, 100);


  EndPaint(hdlg, &ps);
  break;
 }
 
 return FALSE;
}


BOOL CALLBACK AppDlg(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam)
{
 switch (msg) {
 case WM_INITDIALOG:
  SetClassLong(hdlg, GCL_HICON, (LONG)LoadIcon(NULL, IDI_APPLICATION));
  return TRUE;
 case WM_COMMAND:
  switch (LOWORD(wparam)) {
  case IDC_BUTTON1:
   // Creation fenetre enfant
   DialogBox(hInst, MAKEINTRESOURCE(IDD_USERCONTROL), hdlg, (DLGPROC)UserControl, 0);
   break;
  case IDCANCEL:
   EndDialog(hdlg, 0);
   return FALSE;
  }
 }
 return FALSE;
}


int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
  // TODO: Place code here.
 hInst = hInstance;
 DialogBoxParam(hInstance, MAKEINTRESOURCE(IDD_APP), NULL, (DLGPROC)AppDlg, 0);
 return 0;
}

Seul probleme l'application ne repond plus apres que j'ai appuye sur le bouton qui cree la fenetre enfant.

2 réponses

BruNews Messages postés 21040 Date d'inscription jeudi 23 janvier 2003 Statut Modérateur Dernière intervention 21 août 2019
6 juin 2007 à 09:29
BOOL CALLBACK UserControl(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam)
{
  HDC hdc;
  PAINTSTRUCT ps;
  switch (msg) {
    case WM_COMMAND:
      switch (wparam) {
        case IDCANCEL:
        EndDialog(hdlg, 0);
        break;
      }
      break;
    case WM_PAINT:
      hdc = BeginPaint(hdlg, &ps);
      Rectangle(hdc, 0, 0, 100, 100);
      EndPaint(hdlg, &ps);
      break;
  }
  return 0;
}


Suffit d'une organisation correcte de la wndProc.
Ne pas laisser WM_COMMAND enchainer direct dans WM_PAINT.

ciao...
BruNews, MVP VC++
3
NairodDorian Messages postés 130 Date d'inscription lundi 26 juin 2006 Statut Membre Dernière intervention 18 août 2008
5 juin 2007 à 20:49
Solution :
Remplacer DialogBox par CreateDialog.
0
Rejoignez-nous