Click here to Skip to main content
15,906,463 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: FlexGrid control Pin
HvalaMne30-Mar-06 20:03
HvalaMne30-Mar-06 20:03 
QuestionArray Of CWnd Objects (Dynamic) Pin
CQub30-Mar-06 3:22
CQub30-Mar-06 3:22 
AnswerRe: Array Of CWnd Objects (Dynamic) Pin
CQub30-Mar-06 3:38
CQub30-Mar-06 3:38 
QuestionCan anybody explain this to me? Pin
Waldermort30-Mar-06 3:10
Waldermort30-Mar-06 3:10 
AnswerRe: Can anybody explain this to me? Pin
Rage30-Mar-06 5:13
professionalRage30-Mar-06 5:13 
GeneralRe: Can anybody explain this to me? Pin
Waldermort30-Mar-06 5:22
Waldermort30-Mar-06 5:22 
GeneralRe: Can anybody explain this to me? Pin
Rage30-Mar-06 7:07
professionalRage30-Mar-06 7:07 
QuestionGet Item Text in LitBox Problem Pin
gbruyneel30-Mar-06 2:36
gbruyneel30-Mar-06 2:36 
Hello,
I have a project (VS2005) with a dialogBox containing a listBox filled with my drive letters.
I use that code to populate the listbox :
BOOL NewDlgProc_OnInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam)<br />
{_TCHAR path[MAX_PATH];<br />
 int res;<br />
 _tcscpy_s(path, MAX_PATH, _T("*.*"));<br />
 res = DlgDirList(hwnd,(LPTSTR) path, IDL_DRIVE, 0, DDL_DRIVES);<br />
 if (res == 0)<br />
 {<br />
   MessageBox(hwnd, _T("No drive available"), _T("Warning!"),MB_OK | MB_ICONINFORMATION);<br />
 }<br />
 return TRUE;<br />
}


I would like to get the text of the selected item so i wrote the folowing code :
<br />
void NewDlgProc_OnSeldrive(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)<br />
{<br />
 LRESULT len=0;<br />
 LRESULT index;<br />
 // I Get the index of the selected item<br />
 index = SendDlgItemMessage(hwnd, IDL_DRIVE, LB_GETCURSEL, 0, 0);<br />
 if (index != LB_ERR)<br />
 {<br />
  _TCHAR driveText[8];<br />
  // I try to get the text of the selected item<br />
  len = SendDlgItemMessage(hwnd, IDL_DRIVE, LB_GETTEXT, (WPARAM)index2, (LPARAM)driveText);<br />
  if (gbr_len != LB_ERR)<br />
  {<br />
    ...<br />
  }<br />
 }<br />
...<br />
}


When i try to debug this code i have in the listbox two items with the folowing text : [-c-] and [-d-].
When i select an item i got in driveText variable something like that :
driveText[0] = 0x0e1c <br />
driveText[1] = 0x0013<br />
driveText[2] = 0x005b  '['<br />
driveText[3] = 0x002d  '-'<br />
driveText[4] = 0x0064  'd'<br />
driveText[5] = 0x002d  '-'<br />
driveText[6] = 0x005d  ']'<br />
driveText[7] = 0<br />

I do not understand why i get the first two index. I should have get directly the text '[-d-]'.

Could someone help me ?

Best regards.
AnswerRe: Get Item Text in LitBox Problem Pin
David Crow30-Mar-06 2:47
David Crow30-Mar-06 2:47 
GeneralRe: Get Item Text in LitBox Problem Pin
gbruyneel30-Mar-06 2:56
gbruyneel30-Mar-06 2:56 
GeneralRe: Get Item Text in LitBox Problem Pin
David Crow30-Mar-06 3:49
David Crow30-Mar-06 3:49 
AnswerRe: Get Item Text in LitBox Problem Pin
Hamid_RT30-Mar-06 4:31
Hamid_RT30-Mar-06 4:31 
Questionstring array Pin
J512198230-Mar-06 2:35
J512198230-Mar-06 2:35 
AnswerRe: string array Pin
David Crow30-Mar-06 2:51
David Crow30-Mar-06 2:51 
AnswerRe: string array Pin
Rage30-Mar-06 2:53
professionalRage30-Mar-06 2:53 
GeneralRe: string array Pin
J512198230-Mar-06 18:40
J512198230-Mar-06 18:40 
GeneralRe: string array Pin
Rage30-Mar-06 19:46
professionalRage30-Mar-06 19:46 
AnswerRe: string array Pin
khan++30-Mar-06 3:03
khan++30-Mar-06 3:03 
GeneralRe: string array Pin
Jörgen Sigvardsson30-Mar-06 3:26
Jörgen Sigvardsson30-Mar-06 3:26 
GeneralRe: string array Pin
khan++30-Mar-06 3:31
khan++30-Mar-06 3:31 
GeneralRe: string array Pin
toxcct30-Mar-06 3:40
toxcct30-Mar-06 3:40 
GeneralRe: string array Pin
khan++30-Mar-06 3:51
khan++30-Mar-06 3:51 
GeneralRe: string array Pin
toxcct30-Mar-06 3:55
toxcct30-Mar-06 3:55 
GeneralRe: string array Pin
khan++30-Mar-06 4:01
khan++30-Mar-06 4:01 
AnswerRe: string array Pin
HvalaMne30-Mar-06 20:18
HvalaMne30-Mar-06 20:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.