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

📄 main.~pas

📁 一个QQ的界面源码
💻 ~PAS
📖 第 1 页 / 共 4 页
字号:
                  SideBar.Groups[0].Items[i].SmallImage:=StrToInt(aMsg[4]);
                  Break;
               end;
            end;
            for i := 0 to SideBar.Groups[2].ItemCount-1 do
            begin
               if SideBar.Groups[2].Items[i].Tag=StrToInt(aMsg[2]) then
               begin
                  SideBar.Groups[2].Items[i].Caption:=aMsg[3];
                  SideBar.Groups[2].Items[i].LargeImage:=StrToInt(aMsg[4]);
                  SideBar.Groups[2].Items[i].SmallImage:=StrToInt(aMsg[4]);
                  Break;
               end;
            end;{结束更新BtnBar上显示的好友信息}
         end;
      end;
   end;


end;

procedure TFrmMain_QQ.ItmImgLargeClick(Sender: TObject);
var
   i:integer;
begin
   for i := 0 to SideBar.GroupCount-1 do
   begin
      SideBar.Groups[0].IconType:= dxsgLargeIcon;
   end;
end;

procedure TFrmMain_QQ.ItmImgSmallClick(Sender: TObject);
var
   i:integer;
begin
      for i := 0 to SideBar.GroupCount-1 do
   begin
      SideBar.Groups[i].IconType:= dxsgSmallIcon;
   end;
end;

procedure TFrmMain_QQ.BtnSearchClick(Sender: TObject);
var
  Hnd:THandle;
  i:integer;
  NewItem:TdxSideBarItem;
  bTmp:Boolean;
begin
  Hnd:=FindWindow('TFrmFindFriends','查找用户');
  if not Hnd<>0 then
  begin
    FrmFindFriends:=TFrmFindFriends.Create(Application);
    try
      FrmFindFriends.ShowModal;
      FrmFindFriends.Update;
    finally
      FrmFindFriends.Release;
    end;
  end;

//将所加的好友头像加入BtnBar
//在数据库中查找尚未被加入BtnBar中的好友,即新添加的好友
    bTmp:=true;
    with DMShare.TblFriends do
    begin
        First;
        while not Eof do
        begin
            for i := 0 to SideBar.Groups[0].ItemCount-1 do
            begin
                if StrToInt(FieldValues['QQNumber'])=SideBar.Groups[0].Items[i].Tag then
                begin
                  bTmp:=False;
                  Break;
                end
                else
                begin
                  bTmp:=True;   
                end;
            end;
            if bTmp then
            begin
                SideBar.ActiveGroupIndex:=0;
                NewItem:=SideBar.ActiveGroup.Items.Add;
                NewItem.Caption:=FieldValues['UserName'];
                NewItem.LargeImage:=FieldValues['FaceID'] ;
                NewItem.SmallImage:=FieldValues['FaceID'];
                NewItem.Tag:=StrToInt(FieldValues['QQNumber']);
                NewItem.Index:=0;//将所添加的头像提到最上面
            end;
            Next;
        end;
    end;





(*   for i := 0 to 255 do   {这里是0到255,也就是说同时添加的好友不参超过256个,
                           其实这是不科学地,最好的做法是使用while aAddFndLst[i,0]<>'' do
                           这样才是最好地,以后再改吧!!}
   begin
      if aAddFndLst[i,0]<>'' then
      begin

         SideBar.ActiveGroupIndex:=0;
         NewItem:=SideBar.ActiveGroup.Items.Add;
         NewItem.Caption:=aAddFndLst[i,1];
         NewItem.LargeImage:=StrToInt(aAddFndLst[i,2]);
         NewItem.SmallImage:=StrToInt(aAddFndLst[i,2]);
         NewItem.Tag:=StrToInt(aAddFndLst[i,0]);
         NewItem.Index:=0;//将所添加的头像提到最上面
      end
      else
      begin
         Break;
      end;
   end;
{清空存储所添加好友的数组}
   for i := 0 to 255 do
   begin
      aAddFndLst[i,0]:='';
   end;
*)
end;

procedure TFrmMain_QQ.BtnBarChange(Sender: TObject);
var
   sFileName:string;
begin
   sFileName:=ExtractFilePath(Application.ExeName)+'sound\folder.wav';
   sndPlaySound(PChar(sFileName),SND_ASYNC)
