09-08-2009, 10:09 AM
السلام عليكم
شكرا للأخ STRELiTZIA على التوضيح الطيب .. أخي تحملني قليلا .. هل ممكن في الدرس القادم أن يكون الشرح حول دالة DrawItem
شكرا للأخ STRELiTZIA على التوضيح الطيب .. أخي تحملني قليلا .. هل ممكن في الدرس القادم أن يكون الشرح حول دالة DrawItem
كود :
function DrawItem(hDlg:HWND; wParam:wParam; lParam:lParam):LongInt;stdcall;
var
di: ^tagDRAWITEMSTRUCT;
str: PChar;
begin
di := pointer(lParam);
if di^.CtlType = ODT_BUTTON then
begin
if di^.itemState and ODS_SELECTED > 0 then SelectObject(di^.hdc, hIn2Color)
else SelectObject(di^.hdc, hInColor);
SelectObject(di^.hdc, hEdge);
FillRect(di^.hDC, di^.rcItem, hBgColor);
RoundRect(di^.hDC, di^.rcItem.Left, di^.rcItem.Top, di^.rcItem.Right,
di^.rcItem.Bottom, 6, 6);
if di^.itemState and ODS_SELECTED > 0 then OffsetRect(di^.rcItem, 1, 1);
case di^.CtlID of
ID_BtnGEN : str := '&Generate';
ID_BtnExit : str := '&Exit';
ID_BtnABOUT : str := '&About';
else str := '';
end;
SetBkMode(di^.hdc, TRANSPARENT);
SetTextColor(di^.hdc, CR_HIGHLIGHT);
DrawText(di^.hDC, str, Length(str), di^.rcItem,
DT_CENTER or DT_VCENTER or DT_SINGLELINE);
if di^.itemState and ODS_SELECTED > 0 then OffsetRect(di^.rcItem, -1, -1);
if di^.itemState and ODS_FOCUS > 0 then InflateRect(di^.rcItem, -3, -3);
Result := 1;
end else Result := 0;
end;
