⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gfxoutbarctrl.cpp

📁 大家共同进步! 大家共同进步! 大家共同进步!
💻 CPP
📖 第 1 页 / 共 5 页
字号:
										bHigh = true;
										bDragging = true;

										SetCursor(hDragCursor);
										hCur = hDragCursor;

										bPressedHighlight = true;
									}
								}
							}
						}
					}
					break;

				case WM_SETCURSOR:
					SetCursor(hCur);
					break;

                case WM_LBUTTONDBLCLK:
                               AfxMessageBox("Double Click.");
                break;

				case WM_LBUTTONUP://在图标上UP
					{
						if (bHigh)
						{
							HighlightItem(-1);
							bHigh = false;
						}
						CPoint pt(msg.lParam);
						int idx, ht1 = HitTestEx(pt, idx);
						if (!bDragging)
						{
//应该调出一菜单
/*
							if (ht1 == htItem && idx == index) 
							{
								if (dwFlags&fSelHighlight && iLastSel >= 0)
								{
									CRect rc;
									GetIconRect(iSelFolder, iLastSel, rc);
									rc.InflateRect(1,1);
									InvalidateRect(rc);
								}

								iLastSel = index;

								if (dwFlags&fSelHighlight && iLastSel >= 0)
								{
									CRect rc;
									GetIconRect(iSelFolder, iLastSel, rc);
									rc.InflateRect(1,1);
									InvalidateRect(rc);
								}

//不知道这条信息用来做什么?
//								GetOwner()->SendMessage(WM_OUTBAR_NOTIFY, NM_OB_ITEMCLICK, idx);
							}
*/

						}
						else
						{
//不能这样处理。如果在同一个目录下,则要不允许拖动
//但可拖动到任意其它目录去
							if (ht1 == 0)//改为只有在目录的情况下,才允许拖动
							{
//								if (idx != index)
								{
									CBarFolder * pbf = (CBarFolder *) arFolder.GetAt(iSelFolder);
									CBarItem * piFrom = (CBarItem *) pbf->arItems.GetAt(index);
									pbf->arItems.RemoveAt(index);
                                    InsertItem(idx, piFrom->OnLineUser, piFrom->cItem ,piFrom->iImageIndex , piFrom->dwData,piFrom->IsAnimDisp);
								}
							}
						}
					}

					goto ExitLoop4;

				default:
					DispatchMessage(&msg);
					break;
				}
			}

		ExitLoop4:
			ReleaseCapture();
			AfxUnlockTempMaps(FALSE);
			if (bDragging) 
			{
				Invalidate();
			}
		}
		bPressedHighlight = false;
		if (bHigh) InvalidateRect(rc, false);
	}
	else iLastItemHighlighted = -1;

	if (ht == htDownScroll)
	{
		bLooping = true;
		bool bHigh = true;

		if (::GetCapture() == NULL)
		{
			SetCapture();
			ASSERT(this == GetCapture());
			CClientDC dc(this);
			dc.DrawFrameControl(rcDownArrow, DFC_SCROLL, DFCS_SCROLLDOWN|DFCS_PUSHED);
			SetTimer(2,10,NULL);//此定时器用来指示当按下滑块时,图标移动的动画
			AfxLockTempMaps();
			for (;;)
			{
				MSG msg;
				VERIFY(::GetMessage(&msg, NULL, 0, 0));

				if (CWnd::GetCapture() != this) break;

				switch (msg.message)
				{
				case WM_MOUSEMOVE:
					{
						CPoint pt(msg.lParam);
						if (rcDownArrow.PtInRect(pt))
						{
							if (bHigh == false)
							{
								dc.DrawFrameControl(rcDownArrow, DFC_SCROLL, DFCS_SCROLLDOWN|DFCS_PUSHED);
								bHigh = true;
								bDownArrow = true;
								bDownPressed = true;
							}
						}
						else
						{
							if (bHigh == true)
							{
								dc.DrawFrameControl(rcDownArrow, DFC_SCROLL, DFCS_SCROLLDOWN);
								bHigh = false;
								bDownArrow = false;
								bDownPressed = false;
							}
						}
					}
					break;

				case WM_LBUTTONUP:
					{
						if (bHigh)
						{
							dc.DrawFrameControl(rcDownArrow, DFC_SCROLL, DFCS_SCROLLDOWN);
							bHigh = false;
						}
						bDownArrow = false;
						CPoint pt(msg.lParam);
						if (rcDownArrow.PtInRect(pt))
						{
							CRect itrc;
							GetItemRect(iSelFolder, GetItemCount() - 1, itrc);
							CRect crc;
							GetInsideRect(crc);
							if (itrc.bottom > crc.bottom)
							{
								iFirstItem ++;
								InvalidateRect(crc, true);
							}
						}
					}
					goto ExitLoop3;


				case WM_TIMER:
					{
						if (msg.wParam == 2)
						{
							if (bHigh)
							{
								CPoint pt(msg.pt);
								ScreenToClient(&pt);
								if (rcDownArrow.PtInRect(pt))
								{
									bDownPressed = true;
									CRect itrc;
									GetItemRect(iSelFolder, GetItemCount() - 1, itrc);
									CRect crc;
									GetInsideRect(crc);
									if (itrc.bottom > crc.bottom)
									{
										iFirstItem ++;
										InvalidateRect(crc, true);
									}
									else goto ExitLoop3;
								}
								else bDownPressed = false;
							}
						}
						break;
					}

				case WM_KEYDOWN:	
					if (msg.wParam != VK_ESCAPE) 
						break;

				default:
					DispatchMessage(&msg);
					break;
				}
			}

		ExitLoop3:
			KillTimer(2);
			ReleaseCapture();
			AfxUnlockTempMaps(FALSE);
			bLooping = false;
			bDownPressed = false;
			bDownArrow = false;
			CRect crc;
			GetInsideRect(crc);
			InvalidateRect(crc, true);
		}
	}

	if (ht == htUpScroll)
	{
		bLooping = true;
		bool bHigh = true;

		if (::GetCapture() == NULL)
		{
			SetCapture();
			ASSERT(this == GetCapture());
			CClientDC dc(this);
			dc.DrawFrameControl(rcUpArrow, DFC_SCROLL, DFCS_SCROLLUP|DFCS_PUSHED);
			SetTimer(2,10,NULL);
			AfxLockTempMaps();
			for (;;)
			{
				MSG msg;
				VERIFY(::GetMessage(&msg, NULL, 0, 0));

				if (CWnd::GetCapture() != this) break;

				switch (msg.message)
				{
				case WM_MOUSEMOVE:
					{
						CPoint pt(msg.lParam);
						if (rcUpArrow.PtInRect(pt))
						{
							if (bHigh == false)
							{
								dc.DrawFrameControl(rcUpArrow, DFC_SCROLL, DFCS_SCROLLUP|DFCS_PUSHED);
								bHigh = true;
								bUpArrow = true;
								bUpPressed = true;
							}
						}
						else
						{
							if (bHigh == true)
							{
								dc.DrawFrameControl(rcUpArrow, DFC_SCROLL, DFCS_SCROLLUP);
								bHigh = false;
								bUpArrow = false;
								bUpPressed = false;
							}
						}
					}
					break;

				case WM_LBUTTONUP:
					{
						if (bHigh)
						{
							dc.DrawFrameControl(rcUpArrow, DFC_SCROLL, DFCS_SCROLLUP);
							bHigh = false;
						}
						bUpArrow = false;
						CPoint pt(msg.lParam);
						if (rcUpArrow.PtInRect(pt))
						{
							if (iFirstItem > 0 ) 
							{
								iFirstItem --;
								CRect crc;
								GetInsideRect(crc);
								InvalidateRect(crc, true);
							}
						}
					}

					goto ExitLoop;

				case WM_TIMER:
					{
						if (msg.wParam == 2)
						{
							if (bHigh)
							{
								CPoint pt(msg.pt);
								ScreenToClient(&pt);
								if (rcUpArrow.PtInRect(pt))
								{
									bUpPressed = true;
									if (iFirstItem > 0) 
									{
										iFirstItem --;
										CRect crc;
										GetInsideRect(crc);
										InvalidateRect(crc, true);
									}
									else goto ExitLoop;
								}
								else bUpPressed = false;
							}
						}
						break;
					}
				case WM_KEYDOWN:	
					if (msg.wParam != VK_ESCAPE) break;

				default:
					DispatchMessage(&msg);
					break;
				}
			}

		ExitLoop:
			KillTimer(2);
			ReleaseCapture();
			AfxUnlockTempMaps(FALSE);
			bLooping = false;
			bUpPressed = false;
			bUpArrow = false;
			CRect crc;
			GetInsideRect(crc);
			InvalidateRect(crc, true);
		}
	}
	
	CWnd::OnLButtonDown(nFlags, point);
}


