OK, so the user is supposed to click a button, and a dialog box pops up.They then enter a number in an edit box, and then I take that number, do a search on it, and select a peice of data in a list box the parent of this pop-up box.
Here's some code to try to explain this:
case IDC_BUTTON_FIND:
Ret = DialogBox(hInst,MAKEINTRESOURCEIDD_DIALOG_FIND),
hwndDlg,FindDialogProc);
break;
That makes the dialog box pop up quite nicely.
Now for the Dialog procedure. You click the OK button (IDOK) and it grabs the number from the Edit box (IDC_EDIT_IDCODE) and does some stuff with it, then selects a specific player in a list box.
Source Code:
// Parent is an HWND
case IDOK:
Parent = GetParent(hwndFindDlg); //FAILS!
//The debugger tells me that at this point, Parent == NULL
IDCode = GetDlgItemInt(hwndFindDlg,IDC_EDIT_IDCODE,NULL,TRUE);
if(!FindPlayer(IDCode,FoundPlayerIndex))
{
EndDialog(hwndFindDlg,1);
SetFocus(Parent);
break;
}
PlayerListBox = GetDlgItem(Parent,IDC_LIST_PLAYERS);
Sel = SendMessage(PlayerListBox,LB_SELECTSTRING,-1,
(LPARAM)Players[FoundPlayerIndex].Name);
SendMessage(PlayerListBox,LB_SETCURSEL,Sel,0);
EndDialog(hwndFindDlg,1);
SetFocus(Parent);
break;
This is all well and good, except for one little thing....GetParent() ALWAYS fails. After I call it, Parent == NULL. Because of this, I can't do anything with that list box...because i cant do a GetDlgItem() without the parent window handle.
Is there any reason for this? Why doesn't it work? Help?
Thanks alot
--Matt
[edited by - MattS423 on June 2, 2004 10:11:49 PM]