Output to dlg list box

Started by
1 comment, last by curlious 20 years, 5 months ago
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.
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]
GetDlgItem(hwnd, id) returns the HWND associated with the child window of hwnd whose ID is id.

Colin Jeanne | Invader''s Realm

This topic is closed to new replies.

Advertisement