Bonjour,

J'ai écris un petit programme en c dans lequel j'affiche une DialogBox( avec DialogboxParamA). Tout se passe bien mais dès que je rajoute une TabDialog sur ma DialogBox, DialogboxParamA rend immédiatement la main et donc le programme quitte sans rien avoir fait. J'ai tracé la callback associée et le système envoie un premier message MW_FONT, suivi juste après d'un WM_DESTROY puis d'un WL_NCDESTROY. Le plus étrange c'est que DialogboxParamA me renvoie -1 mais par contre un GetLastError() que je fais juste après me renvoie 0.

Voici 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
57
58
59
 
#include <windows.h>
#include "resource.h"
 
INT_PTR CALLBACK DlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam );
 
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int )
{
	LRESULT lResult = DialogBoxParamA( hInstance, MAKEINTRESOURCEA( IDD_DIALOGMAIN), NULL, DlgProc, 0L );
	DWORD dwError = GetLastError();
	return 0;
}
 
 
INT_PTR CALLBACK DlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
	switch( msg )
	{
	case WM_NCDESTROY:
		{
			int test=0;
			break;
		}
	case WM_SETFONT:
		{
			int test = 0;
			break;
		}
	case WM_DESTROY:
		{
			int test=0;
			break;
		}
	case WM_LBUTTONDBLCLK:
		{
			EndDialog(hWnd,0);
			break;
		}
	case WM_CLOSE:
		{
			EndDialog( hWnd, 0);
			break;
		}
	case WM_COMMAND:
		{
			switch( wParam )
			{
			case ID_BUTTON_OK:
			case ID_BUTTON_CANCEL:
				{
					EndDialog(hWnd,0);
					break;
				}
			}
			break;
		}
	}
	return 0;
}
Si ça peut éventuellement aider voilà le fichier de ressource :

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
 
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
 
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
 
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
 
/////////////////////////////////////////////////////////////////////////////
// Français (France) resources
 
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_FRA)
#ifdef _WIN32
LANGUAGE LANG_FRENCH, SUBLANG_FRENCH
#pragma code_page(1252)
#endif //_WIN32
 
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
 
1 TEXTINCLUDE 
BEGIN
    "resource.h\0"
END
 
2 TEXTINCLUDE 
BEGIN
    "#include ""afxres.h""\r\n"
    "\0"
END
 
3 TEXTINCLUDE 
BEGIN
    "\r\n"
    "\0"
END
 
#endif    // APSTUDIO_INVOKED
 
 
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
 
IDD_DIALOGMAIN DIALOGEX 0, 0, 297, 177
STYLE DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | DS_CENTER | WS_MAXIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
CAPTION "Dialog"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
    DEFPUSHBUTTON   "OK",ID_BUTTON_OK,240,7,50,14
    PUSHBUTTON      "Annuler",ID_BUTTON_CANCEL,240,24,50,14
    CONTROL         "",IDC_TAB1,"SysTabControl32",0x0,29,48,174,79
END
 
 
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
 
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO 
BEGIN
    IDD_DIALOGMAIN, DIALOG
    BEGIN
        LEFTMARGIN, 7
        RIGHTMARGIN, 290
        TOPMARGIN, 7
        BOTTOMMARGIN, 170
    END
END
#endif    // APSTUDIO_INVOKED
 
#endif    // Français (France) resources
/////////////////////////////////////////////////////////////////////////////
 
 
 
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
 
 
/////////////////////////////////////////////////////////////////////////////
#endif    // not APSTUDIO_INVOKED
... et resource.h :

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
 
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by TestGUI.rc
//
#define IDD_DIALOGMAIN                  101
#define IDC_TABCONTROL                  1003
#define ID_BUTTON_OK                    1004
#define ID_BUTTON_CANCEL                1005
#define IDC_TAB1                        1006
 
// Next default values for new objects
// 
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE        103
#define _APS_NEXT_COMMAND_VALUE         40001
#define _APS_NEXT_CONTROL_VALUE         1007
#define _APS_NEXT_SYMED_VALUE           101
#endif
#endif
Voilà merci beaucoup pour votre aide parce que ça fait plusieurs jours que je me prend la tête là dessus et je n'y comprends plus rien.