winapi - Unable to receive all NM_CUSTOMDRAW dwDrawStage for a ListView -
i have win32 application (no mfc) mdi frame window.
the main mdi frame window of cause has mdiclient window. in application, main frame window has tabctrl kid window, displays listview wnds on bottom of main frame:
//create tab first, kid of main mdi frame 800px width , 300px height, @ point (0, 600) of main frame window. hwnd hwndtabctrl = createwindow(wc_tabcontrol, null, ws_child | ws_clipsiblings | ws_visible | tcs_bottom, 0, 600, 800, 300, hwndmainframe, null, hinstance, null); //add 1 tab item test: tcitem item; item.mask = tcif_text; item.psztext = l"test list view"; tabctrl_insertitem(hwndtabctrl , 0, &item); //and create listview, list view kid window of tab ctrl (hwndtabctrl) hwnd hwndlistview = createwindow(wc_listview, l"", ws_child | ws_border | lvs_report | lvs_showselalways | ws_visible, 0, 0,800, 280, hwndtabctrl , null, hinstance, null); //now insert 2 columns: lvcolumn column; column.mask = lvcf_width | lvcf_text; column.cx = 200; column.psztext = l"column 0"; listview_insertcolumn(hwndlistview , 0, &column); //column sub item 0 column.psztext = l"column 1"; listview_insertcolumn(hwndlistview , 1, &column); //column sub item 1 now want alter text color sub item 1.
lresult callback wndproc(hwnd hwnd, uint message, wparam wparam, lparam lparam) { switch (message){ case wm_notify: if (((lpnmhdr)lparam)->hwndfrom == hwndlistview && ((lpnmhdr)lparam)->code == nm_customdraw){ lpnmlvcustomdraw lplvcd = (lpnmlvcustomdraw)lparam; switch (lplvcd->nmcd.dwdrawstage){ case cdds_prepaint: //i can receive value homecoming cdrf_notifyitemdraw; break; case cdds_itemprepaint: //i cann't receive value: homecoming cdrf_notifysubitemdraw; break; case cdds_subitem | cdds_itemprepaint: //i cann't receive value: lplvcd->clrtext = rgb(255,0, 0); homecoming cdrf_newfont; break; } homecoming cdrf_dodefault; } break; case ... ... break; default: homecoming defframeproc(hwnd, hwndmainframe, message, wparam, lparam); } } in case wm_notify code block, can receive lplvcd->nmcd.dwdrawstage once, value cdds_prepaint. believe because homecoming value cdrf_notifyitemdraw not homecoming right "parent".
is problem of tabctrl or problem of mdi window?
despite documentation says, homecoming value bitmask can homecoming multiple values @ time. likewise, dwdrawingstage bitmask well, should looking specific bits interested in.
try more this:
lpnmhdr pnmhdr = (lpnmhdr) lparam; if ((pnmhdr->hwndfrom == hwndlistview) && (pnmhdr->code == nm_customdraw)) { lpnmlvcustomdraw lplvcd = (lpnmlvcustomdraw) lparam; if (lplvcd->nmcd.dwdrawstage & cdds_item) { if (lplvcd->nmcd.dwdrawstage & cdds_itemprepaint) { if (lplvcd->nmcd.dwdrawstage & cdds_subitem) { lplvcd->clrtext = rgb(255,0, 0); ... homecoming cdrf_dodefault | cdrf_newfont; } else { ... homecoming cdrf_dodefault | cdrf_notifysubitemdraw; } } ... } else { switch (lplvcd->nmcd.dwdrawstage) { case cdds_prepaint: { ... homecoming cdrf_notifyitemdraw | cdrf_notifysubitemdraw; } ... } } homecoming cdrf_dodefault; } listview winapi mdi
No comments:
Post a Comment