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

📄 umain.pas

📁 自己写的一个 RSS 阅读器
💻 PAS
📖 第 1 页 / 共 5 页
字号:
begin
  if (key = VK_RETURN) and (AddressBox.Text <> '') then
  begin
    FindAddress(AddressBox.Text);
  end;
end;

procedure TMainWindow.BarCmbStyleChange(Sender: TObject);
begin
  ApplyStyle(Sender);
end;

procedure TMainWindow.EmbeddedWB1BeforeNavigate2(Sender: TObject;
  const pDisp: IDispatch; var URL, Flags, TargetFrameName, PostData,
  Headers: OleVariant; var Cancel: WordBool);
var NewIndex,index:Integer;
begin
  if (EmbeddedWB1.LocationURL<>'') and (EmbeddedWB1.LocationURL<>'about:blank')then
  begin
    BarCmbStyle.Enabled:=False;
    NewIndex := HistoryList.IndexOf(EmbeddedWB1.LocationURL);
    if NewIndex = -1 then
    begin
      if (HistoryIndex >= 0) and (HistoryIndex < HistoryList.Count-1) then
        while HistoryList.Count-1 > HistoryIndex do
          HistoryList.Delete(HistoryIndex);
      HistoryIndex := HistoryList.Add(EmbeddedWB1.LocationURL);
    end
    else
    HistoryIndex := NewIndex;
    index := AddressBox.Items.IndexOf(EmbeddedWB1.LocationURL);
    if index < 0 then
      AddressBox.Items.Insert(0, EmbeddedWB1.LocationURL)
    else
      AddressBox.Items.Move(Index, 0);
    AddressBox.Text:=EmbeddedWB1.LocationURL;
  end;
end;

procedure TMainWindow.EmbeddedWB1NavigateComplete2(Sender: TObject;
  const pDisp: IDispatch; var URL: OleVariant);
var NewIndex,index:Integer;
begin
  if (EmbeddedWB1.LocationURL<>'') and (EmbeddedWB1.LocationURL<>'about:blank')then
  begin
    NewIndex := HistoryList.IndexOf(EmbeddedWB1.LocationURL);
    if NewIndex = -1 then
    begin
      if (HistoryIndex >= 0) and (HistoryIndex < HistoryList.Count-1) then
        while HistoryList.Count-1 > HistoryIndex do
          HistoryList.Delete(HistoryIndex);
      HistoryIndex := HistoryList.Add(EmbeddedWB1.LocationURL);
    end
    else
      HistoryIndex := NewIndex;
    index := AddressBox.Items.IndexOf(EmbeddedWB1.LocationURL);
    if index < 0 then
      AddressBox.Items.Insert(0, EmbeddedWB1.LocationURL)
    else
      AddressBox.Items.Move(Index, 0);
    AddressBox.Text:=EmbeddedWB1.LocationURL;
  end;
end;

procedure TMainWindow.AddressBoxChange(Sender: TObject);
begin
  if (AddressBox.Text<>EmbeddedWB1.LocationURL) and (AddressBox.Text<>'') then
    EmbeddedWB1.Navigate(AddressBox.Text);
end;

procedure TMainWindow.actStopExecute(Sender: TObject);
begin
  EmbeddedWB1.Stop;
end;

procedure TMainWindow.actStopUpdate(Sender: TObject);
begin
  actStop.Enabled:=EmbeddedWB1.Busy;
end;

procedure TMainWindow.actRefreshExecute(Sender: TObject);
begin
  if BarCmbStyle.Enabled then
     ApplyStyle(Sender)
  else
    EmbeddedWB1.Refresh;
end;

procedure TMainWindow.actRefreshUpdate(Sender: TObject);
begin
  actRefresh.Enabled:=True;
end;

procedure TMainWindow.P1Click(Sender: TObject);
begin
  if FeedTree.FocusedNode=nil then
    Exit;
  FeedPropertyExec(TFeedItem(FeedTree.FocusedNode.Data));
end;

procedure TMainWindow.cxTreeList1DblClick(Sender: TObject);
var
   item:TcxTreeListNode;
begin
  item:=cxTreeList1.FocusedNode;
  if item<>nil then
    EmbeddedWB1.Navigate(TLocalRssItem(item.Data).Link);
end;

procedure TMainWindow.cxTreeList1CustomDrawCell(Sender: TObject;
  ACanvas: TcxCanvas; AViewInfo: TcxTreeListEditCellViewInfo;
  var ADone: Boolean);
var aID:Integer;
  FItem:TFlagItem;
