PDA

Click to See Complete Forum and Search --> : strange things happen...


Aragorn
Aug 16th, 2001, 12:16 PM
Ok. It seems to me that i'm never gonna get rid of some odd errors. Today's is the following:
I have a dialog opened with some buttons on it. When the user presses one of the buttons i want to open a new dialog, something like "advanced settings", the problem is that the second dialog doesn't show up but the controls in it they do. So i'm getting something like this (SEE ATTACHED JPG)
The code is the following, for the first dialog (called ID_NEWDLG) i use:
DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(ID_NEWDLG), hwnd, NewDlg);
and then i use the following code to open the other dialog:

BOOL CALLBACK NewDlg(
HWND hwnd,
UINT Message,
WPARAM wParam,
LPARAM lParam) {
switch(Message)
{
case WM_INITDIALOG: {
}
return TRUE;
case WM_COMMAND:
switch(LOWORD(wParam)) {
case IDOK:
EndDialog(hwnd, IDOK);
break;
case IDCANCEL:
EndDialog(hwnd, IDCANCEL);
break;
case IDC_PARAMETERS: {
if (IsDlgButtonChecked(hwnd, IDC_RADIOFFWD)) {
EndDialog(hwnd, IDOK);
DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(ID_FFWDPARAMDLG), hwnd, FFwdParamDlg);
}
}
break;
}
break;
default:
return FALSE;
}
return TRUE;
}


i don't know what is wrong with this code.
I will post the resource script just in case:

ID_NEWDLG DIALOGEX 0, 0, 294, 130
EXSTYLE WS_EX_DLGMODALFRAME | WS_EX_CONTEXTHELP
STYLE DS_MODALFRAME | DS_3DLOOK | DS_CONTEXTHELP | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "Create new network"
FONT 8, "MS Sans Serif"
{
CONTROL "Create", IDOK, "BUTTON", BS_PUSHBUTTON | BS_CENTER | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 128, 112, 50, 14
CONTROL "Cancel", IDCANCEL, "BUTTON", BS_PUSHBUTTON | BS_CENTER | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 184, 112, 50, 14
CONTROL "Help", IDHELP, "BUTTON", BS_PUSHBUTTON | BS_CENTER | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 240, 112, 50, 14
CONTROL "Type", IDC_GROUPBOX2, "button", BS_GROUPBOX | WS_CHILD | WS_VISIBLE | WS_GROUP, 8, 8, 92, 48
CONTROL "Feed Forward", IDC_RADIOFFWD, "button", BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 12, 18, 84, 10
CONTROL "Boltzmann Machine", IDC_RADIOBOLTZ, "button", BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 12, 28, 84, 12
CONTROL "RadioButton8", IDC_RADIOBUTTON6, "button", BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 12, 40, 84, 12
CONTROL "Parameters...", IDC_PARAMETERS, "button", BS_PUSHBUTTON | BS_CENTER | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 136, 13, 72, 19
}



