;================================================================ ; Program: ListIcon FillByGadget Sample ; Author: netmaestro ; Date: January 7, 2007 ; Target OS: Windows All ; Target Compiler: PureBasic 4.02 ; License: Free, Unrestricted, Credit appreciated ; but not required ;================================================================ #LVM_SUBITEMHITTEST = #LVM_FIRST + 57 #LVM_GETSUBITEMRECT = #LVM_FIRST + 56 Global oldproc Global currentitem, currentsubitem Procedure MainWindowCallBack(hwnd, msg, wparam, lparam) result = #PB_ProcessPureBasicEvents Select msg Case #WM_DRAWITEM *lpdis.DRAWITEMSTRUCT = lparam Dim itemrect.RECT(3) For i = 1 To 3 RtlZeroMemory_(@itemrect(i),SizeOf(RECT)) itemrect(i)\top = i SendMessage_(*lpdis\hwndItem, #LVM_GETSUBITEMRECT, *lpdis\itemid, @itemrect(i)) text$ = GetGadgetItemText(GetDlgCtrlID_(*lpdis\hwndItem), *lpdis\itemid, i) SelectObject_(*lpdis\hDC, GetStockObject_(#NULL_PEN)) WhiteBrush = CreateSolidBrush_(#White) SelectObject_(*lpdis\hDC, WhiteBrush) Rectangle_(*lpdis\hDC, itemrect(i)\left, itemrect(i)\top, itemrect(i)\right, itemrect(i)\bottom) TextOut_(*lpdis\hDC, itemrect(i)\left+4, itemrect(i)\top+4, text$, Len(text$)) DeleteObject_(WhiteBrush) Next Case #WM_MEASUREITEM *lpmis.MEASUREITEMSTRUCT = lparam *lpmis\itemheight = 20 EndSelect ProcedureReturn result EndProcedure Procedure ResizeCombo(hwnd) RtlZeroMemory_(@itemrect.RECT,SizeOf(RECT)) itemrect\top = currentsubitem SendMessage_(hwnd,#LVM_GETSUBITEMRECT, currentitem, @itemrect) ResizeGadget(1,itemrect\left,itemrect\top,itemrect\right-itemrect\left,#PB_Ignore) InvalidateRect_(GadgetID(1),0,1) EndProcedure Procedure SubClass_LV(hwnd, msg, wparam, lparam) result = CallWindowProc_(oldproc, hwnd, msg, wparam, lparam) If msg = #WM_RBUTTONDOWN Or msg = #WM_LBUTTONDOWN GetCursorPos_(@cp.POINT) MapWindowPoints_(0,hwnd,@cp,1) HitInfo.LVHITTESTINFO Hitinfo\pt\x = cp\x HitInfo\pt\y = cp\y SendMessage_(hwnd,#LVM_SUBITEMHITTEST ,0,@HitInfo) If hitinfo\isubitem > 0 And HitInfo\iItem >= 0 currentitem = hitinfo\iitem currentsubitem = hitinfo\isubitem RtlZeroMemory_(@itemrect.RECT,SizeOf(RECT)) itemrect\top = hitinfo\iSubItem SendMessage_(hwnd,#LVM_GETSUBITEMRECT, hitinfo\iitem, @itemrect) If HitInfo\iSubItem = 2 ; номер столбца где должно отображатся ResizeGadget(1, itemrect\left, itemrect\top, itemrect\right-itemrect\left, itemrect\bottom-itemrect\top) SetGadgetText(1,GetGadgetItemText(0,currentitem,currentsubitem)) SetFocus_(GadgetID(1)) HideGadget(1,0) Else HideGadget(1,1) EndIf Else HideGadget(1,1) EndIf ElseIf msg=#WM_HSCROLL Or msg=#WM_VSCROLL ResizeCombo(hwnd) ElseIf msg=#WM_NOTIFY *nmHEADER.HD_NOTIFY = lParam Select *nmHEADER\hdr\code Case #HDN_ITEMCHANGING ResizeCombo(hwnd) EndSelect EndIf ProcedureReturn result EndProcedure OpenWindow(0,0,0,520,240,"",$CF0001) SetWindowCallback(@MainWindowCallBack()) ListIconGadget(0,0,0,520,140,"",0,#PB_ListIcon_GridLines|#LVS_OWNERDRAWFIXED) oldproc = SetWindowLong_(GadgetID(0), #GWL_WNDPROC, @SubClass_LV()) AddGadgetColumn(0,1,"Название",100) AddGadgetColumn(0,2,"Значение",100) AddGadgetItem(0, -1, Chr(10) + "Left" + Chr(10) + "5" + Chr(10) ) AddGadgetItem(0, -1, Chr(10) + "Top" + Chr(10) + "5" + Chr(10) ) AddGadgetItem(0, -1, Chr(10) + "Width" + Chr(10) + "350" + Chr(10) ) AddGadgetItem(0, -1, Chr(10) + "Height" + Chr(10) + "200" + Chr(10) ) SpinGadget(1, 0,0,0,0,0,500,#PB_Spin_Numeric) SetParent_(GadgetID(1),GadgetID(0)) HideGadget(1,1) Repeat EventID = WaitWindowEvent() Select EventID Case #PB_Event_Gadget Select EventGadget() Case 1 SetGadgetItemText(0, currentitem, GetGadgetText(1), currentsubitem) EndSelect EndSelect Until EventID = #WM_CLOSE
не знаю как спросить даже, но попробую, спингаджет не правильно помешается в листиконгаджет а комбобох правильно. Как это исправить?
Отредактировано mestnyi (26.09.2013 23:02:07)