end;

procedure TFrmMain_QQ.ItmSendMsgClick(Sender: TObject);
var
   MyFace:TBitmap;
   sPath,sBmp1,sBmp2:string;
   i,j:integer;
   bExistFrmMsg,bCreateFrmMsg:boolean;
begin
   bExistFrmMsg:=False;
   bCreateFrmMsg:=True;
{判断消息窗体是否已经创建,是则显示}
   for i := 0 to 254 do
   begin
      if WndRecArr[i].QQNum=IntToStr(ActiveItem.Tag) then
      begin
         WndRecArr[i].PForm.Show;
         WndRecArr[i].PForm.BtnRevert.SetFocus;
         ActiveItem:=nil;
         WndRecArr[i].QQNum:='';//一定要释放这个窗体所占用的数组空间
         bCreateFrmMsg:=False;//为假,不需要创建消息窗体了
         Break;
//         Exit;
      end;
   end;

   {判断是否继续托盘图标的跳动,具体说明参照procedure TFrmMain_QQ.TrayIconDblClick(Sender: TObject);}
   if TrayIcon.CycleIcons then
   begin
      for j := 0 to 254 do
      begin
         if WndRecArr[j].QQNum<>'' then
         begin
            bExistFrmMsg:=True;
            Break;
         end;
      end;
   if not bexistFrmMsg then
      begin
         TrayIcon.CycleIcons:=False;
//               TrayIcon.IconList:=nil;
         DMShare.IconList.GetIcon(1,TrayIcon.Icon);
      end;
   end;



{没有创建消息窗体则创建一个发送消息窗体}
if bCreateFrmMsg then
begin
   with TFrmMsg.Create(Application) do
   begin
//      Height:=290;
      Caption:='发送消息';
      LabSendTo.Caption:='发送给:';
      BtnSend.Enabled:=False;
      BtnRevert.Enabled:=False;
      LabQQNumber.Visible:=False;
      LabQQNumber.Caption:=IntToStr(ActiveItem.Tag);

      DMShare.TblFriends.First;//显示好友妮称
      if DMShare.TblFriends.Locate('QQNumber',IntToStr(ActiveItem.Tag),[]) then
      begin
         PnlUserName.Caption:=DMShare.TblFriends.FieldValues['UserName'];
      end;
//显示好友头像
      {先将头像提取出存储在硬盘上}
      MyFace:=TBitMap.Create;
      sPath:=ExtractFilePath(Application.ExeName)+'temp\';
      sBmp1:=IntToStr(ActiveItem.Tag)+'_1.bmp';
      sBmp2:=IntToStr(ActiveItem.Tag)+'_2.bmp';
      if not FileExists(sPath+sBmp1) then
      begin
         DMShare.ImgLarge.GetBitmap(ActiveItem.LargeImage,MyFace);
         MyFace.SaveToFile(sPath+sBmp1);{存储第一张图}
      end;
      if not FileExists(sPath+sBmp2) then
      begin
         DMShare.ImgLarge.GetBitmap(ActiveItem.LargeImage+170,MyFace);
         MyFace.SaveToFile(sPath+sBmp2);{存储第二张图}
      end;

      DMShare.ImgLarge.GetBitmap(ActiveItem.LargeImage,ImgFace.Picture.Bitmap);
//      ImgFace.Picture.Bitmap:=MyFace;

      if (FileExists(sPath+sBmp1)) and
         (FileExists(sPath+sBmp2))  then
      begin
         Timer.Enabled:=True;  {用定时器使好友眨眼睛}
      end;

      ActiveItem:=nil;//消除全局变量的值,此值的生效时间不能长

      Show;
      Update;
   end;
end;

end;

procedure TFrmMain_QQ.FormClose(Sender: TObject; var Action: TCloseAction);
var
   MyIni:TIniFile;
begin
   DMShare.TblFriends.Close;
   DMShare.TblChatLog.Close;
   DMShare.TblSystemMsg.Close;
   FrmMain_QQ.Offline;