begin
  
  if Odd(AViewInfo.Node.AbsoluteIndex) then
    ACanvas.Brush.Color := RGB(245,245,245);
  if AViewInfo.Node.Values[0] then
    ACanvas.Font.Style := []
  else
    ACanvas.Font.Style := [fsBold];
  try
    aID := AViewInfo.Node.Values[1];
    if aID>1 then
    begin
      FItem:=FlagList.Get_ItemByFlagID(aID);
      if FItem<>nil then
      begin
        ACanvas.Font.Color := StringToColor(FItem.FontColor);
        ACanvas.Brush.Color := StringToColor(FItem.BGColor);
      end
      else
      begin
        TLocalRssItem(AViewInfo.Node.Data).Flag := 0;
        AViewInfo.Node.Values[1] := 0;
      end;
    end
    else
      if aID = 1 then ACanvas.Font.Color:=clRed;
  finally // wrap up

  end;    // try/finally
  if AViewInfo.Selected then
  begin
    ACanvas.Brush.Color := clHighlight;
    ACanvas.Font.Color :=clHighlightText;
  end;
    
end;

procedure TMainWindow.BarBtnShowPerviewClick(Sender: TObject);
begin
  cxTreeList1.Preview.Visible :=not cxTreeList1.Preview.Visible;
  BarBtnShowPerview.Down := cxTreeList1.Preview.Visible;
  gProperties.ShowPerview := cxTreeList1.Preview.Visible;
end;

procedure TMainWindow.cxTreeList1MouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var node:TcxTreeListNode;
begin
  node := cxTreeList1.GetNodeAt(x,y);
  if node<>nil then
   cxTreeList1.PopupMenu := PMRssItem
  else
   cxTreeList1.PopupMenu := nil;
  ClickX := X + PanelLeft.Width + JvNetscapeSplitter1.Width;
  ClickY := Y + JvNetscapeSplitter1.Top + cxTreeList1.Top + 38;
end;

procedure TMainWindow.actMakeReadExecute(Sender: TObject);
var i:Integer;
begin
  try
    for i := 0 to cxTreeList1.SelectionCount - 1 do
    begin
      cxTreeList1.Selections[i].Values[0] := true;
      TLocalRssItem(cxTreeList1.Selections[i].Data).Readed := True;
    end;
    TLocalRssFeed(TLocalRssItem(cxTreeList1.Selections[0].Data).Owner.Owner).ExecItemChanged;
  finally // wrap up

  end;    // try/finally
end;

procedure TMainWindow.actMakeUnReadExecute(Sender: TObject);
var i:Integer;
begin
  try
    for i := 0 to cxTreeList1.SelectionCount - 1 do
    begin
    cxTreeList1.Selections[i].Values[0] := false;
    TLocalRssItem(cxTreeList1.Selections[i].Data).Readed := False;
    end;
    TLocalRssFeed(TLocalRssItem(cxTreeList1.Selections[0].Data).Owner.Owner).ExecItemChanged;
  finally // wrap up
    AutoSetReaded := False;
  end;
end;

procedure TMainWindow.actMakeReadUpdate(Sender: TObject);
begin
  actMakeRead.Enabled:=(cxTreeList1.FocusedNode.Values[0]=false)
  or (cxTreeList1.SelectionCount>1);
end;

procedure TMainWindow.actMakeUnReadUpdate(Sender: TObject);
begin
  actMakeUnRead.Enabled:=(cxTreeList1.FocusedNode.Values[0]=True)
  or (cxTreeList1.SelectionCount>1);
end;

procedure TMainWindow.actDeleteItemExecute(Sender: TObject);
var
  i:Integer;
  node:TcxTreeListNode;
begin
  for  i := cxTreeList1.SelectionCount - 1 downto  0 do    // Iterate
  begin
    node := cxTreeList1.Selections[i];
    TLocalRssItem(node.Data).Delete := True;
  end;
  //注: 不能在循环中使用 node.Delete 来删除项目(容易 OutOf Bound)
  //    在删除所有RssItem后,在 通过 下面语句来删除TreeList中的节点

  TLocalRssFeed(TLocalRssItem(node.Data).Owner.Owner).ExecItemChanged;
  cxTreeList1.DeleteSelection;
end;

procedure TMainWindow.actDeleteItemUpdate(Sender: TObject);
begin
  actDeleteItem.Enabled := cxTreeList1.SelectionCount > 0;
end;

procedure TMainWindow.cxTreeList1Click(Sender: TObject);
begin
  if ( cxTreeList1.HitTest.HitAtNode) then
  begin
    if (cxTreeList1.HitTest.HitColumn = Col_Read) then
      begin
        cxTreeList1.FocusedNode.Values[0] := not cxTreeList1.FocusedNode.Values[0];
        TLocalRssItem(cxTreeList1.FocusedNode.Data).Readed:=cxTreeList1.FocusedNode.Values[0];
        
        TLocalRssFeed(TLocalRssItem(cxTreeList1.FocusedNode.Data).Owner.Owner).ExecItemChanged;
        AutoSetReaded := False;
      end
    else
    begin
      if cxTreeList1.HitTest.HitColumn = Col_Flag then
      begin
        PMFlag.Popup(ClickX,ClickY);
      end;
    end;
  end;
end;