int CGfxOutBarCtrl::InsertItem(const int folder, const int index, const char * text, const int image, const DWORD exData,int IsAnimDisp)
{
	ASSERT(folder >= 0 && folder < GetFolderCount());
	CBarFolder * pbf = (CBarFolder *) arFolder.GetAt(folder);
	return pbf->InsertItem(index, text, image, exData,IsAnimDisp);
}

int CGfxOutBarCtrl::GetItemCount() const
{
	ASSERT(iSelFolder >= 0 && iSelFolder < GetFolderCount());
	CBarFolder * pbf = (CBarFolder *) arFolder.GetAt(iSelFolder);
	return 	pbf->GetItemCount();
}

void CGfxOutBarCtrl::SetSelFolder(const int index)
{
	ASSERT(index >= 0 && index < GetFolderCount());
//	if (index == iSelFolder) return;

	CWnd * pc = GetFolderChild();
	if (pc) pc->ShowWindow(SW_HIDE);

	if (index != iSelFolder)
	{
		if (dwFlags&fAnimation && lAnimationTickCount >= 0) AnimateFolderScroll(iSelFolder, index);
	}

	iSelFolder = index;
	iFirstItem = 0;
	iLastSel = -1;

	pc = GetFolderChild();
	if (pc)
	{
		CRect rc;
		GetInsideRect(rc);
		pc->MoveWindow(rc);
		pc->ShowWindow(SW_SHOW);
	}	

	GetOwner()->SendMessage(WM_OUTBAR_NOTIFY, NM_FOLDERCHANGE, (LPARAM) iSelFolder);

	Invalidate();
}
							
