arp.arp_tha[i]=0x00; }
memset(sendbuf,0,sizeof(sendbuf)); memcpy(sendbuf,ð,sizeof(eth)); memcpy(sendbuf+sizeof(eth),&arp,sizeof(arp));
PacketInitPacket(lppackets,sendbuf,sizeof(eth)+sizeof(arp)); if(PacketSendPacket(lpadapter,lppackets,TRUE)==FALSE) { AfxMessageBox("PacketSendPacket in SendArpReq Error"); } }
双击表格中控制Sniffer、ARP欺骗和IP地址重复的栏目,需要变换其中的显示内容,要么从"ON"到"OFF",要么从"OFF"到"ON"(当然,主机数据结构中的控制属性也要随之而改变),相关的代码为:
void XTable::OnLButtonDblClk(UINT nFlags, CPoint point) { HitTest(point, focusRow, focusCol);
SetFocus(); CString str = GetText(focusRow, focusCol); if (str == "ON") { SetText(focusRow, focusCol, "OFF"); switch (focusCol) { case 2: oldHostList[focusRow - 1+nVWndPos / 13].sniffer = 0; break; case 3: oldHostList[focusRow - 1+nVWndPos / 13].arpCheat = 0; break; case 4: oldHostList[focusRow - 1+nVWndPos / 13].ipConflict = 0; break; default: break; } } else if (str == "OFF") { SetText(focusRow, focusCol, "ON"); switch (focusCol) { case 2: oldHostList[focusRow - 1+nVWndPos / 13].sniffer = 1; break; case 3: oldHostList[focusRow - 1+nVWndPos / 13].arpCheat = 1; break; case 4: oldHostList[focusRow - 1+nVWndPos / 13].ipConflict = 1; break; default: break; } }
Invalidate(); CWnd::OnLButtonDblClk(nFlags, point); }
上述代码中的HitTest()调用比较关键,用于获得当前选中的行和列,我们来看看相关的代码:
bool XTable::HitTest(CPoint point, int &row, int &col) { for (int i = 0; i < rows; i++) { for (int j = 0; j < rows; j++) { RECT rect = GetRect(i, j); if (rect.top <= point.y && rect.bottom > point.y && rect.left <= point.x && rect.right > point.x) { row = i; col = j;
共15页: 上一页 [1] [2] [3] 4 [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] 下一页
|