procedure TMainWindow.actPreviewExecute(Sender: TObject);
begin
  cxTreeList1.GotoPrev;
end;

procedure TMainWindow.actPreviewUpdate(Sender: TObject);
begin
  actPreview.Enabled := (not cxTreeList1.IsBOF) and (cxTreeList1.FocusedNode<>nil);
end;

procedure TMainWindow.actNextExecute(Sender: TObject);
begin
  cxTreeList1.GotoNext;
end;

procedure TMainWindow.actNextUpdate(Sender: TObject);
begin
  actNext.Enabled := (not cxTreeList1.IsEOF) and (cxTreeList1.FocusedNode<>nil);
end;

function TMainWindow.IsUnreadBOF:Boolean;
var i:Integer;
  node:TcxTreeListNode;
begin
  Result := True;
  if (cxTreeList1.Count<=0) or (cxTreeList1.FocusedNode=nil) then
    Exit;
  for i := cxTreeList1.FocusedNode.Index - 1 downto 0 do    // Iterate
    begin
      node := cxTreeList1.Items[i];
      if not node.Values[0] then
      begin
        PrevUnreadNode := node;
        Result := False;
        Break;
      end;
    end;    // for
end;

function TMainWindow.IsUnreadEOF:Boolean;
var i:Integer;
  node:TcxTreeListNode;
begin
  Result := True;
  if (cxTreeList1.Count<=0) or (cxTreeList1.FocusedNode=nil) then
    Exit;
  for i := cxTreeList1.FocusedNode.Index + 1 to cxTreeList1.Count -1 do    // Iterate
    begin
      node := cxTreeList1.Items[i];
      if not node.Values[0] then
      begin
        NextUnreadNode := node ;
        Result := False;
        Break;
      end;
    end;    // for
end;

procedure TMainWindow.EmbeddedWB1ScriptError(Sender: TObject; ErrorLine,
  ErrorCharacter, ErrorCode, ErrorMessage, ErrorUrl: String;
  var ContinueScript, Showdialog: Boolean);
begin
  ContinueScript := True;
  Showdialog := False;
end;

procedure TMainWindow.FeedTreeMouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
  feedItem:TFeedItem;
  favItem:TFavItem;
  rootnode,node:TcxTreeListNode;
begin
  if Button=mbright then
  begin
    node:=FeedTree.GetNodeAt(x,y);
    if node=nil then
    begin
      FeedTree.PopupMenu := nil;
      Exit;
    end;

    FeedTree.SetFocusedNode(node,[]);

    rootnode :=GetRootNode(node);
    if rootnode = ChannelNode then
    begin
      if node.Level=0 then
      begin
        FeedTree.PopupMenu := PMChannel;
        Exit;
      end;
      if TFeedItem(node.Data).Outline.Type_='folder' then
        FeedTree.PopupMenu := PMFolder
      else
        FeedTree.PopupMenu:=PMFeed;
    end
    else
    begin
      if rootnode = FavoritesNode then
      begin
        if node.Level=0 then
        begin
          FeedTree.PopupMenu := PMFav;
          Exit;
        end;
        if TfavItem(node.Data).Outline.Type_='folder' then
          FeedTree.PopupMenu := PMFavFolder
        else
          FeedTree.PopupMenu:=PMFavItem;
      end
      else
      begin
        FeedTree.PopupMenu:=PMSearch;
      end;
    end;
  end;
end;

procedure TMainWindow.FeedTreeCustomDrawCell(Sender: TObject;
  ACanvas: TcxCanvas; AViewInfo: TcxTreeListEditCellViewInfo;
  var ADone: Boolean);
begin
  try
    if AViewInfo.Node.Values[1]>0 then
      ACanvas.Font.Style := [fsBold];

    if AViewInfo.Node.Level=0 then
      ACanvas.Font.Color := clBlue;
  finally // wrap up

  end;    // try/finally
  if Odd(AViewInfo.Node.AbsoluteIndex) then
    ACanvas.Brush.Color:=RGB(245,245,245);
  if AViewInfo.Selected then
  begin
    ACanvas.Brush.Color := clHighlight;
    ACanvas.Font.Color :=clHighlightText;
  end;
end;

procedure TMainWindow.cxTreeList1Change(Sender: TObject);
begin
   actPreUnread.Enabled := not IsUnreadBOF ;
   actNextUnread.Enabled := not IsUnreadEOF;
end;

procedure TMainWindow.FeedTreeFocusedNodeChanged(Sender: TObject;
  APrevFocusedNode, AFocusedNode: TcxTreeListNode);
var
  feedItem:TFeedItem;
  favItem:TFavItem;
  rootnode,node:TcxTreeListNode;
begin
    node:=AFocusedNode;
    ShowHtmlInBrowser('');
    if node=nil then
    begin
      FeedTree.PopupMenu := nil;
      Exit;
    end;
  
  if (AFocusedNode.Level=0) then

⌨️ 快捷键说明

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