ID_FFWDPARAMDLG DIALOGEX 0, 0, 344, 124
EXSTYLE WS_EX_DLGMODALFRAME | WS_EX_CONTEXTHELP
STYLE DS_MODALFRAME | DS_3DLOOK | DS_CONTEXTHELP | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "Feed Forward Network parameters"
FONT 8, "MS Sans Serif", 400, 0
{
CONTROL "Ok", IDOK, "BUTTON", BS_PUSHBUTTON | BS_CENTER | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 284, 60, 50, 14
CONTROL "Cancel", IDCANCEL, "BUTTON", BS_PUSHBUTTON | BS_CENTER | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 284, 80, 50, 14
CONTROL "Help", IDHELP, "BUTTON", BS_PUSHBUTTON | BS_CENTER | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 284, 100, 50, 14
CONTROL "Cell type", IDC_GROUPBOX1, "button", BS_GROUPBOX | WS_CHILD | WS_VISIBLE | WS_GROUP, 13, 12, 148, 104
CONTROL "Linear", IDC_CELLTYPE_LIN, "button", BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 22, 28, 40, 9
CONTROL "Enter slope", IDC_STATICTEXT_SLOPE, "static", SS_LEFT | WS_CHILD | WS_VISIBLE, 76, 28, 38, 8
CONTROL "1", IDC_CELLTYPE_SLOPE, "edit", ES_RIGHT | ES_NUMBER | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 124, 26, 20, 12, WS_EX_RIGHT
CONTROL "Sigmoid:", IDC_CELLTYPE_SIGM, "button", BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 21, 60, 44, 14
CONTROL "Select target", IDC_GROUPBOX2, "button", BS_GROUPBOX | WS_CHILD | WS_VISIBLE | WS_GROUP, 72, 45, 80, 38
CONTROL "Maximum", IDC_STATICTEXT_MAX, "static", SS_LEFT | WS_CHILD | WS_VISIBLE, 80, 56, 32, 8
CONTROL "Minimum", IDC_STATICTEXT_MIN, "static", SS_LEFT | WS_CHILD | WS_VISIBLE, 80, 68, 32, 8
CONTROL "1", IDC_CELLTYPE_MAX, "edit", ES_RIGHT | ES_NUMBER | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 124, 54, 20, 12, WS_EX_RIGHT
CONTROL "0", IDC_CELLTYPE_MIN, "edit", ES_RIGHT | ES_NUMBER | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 124, 66, 20, 12, WS_EX_RIGHT
CONTROL "Stochastic", IDC_CELLTYPE_STOCH, "button", BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 76, 88, 48, 12
CONTROL "Network structure", IDC_GROUPBOX3, "button", BS_GROUPBOX | WS_CHILD | WS_VISIBLE | WS_GROUP, 167, 12, 108, 104
CONTROL "Number of layers", IDC_STATICTEXT3, "static", SS_LEFT | WS_CHILD | WS_VISIBLE, 179, 48, 60, 8
CONTROL "Number of inputs", IDC_STATICTEXT4, "static", SS_LEFT | WS_CHILD | WS_VISIBLE, 179, 24, 60, 8
CONTROL "Number of outputs", IDC_STATICTEXT5, "static", SS_LEFT | WS_CHILD | WS_VISIBLE, 179, 36, 64, 8
CONTROL "Cells in each layer", IDC_STATICTEXT7, "static", SS_LEFT | WS_CHILD | WS_VISIBLE, 179, 60, 60, 8
CONTROL "", IDC_EDIT_INPUTS, "edit", ES_RIGHT | ES_NUMBER | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 247, 22, 20, 12, WS_EX_RIGHT
CONTROL "", IDC_EDIT_OUTPUTS, "edit", ES_RIGHT | ES_NUMBER | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 247, 34, 20, 12, WS_EX_RIGHT
CONTROL "", IDC_EDIT_LAYERS, "edit", ES_RIGHT | ES_NUMBER | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 247, 45, 20, 12, WS_EX_RIGHT
CONTROL "", IDC_EDIT_CELLSPLAY, "edit", ES_RIGHT | ES_NUMBER | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 247, 57, 20, 12, WS_EX_RIGHT
CONTROL "Frame1", IDC_STATICFRAME1, "static", SS_ETCHEDFRAME | WS_CHILD | WS_VISIBLE, 168, 73, 104, 1
CONTROL "Threshold", IDC_CHECKBOX2, "button", BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 176, 76, 48, 12
CONTROL "0", IDC_THRESH, "edit", ES_LEFT | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 228, 76, 20, 12
CONTROL "To cells in first layer", IDC_RADIOBUTTON7, "button", BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 182, 90, 76, 12
CONTROL "To all cells in network", IDC_RADIOBUTTON8, "button", BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 182, 102, 80, 12
}


i'm pretty sure that the error is not in the resource, but anyway...
Any thoughts will be welcome.
thanks

Aragorn
Aug 16th, 2001, 12:19 PM
sorry, i forgot to attach the image. Take a look and you'll see what i mean... :)

abdul
Aug 16th, 2001, 03:15 PM
Hmmm..

Try CreateDialog() instead of DialogBox()

abdul
Aug 16th, 2001, 03:17 PM
I noticed another thing that the second dialog you are creating has a parent window which you have allready destroyed.

Also Try to set the parent window to NULL

Aragorn
Aug 19th, 2001, 05:48 PM
I tried both things and they didn't work either.
I have created a very simple program that is supposed to do this job, ie. to create a second dialog from a first one, but IT DOESN'T WORK. The code is attached. It is a very small piece of code and is not doing any advanced stuff, so i don't understand what is wrong :(
I would appreciate someone taking a look at it.
thank's
:confused: :confused: :confused: :confused: :confused: