Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

MattS423

Are all my windows orphans? GetParent() failure

This topic is 5221 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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]

Share this post


Link to post
Share on other sites
Advertisement
hWndFindDlg was declared in the dialog porcedure prototype...like so

INT_PTR CALLBACK FindDialogProc( HWND hwndFindDlg, UINT uMsg,
WPARAM wParam, LPARAM lParam)


The debugger says that hWndFindDlg = 0x00260654
All i make of that is that it''s not NULL.

i''m pretty sure it''s valid.

Share this post


Link to post
Share on other sites
Presumably, hwndDlg is also a parameter, but...
If hwndDlg is NULL when you call CreateDialog, then the parent would be NULL as well. It wouldn''t hurt to check it. Just throwing out suggestions.

Share this post


Link to post
Share on other sites
At the point of calling the DialogBox() function, hwndDlg was NOT equal to NULL.

Also, DialogBox() returns 1.

Any other ideas?

[edited by - MattS423 on June 2, 2004 10:16:25 PM]

Share this post


Link to post
Share on other sites
Also, when i call MessageBox() from that dialog porcedure, I can''t seem to set the focus on the message box....probably a related issue.

Share this post


Link to post
Share on other sites
quote:
Original post by MattS423
So am i just dealing with the Windows of Penzance here?


So, are you suggesting that your windows have been ''piloted''?

Sorry, but I''m pretty much out of ideas.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!