int CGfxOutBarCtrl::GetFolderCount() const
{
	return arFolder.GetSize();
}

int CGfxOutBarCtrl::GetSelFolder() const
{
	return iSelFolder;
}

void CGfxOutBarCtrl::RemoveFolder(const int index)
{
	ASSERT(index >= 0 && index < GetFolderCount());
	CBarFolder * pbf = (CBarFolder *) arFolder.GetAt(index);
	delete pbf;
	arFolder.RemoveAt(index);
	if (iSelFolder >= index) iSelFolder = index - 1;
	if (iSelFolder < 0 && GetFolderCount() > 0) iSelFolder = 0;
	Invalidate();
}

int CGfxOutBarCtrl::CBarFolder::InsertItem(int index, const char * text, const int image, const DWORD exData,int IsAnimDisp)
//index:快速ICQ编号(QICQ号码)
//text标题
//image//图像索引号
//exData//利用来显示当前在线吗
{
    int tempIndex;
    char tempString[200];
    int tempData;
    CBarItem *pbf;
    CPtrArray arItems1,arItems2;
    //从PTRARRAY数组中得到当前的数据个数

	int c = GetItemCount();
//首先要找出在列表中有没有这个用户
        tempData=0;
        for(tempIndex=0;tempIndex<c;tempIndex++)
        {
            if(((CBarItem *)arItems.GetAt (tempIndex))->OnLineUser==index)
            {
                pbf=(CBarItem *)arItems.GetAt (tempIndex);
                pbf->dwData =exData;
                pbf->iImageIndex =image;
                pbf->IsAnimDisp =IsAnimDisp;
                arItems.RemoveAt (tempIndex);
//                arItems.Add ((void *)pbf);
                tempData=1;
                break;
            }
        }
        if(!tempData)
        {
	            pbf = new CBarItem(text, image, exData);
                pbf->OnLineUser =index;
                pbf->IsAnimDisp =IsAnimDisp;
        }
    //内存的分配将总是在读入或加为好友时进行
    //如果已分配好,当好友上线时,不再进行分配,而是根据改变的EXDATA值重新
    //设定索引,重新排序
    //如果删除一个好友,则释放内存
	ASSERT(pbf);//证实一下
    //建立两个临时的PTRARRAY数组,一个存放EXDATA=1的数据,一个存放EXDATA=0的
    //数据。对两个数组分别排序,然后统一加入到ARITEMS中去
    //前提是两个数组都是ARITEMS的子集,不要分配内存
    //不根据INDEX来排序,根据TEXT来排序好些
	c = GetItemCount();
    for(tempIndex=0;tempIndex<c;tempIndex++)
    {
        if(((CBarItem *)arItems.GetAt (tempIndex))->dwData)
        {
            arItems1.Add ((void *)arItems.GetAt (tempIndex));
        }
        else
        {
            arItems2.Add ((void *)arItems.GetAt (tempIndex));
        }
    }
    if(exData)
    {
        for(tempIndex=0;tempIndex<arItems1.GetSize();tempIndex++)
        {
            //如果此字符串比已有的某个字符串要小,跳出
            //如果一个也没有,则加入一个
            //如果比所有的都要大,跳出
            strcpy(tempString,((CBarItem *)arItems1.GetAt (tempIndex))->cItem);
            tempData=strcmp(text,tempString);
            if(tempData<=0)
                break;
        }
            arItems1.InsertAt (tempIndex,(void *)pbf);
    }
    else
    {
        for(tempIndex=0;tempIndex<arItems2.GetSize();tempIndex++)
        {
            //如果此字符串比已有的某个字符串要小,跳出
            //如果一个也没有,则加入一个
            //如果比所有的都要大,跳出
            strcpy(tempString,((CBarItem *)arItems2.GetAt (tempIndex))->cItem);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -