Jump to content
  • Advertisement

Archived

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

curlious

Output to dlg list box

This topic is 5353 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

I am trying to get output to a list box in my dialog working. Here is an example of the function I am using. SendMessage(GetDlgItem( hChildHandle, IDC_SESSIONS ),LB_ADDSTRING,0,(LPARAM)szText); hChildHandle is equal to my main window handle do I need a seperate handle for my dialog, if so how do I get it. Little confused about handles.

Share this post


Link to post
Share on other sites
Advertisement
You usually get the handle of the dialog box when it fulfills its duties. Example:

HWND status_dlg //Handle of the dialog box

//...

status_dlg = CreateDialog(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_INFO_BOX),hwnd,Status_Dialog);
if(!status_dlg)
{
MessageBox(hwnd,"Satus Dialog Box cannot be created","ERROR",MB_OK);
}


When sending a message to the dialog box it seems, in what I've always accepted, you use the parent's handle. I'm not sure why but it seems to work for me.
Although my dialog box's handle is named spell_dlg, my parent windows handle, hwnd, will work.

for(loop=0; loop < 30; loop++)
{
if(spell[loop] != 4)
{
sprintf(int_buff,"%d",loop);
position=strstr(spell_char,int_buff);
int increment=loop+1;
sprintf(int_buff,"%d",increment);
strcpy(position,int_buff);
GetPrivateProfileString(spell_char,"Name","N/A",spell_char2,1000,spells_path);
SendDlgItemMessage(hwnd, IDC_LEARN_LIST, LB_ADDSTRING, 0, (LPARAM)spell_char2);
}
}
selection_valid=0;


Someone will have to clearify why the parent's handle works rather than the dialog's that the list is in.

Edit: Handle: A variable that identifies an object; an indirect reference to an operating system resource.

[edited by - Xiachunyi on October 21, 2003 9:44:16 PM]

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!