//存储窗体位置
   MyIni:=TIniFile.Create(ExtractFilePath(Application.ExeName)+sQQNumber+'\FndSetup.ini');
   try
      MyIni.WriteInteger('SETUP','FormLeft',FrmMain_QQ.Left);
      MyIni.WriteInteger('SETUP','FormTop',FrmMain_QQ.Top);
   finally
      MyIni.Free;
   end;

    //删除临时目录
   if DirectoryExists(ExtractFilePath(Application.ExeName)+'temp') then
   begin
      Deltree(ExtractFilePath(Application.ExeName)+'temp');
   end;

end;

procedure TFrmMain_QQ.SideBarItemClick(Sender: TObject; Item: TdxSideBarItem);
var
   CursorPos:TPoint;
begin
//判断“发送信息”命令是否可用
   if Item.LargeImage>84 then
   begin
      ItmSendMsg.Enabled:=False;
   end
   else
   begin
      ItmSendMsg.Enabled:=True;
   end;

//判断“大图标”,“小图标”命令谁可用
   if SideBar.Groups[0].IconType=dxsgLargeIcon then
   begin
      ItmImgSmall.Enabled:=True;
      ItmImgLarge.Enabled:=False;
   end
   else
   begin
      ItmImgSmall.Enabled:=False;
      ItmImgLarge.Enabled:=True;
   end;

//判断“加入黑名单”是否可用
   if SideBar.ActiveGroupIndex=2 then
      ItmBeBaddy.Caption:='加为好友(&A)'
   else
      ItmBeBaddy.Caption:='加入黑名单(&A)';

   GetCursorPos(CursorPos);
   PMItem.Popup(CursorPos.X,CursorPos.Y);

//将当前Item赋给全局变量ActiveItem,以便在创建发送消息窗体时使用
   ActiveItem:=Item;
end;

procedure TFrmMain_QQ.SideBarDblClick(Sender: TObject);
begin
   if SideBar.FocusedItem<>nil then
   begin
      ItmSendMsg.Click;
   end;
end;

procedure TFrmMain_QQ.SideBarMouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
var
   CursorPos:TPoint;
begin
   if (SideBar.FocusedItem<>nil) and
      (Button=mbRight) and
      (SideBar.FocusedItem.LargeImage<85) then
   begin
      //将当前Item赋给全局变量ActiveItem,以便在创建发送消息窗体时使用
      ActiveItem:=SideBar.FocusedItem;
      ItmSendMsg.Click;
   end;

   if (SideBar.FocusedItem=nil) and
      (Button=mbRight) then
   begin
      //判断“删除组”、“改名组”是否可用?
      if (SideBar.ActiveGroupIndex=0) or
         (SideBar.ActiveGroupIndex=1) or
         (SideBar.ActiveGroupIndex=2) then
      begin
         ItmRenameGroup.Enabled:=False;
         ItmDelGroup.Enabled:=False;
      end
      else
      begin
         ItmRenameGroup.Enabled:=True;
         ItmDelGroup.Enabled:=True;
      end;

      
      GetCursorPos(CursorPos);
      PMGroup.Popup(CursorPos.X,CursorPos.Y);
   end;
end;

procedure TFrmMain_QQ.ItmSetupClick(Sender: TObject);
begin
   with TFrmSetup.Create(Application) do
   begin
      try
        PageControl1.ActivePage:=TabSystem;
        ShowModal;
        Update;
      finally
        Release;
      end;
   end;
end;

procedure TFrmMain_QQ.ItmSelfSetupClick(Sender: TObject);
begin
   with TFrmSetup.Create(Application) do
   begin
      try
        PageControl1.ActivePage:=TabSelf;
        ShowModal;
        Update;
      finally
        Release;
      end;
   end;
end;

procedure TFrmMain_QQ.ItmSelfSetup2Click(Sender: TObject);
begin
   ItmSelfSetup.Click;
end;

procedure TFrmMain_QQ.ItmSysSetupClick(Sender: TObject);
begin
   ItmSetup.Click;
end;

procedure TFrmMain_QQ.ItmDelFriendClick(Sender: TObject);
begin
   if MessageBox(GetActiveWindow(),'您确认要删除此好友吗?',
                  '删除好友',MB_YESNO+MB_ICONQUESTION)=IDYES then
   begin
      with DMShare.TblFriends do
      begin
         First;
         if Locate('QQNumber',IntToStr(ActiveItem.Tag),[]) then
         begin
            Delete;
         end;
      end;
      ActiveItem.Free;
      ActiveItem:=nil;
   End;

⌨️ 快捷键说明

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