3 Attachment(s)
win32 listbox not populating right
Hi guys,
This is my first posting here, i am trying to learn to program a win32 GUI in code blocks 12.11, but here is the problem,
I have got 2x list boxes on a dialog box window(IDC_LIST1 > Personal Project Notes) and (IDC_LIST2 > Shared Project Notes),see attached pic,
Attachment 32005,
The (personal project notes) auto populates on the dialog been created, i can also get the (Shared project notes) to populate from a folder(by clicking button),see attached pic,
Attachment 32007,
The problem arises when i click the button(update personal) after clicking the(update shared ), it loads the contents of (shared project notes) into the(personal project notes) list box, even after using the clear button too, this still populates (the personal project notes) when clicking the (update personal)button, see attached pic,
Attachment 32009,
please could someone help me resolve this problem, has i have been banging my head against a wall for days now,
This is the code i have been currently experimenting with, please excuse the messy code, as most of it is from examples that i have converted to suit my GUI.
Code:
BOOL CALLBACK DlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam){
switch(Message){
case WM_INITDIALOG:
CheckRadioButton(HWND (hwnd),IDRADIO, IDRADIO2, IDRADIO);
{
DlgDirList(HWND (ID_PROJECT_PROJECT_NOTES), pbuffer, IDC_LISTP, 0, DDL_EXCLUSIVE);
HWND hListBox = GetDlgItem(hwnd, IDC_LISTP);
SendMessage(hListBox, LB_DIR, 0, (LPARAM)("*.txt*"));
}
break;
case WM_COMMAND:
switch(LOWORD(wParam)){
case ID_UPDATEP:{
SendDlgItemMessage(HWND(hwnd), IDC_LISTP, LB_RESETCONTENT, 0, 0);
DlgDirList(HWND (ID_PROJECT_PROJECT_NOTES), pbuffer, IDC_LISTP, 0, DDL_EXCLUSIVE);
HWND hListBox = GetDlgItem(hwnd, IDC_LISTP);
SendMessage(hListBox, LB_DIR, 0, (LPARAM)("*.txt"));
}
break;
case ID_UPDATES:{
SendDlgItemMessage(HWND(hwnd), IDC_LISTS, LB_RESETCONTENT, 0, 0);
DlgDirList(HWND (ID_PROJECT_PROJECT_NOTES), sbuffer, IDC_LISTS, 0, DDL_EXCLUSIVE);
HWND hList = GetDlgItem(hwnd, IDC_LISTS);
SendMessage(hList, LB_DIR, 0, (LPARAM)("*.txt"));
}
break;
case IDCLEAR:
SendDlgItemMessage(HWND(hwnd), IDC_LISTP, LB_RESETCONTENT, 0, 0);
SendDlgItemMessage(HWND(hwnd), IDC_LISTS, LB_RESETCONTENT, 0, 0);
break;
case IDCREATE:{
DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDPAD), NULL, DlgProc);
}
break;
case IDOK:
EndDialog(hwnd, IDOK);
break;
case IDCANCEL:
EndDialog(hwnd, IDCANCEL);
break;
}
break;
case WM_CLOSE:
EndDialog(hwnd, 0);
break;
default:
return FALSE;
}
return TRUE;
}
Re: win32 listbox not populating right
Hi again guys,
After getting a reply on another forum i have updated the code again,
DlgDirList(hwnd, pbuffer, IDC_LIST1, 0, 0);
sprintf(szTrace, "Filling 1 (ID %d) from %s: result = %d\n", IDC_LIST1, pbuffer, nResult);
MessageBox(hwnd, szTrace, "Personal", MB_OK);
This continues to load the "txt" files from the right folder(on the first click only as show in the pics above), with the trace i believe saying it failed, (Filling 1(ID3000) from*.txt: result=0)
this is the directory and folder that is been searched and populating the list boxes: char pbuffer[MAX_PATH] = ("C:\\Users\\uncboog\\Documents\\Nexum Core\\Project Notepad\\User\\*.txt");
char sbuffer[MAX_PATH] = "C:\\Users\\uncboog\\Documents\\Nexum Core\\Project Notepad\\Shared\\*.txt";
the problem works both ways, if u click the personal button first, then shared button, then personal button, or vice versa, it populates each list box correctly first time, then populates the wrong list box on the second click, again above pics. even after using the clear button they continue to populate wrong.
this is the dialog box .rc section,
ID_PROJECT_PROJECT_NOTES DIALOG DISCARDABLE 180, 600, 600, 400
STYLE DS_CENTER | DS_MODALFRAME | WS_POPUP| WS_CAPTION | WS_SYSMENU | WS_OVERLAPPED | WS_VISIBLE | WS_MINIMIZEBOX
CAPTION "Nexum Core Notepad System"
FONT 8, "MS Sans Serif"
BEGIN
PUSHBUTTON "&Update Personal",ID_UPPERSONAL,369,370,60,16
PUSHBUTTON "&Update Shared",ID_UPSHARE,431,370,60,16
PUSHBUTTON "&Create",ID_CREATE, 545,370,50,16
PUSHBUTTON "&Clear",ID_CLEAR,493,370,50,16
CTEXT "Nexum Core Notepad System\r\n\r\nby Uncle Boogs Production House Ltd",IDC_STATIC ,175,365,144,25
CTEXT "PERSONAL PROJECT NOTES...",IDC_STATIC ,230,1,144,10
CTEXT "SHARED PROJECT NOTES...",IDC_STATIC ,230,188,144,10
GROUPBOX "",IDC_STATIC,3,5,590,360
LISTBOX IDC_LIST1, 9, 15, 580, 170, WS_GROUP | WS_VSCROLL | LBS_NOINTEGRALHEIGHT | WS_BORDER //personal list box
LISTBOX IDC_LIST2, 9, 197, 580, 160,WS_VSCROLL | LBS_NOINTEGRALHEIGHT | WS_BORDER //shared list box
END
again guys this is my first ever attempt at this, so if anyone could find it in them selfs to help me figure out the problem, :):)