www.pudn.com > ChaoJiQiDong.rar > u_Main.pas, change:2009-11-23,size:26736b


unit u_Main; 
 
interface 
 
uses 
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, 
  Dialogs, mxOutlookBarPro, Menus,IniFiles, ImgList,shellapi, StdCtrls, 
  Buttons, ComCtrls, ExtCtrls, SkinCaption, WinSkinData,ActiveX,ShlObj, 
  CnClasses, CnTrayIcon,MMSystem; 
 
type 
  TForm1 = class(TForm) 
    PopupMenu1: TPopupMenu; 
    N1: TMenuItem; 
    N2: TMenuItem; 
    N3: TMenuItem; 
    N4: TMenuItem; 
    N5: TMenuItem; 
    N6: TMenuItem; 
    PopupMenu2: TPopupMenu; 
    N7: TMenuItem; 
    N9: TMenuItem; 
    N10: TMenuItem; 
    N11: TMenuItem; 
    PopupMenu3: TPopupMenu; 
    N12: TMenuItem; 
    N13: TMenuItem; 
    N14: TMenuItem; 
    N15: TMenuItem; 
    N16: TMenuItem; 
    N17: TMenuItem; 
    N18: TMenuItem; 
    N19: TMenuItem; 
    ImageList1: TImageList; 
    SkinData1: TSkinData; 
    SkinCaption1: TSkinCaption; 
    PopupMenu4: TPopupMenu; 
    N25: TMenuItem; 
    N26: TMenuItem; 
    Timer1: TTimer; 
    CnTrayIcon1: TCnTrayIcon; 
    PopupMenu5: TPopupMenu; 
    N23: TMenuItem; 
    N24: TMenuItem; 
    Label1: TLabel; 
    Panel1: TPanel; 
    mxOutlookBarPro1: TmxOutlookBarPro; 
    Panel2: TPanel; 
    SpeedButton1: TSpeedButton; 
    ImageList2: TImageList; 
    N8: TMenuItem; 
    N20: TMenuItem; 
    N21: TMenuItem; 
    procedure N1Click(Sender: TObject); 
    procedure mxOutlookBarPro1ContextPopup(Sender: TObject; 
      MousePos: TPoint; var Handled: Boolean); 
    procedure FormCreate(Sender: TObject); 
    procedure mxOutlookBarProHeadersButtonsClick(Sender: TObject); 
    procedure N17Click(Sender: TObject); 
    procedure mxOutlookBarPro1DragDrop(Sender: TmxOutlookBarPro; 
      Source: TObject; DataObject: IDataObject; 
      const Formats: array of Word; Shift: TShiftState; Pt: TPoint; 
      var Effect: Integer; Mode: TmxDropMode); 
    procedure N16Click(Sender: TObject); 
    procedure N12Click(Sender: TObject); 
    procedure N4Click(Sender: TObject); 
    procedure N7Click(Sender: TObject); 
    procedure Timer1Timer(Sender: TObject); 
    procedure N23Click(Sender: TObject); 
    procedure CnTrayIcon1DblClick(Sender: TObject); 
    procedure N24Click(Sender: TObject); 
    procedure N9Click(Sender: TObject); 
    procedure mxOutlookBarPro1Change(Sender: TObject; OldIndex, 
      NewIndex: Integer); 
    procedure ScriptClick(Sender: TObject); 
    procedure SpeedButton1Click(Sender: TObject); 
    procedure N8Click(Sender: TObject); 
  private 
    FAnchors: TAnchors; 
    procedure WMSIZING(var Msg: TMessage); message WM_SIZING; 
    procedure WMSysCommand(var Msg: TMessage); message WM_SYSCOMMAND; 
    procedure WMMOVING(var Msg: TMessage); message WM_MOVING; 
 
  public 
    procedure CommonSetFun(Sender: TObject); 
    Function  CreateSubMenuItem(itemText:string; 
    ItemNum:Integer; 
    MenuItem:TMenuItem; 
    MsgID:Integer):TMenuItem; 
  end; 
 
const 
  TempStrCount:Integer=1; 
  HeaderFileName:string='users\Header.ini'; 
  BtnFileName:string='users\mxButton.ini'; 
  CfgFileName:string='users\config.ini'; 
  sknFile:string='skins\'; 
  FormText:string='QRUN'; 
  HDropFormatEtc: TFormatEtc = ( cfFormat: CF_HDROP; ptd: Nil; dwAspect: DVASPECT_CONTENT; lindex: - 1; tymed: TYMED_HGLOBAL ); 
  MaxWidth = 500; 
  MinHeight = 300; 
var 
  Form1: TForm1; 
  MyPath:string=''; 
  CurSkn:string=''; 
  CurSelButtonIndex:Integer=0; 
  DefaultWidth,DefaultHeigth:Integer; 
  IsShow:Boolean=False; 
  IsUseMusic:Boolean=True; 
  Operation:string='open'; 
  ExeParam:string=''; 
  Function ExtractFileIcon(FileName:string;mxButton:TmxButton):Boolean; 
  Function AddButtontoFile(FileName:string;ButtonText:string;ExeFilePath:string;ExeParams:string=''):Boolean; 
  Function AddButtontoHeadFile(FileName:string;HeadCaption:string;ButtonText:string):Boolean; 
implementation 
uses 
  Math, 
  u_OutlookBar,u_AddDlg,u_CommonSetDlg,u_MondifyInfo, 
  u_NetSite,u_Chat; 
 
{$R *.dfm} 
 
procedure TForm1.WMMOVING(var Msg: TMessage); 
begin 
  inherited; 
  with PRect(Msg.LParam)^ do 
  begin 
    Left := Min(Max(0, Left), Screen.Width - Width); 
    Top := Min(Max(0, Top), Screen.Height - Height); 
    Right := Min(Max(Width, Right), Screen.Width); 
    Bottom := Min(Max(Height, Bottom), Screen.Height); 
    FAnchors := []; 
    if Left = 0 then Include(FAnchors, akLeft); 
    if Right = Screen.Width then 
      Include(FAnchors, akRight); 
    if Top = 0 then Include(FAnchors, akTop); 
    if Bottom = Screen.Height then 
      Include(FAnchors, akBottom); 
      Timer1.Enabled := FAnchors <> []; 
    end; 
end; 
 
procedure TForm1.WMSIZING(var Msg: TMessage); 
begin 
  Msg.Result := 1; 
  //限制最大宽度 
  if (PRect(Msg.LPARAM)^.Right - PRect(Msg.LPARAM)^.Left) > MaxWidth then 
  begin 
    if PRect(Msg.LPARAM)^.Left = Left then 
      PRect(Msg.LPARAM)^.Right := PRect(Msg.LPARAM)^.Left + MaxWidth 
    else 
      PRect(Msg.LPARAM)^.Left := PRect(Msg.LPARAM)^.Right - MaxWidth; 
  end; 
  //限制最小高度 
  if (PRect(Msg.LPARAM)^.Bottom - PRect(Msg.LPARAM)^.Top) < MinHeight then 
  begin 
    if PRect(Msg.LPARAM)^.Top = Top then 
      PRect(Msg.LPARAM)^.Bottom := PRect(Msg.LPARAM)^.Top + MinHeight 
    else 
      PRect(Msg.LPARAM)^.Top := PRect(Msg.LPARAM)^.Bottom - MinHeight; 
  end;   
end; 
 
procedure SearchFileEx(const Dir, Ext: string; Files: TStrings); 
var 
Found: TSearchRec; 
i: integer; 
Dirs: TStrings; 
Finished: integer; 
StopSearch: Boolean; 
begin 
    StopSearch := False; 
    Dirs := TStringList.Create; 
    Finished := FindFirst(Dir + '*.*', 63, Found); 
    while (Finished = 0) and not (StopSearch) do 
    begin 
        if (Found.Name <> '.') then 
        begin 
          if (Found.Attr and faDirectory) = faDirectory then 
              Dirs.Add(Dir + Found.Name) 
          else 
          if Pos(UpperCase(Ext), UpperCase(Found.Name)) > 0 then 
              Files.Add(Found.Name); 
        end; 
        Finished := FindNext(Found); 
    end; 
    FindClose(Found); 
    if not StopSearch then 
    for i := 0 to Dirs.Count - 1 do 
    SearchFileEx(Dirs[i], Ext, Files); 
    Dirs.Free; 
end; 
 
Function  LoadAllHeader(FileName:string):Boolean; 
var 
  i,HeaderCount:Integer; 
  MyIniFile:TIniFile; 
  HeaderList:TStringList; 
  mxHeader:TmxHeader;   
begin 
    Result:=False; 
    if not FileExists(FileName) then exit; 
    try 
        MyIniFile:=TIniFile.Create(FileName); 
        HeaderList:=TStringList.Create; 
        HeaderList.Clear; 
        MyIniFile.ReadSections(HeaderList); 
        HeaderCount:= HeaderList.Count; 
        if  HeaderCount=0 then exit; 
        for i:=0 to  HeaderCount-1 do 
        begin 
           mxHeader:=AddNewHeader(Form1.mxOutlookBarPro1,Trim(HeaderList[i])); 
           mxHeader.Images.Normal:= Form1.ImageList1; 
           mxHeader.Images.Small := Form1.ImageList1; 
        end; 
        Form1.mxOutlookBarPro1.ActiveHeader:=Form1.mxOutlookBarPro1.Header[0]; 
    finally 
        MyIniFile.Free; 
        HeaderList.Free; 
    end; 
end; 
 
 
Function  AddHeadertoFile(FileName:string;HeaderName:string):Boolean; 
var 
  MyIniFile:TIniFile; 
begin 
     try 
       MyIniFile:=TIniFile.Create(FileName); 
       MyIniFile.WriteString(HeaderName,'HeadPsw',''); 
       MyIniFile.DeleteKey(HeaderName,'HeadPsw'); 
     finally 
       MyIniFile.Free; 
     end; 
end; 
 
Function DelButtonOrHeadFromFile(FileName:string;HeaderName:string;ButtonText:string;IsDelHead:Boolean=False):Boolean; 
var 
  MyIniFile:TIniFile; 
begin 
     try 
       MyIniFile:=TIniFile.Create(FileName); 
       if IsDelHead then 
         MyIniFile.EraseSection(HeaderName) 
       else 
       begin 
         MyIniFile.DeleteKey(HeaderName,ButtonText); 
       end; 
     finally 
       MyIniFile.Free; 
     end; 
end; 
 
Function AddButtontoHeadFile(FileName:string;HeadCaption:string;ButtonText:string):Boolean; 
var 
  MyIniFile:TIniFile; 
begin 
     try 
       MyIniFile:=TIniFile.Create(FileName); 
       MyIniFile.WriteString(HeadCaption,ButtonText,''); 
     finally 
       MyIniFile.Free; 
     end; 
end; 
 
 
Function AddButtontoFile(FileName:string;ButtonText:string;ExeFilePath:string;ExeParams:string=''):Boolean; 
var 
  MyIniFile:TIniFile; 
begin 
     try 
       MyIniFile:=TIniFile.Create(FileName); 
       MyIniFile.WriteString(ButtonText,'path',ExeFilePath); 
       MyIniFile.WriteString(ButtonText,'params',ExeParams); 
     finally 
       MyIniFile.Free; 
     end; 
end; 
 
Function GetIcon(fName:string):hIcon; 
const 
Flags = SHGFI_ICON or SHGFI_SMALLICON;  
var 
FileInfo: TSHFileInfo; 
begin 
  SHGetFileInfo(PChar(fName), 
                0, 
                FileInfo, 
                SizeOf(FileInfo), 
                Flags); 
  Result := FileInfo.hIcon; 
end; 
 
Function ExtractFileIcon(FileName:string;mxButton:TmxButton):Boolean; 
var 
  hc:TIcon; 
  ImageListCount:Integer; 
begin 
  if not FileExists(FileName) then exit; 
  if mxButton=NIL then exit; 
  try 
    hc:= TIcon.Create; 
    hc.Handle:=GetIcon(FileName); 
    Form1.ImageList1.AddIcon(hc); 
    ImageListCount:=Form1.ImageList1.Count; 
    mxButton.ImageIndex:=ImageListCount-1; 
  finally 
    hc.Free; 
  end; 
end; 
 
Function  CopyBmptoImage(FileName:string;Image:TImage):Boolean; 
var 
  hc:TIcon; 
begin 
  if not FileExists(FileName) then exit; 
  if Image=NIL then exit; 
  try 
    hc:= TIcon.Create; 
    hc.Handle:=ExtractIcon(hInstance,PChar(FileName),0); 
    Image.Picture.Bitmap.Width := hc.Width; 
    Image.Picture.Bitmap.Height := hc.Height; 
    Image.Picture.Bitmap.Canvas.Draw(0,0,hc); 
  finally 
    hc.Free; 
  end; 
 
end; 
 
Function  LoadFileForHeader(FileName:string;mxHeader:TmxHeader):Boolean; 
var 
  i,HeaderFileCount:Integer; 
  MyIniFile,mxButtonIniFile:TIniFile; 
  HeaderFileList:TStringList; 
  HeaderCaption:string; 
  mxButton:TmxButton; 
  FilePath,FileParams:string; 
begin 
     try 
       HeaderCaption:=mxHeader.Caption; 
       MyIniFile:=TIniFile.Create(FileName); 
       mxButtonIniFile:=TIniFile.Create(MyPath+BtnFileName); 
       HeaderFileList:=TStringList.Create; 
       HeaderFileList.Clear; 
       MyIniFile.ReadSection(HeaderCaption,HeaderFileList); 
       HeaderFileCount:=HeaderFileList.Count; 
       if HeaderFileCount=0 then exit; 
      // if  HeaderFileCount<=TempStrCount then exit; 
       for i:=0 to  HeaderFileCount-1 do 
       begin 
           FilePath:=mxButtonIniFile.ReadString(HeaderFileList[i],'path',''); 
           if  FilePath='' then Continue; 
           FileParams:=mxButtonIniFile.ReadString(HeaderFileList[i],'params',''); 
           mxButton:=AddNewButton(mxHeader,HeaderFileList[i]); 
           mxButton.Hint:=FilePath; 
           mxButton.UserString:=FileParams; 
           ExtractFileIcon(FilePath,mxButton); 
           mxButton.OnClick:=Form1.mxOutlookBarProHeadersButtonsClick; 
       end; 
     finally 
       MyIniFile.Free; 
       mxButtonIniFile.Free; 
       HeaderFileList.Free; 
     end; 
end; 
 
procedure TForm1.N1Click(Sender: TObject); 
var 
  headerText:string; 
  mxHeader:TmxHeader; 
begin 
  Form1.mxOutlookBarPro1.Hint:=''; 
  headerText:=''; 
  Application.CreateForm(TForm2,Form2); 
  u_AddDlg.MyOutlookBar:=Form1.mxOutlookBarPro1; 
  Form2.Caption :='添加栏目'; 
  if Form2.ShowModal=1 then 
  begin 
      headerText:=Form1.mxOutlookBarPro1.Hint; 
      if headerText='' then exit; 
      mxHeader:=AddNewHeader(mxOutlookBarPro1,headerText); 
      AddHeadertoFile(MyPath+HeaderFileName,headerText); 
      Form1.mxOutlookBarPro1.ActiveHeader:=mxHeader; 
  end; 
  Form1.mxOutlookBarPro1.Hint:=''; 
end; 
 
Function  InRect(MousePos:TPoint;MyRect:TRect):Boolean; 
var 
  i:Integer; 
  x,y,pleft,pright,pTop,pBottom:Integer; 
  mxHeaderWidth:Integer; 
begin 
     Result:=False; 
     x:= MousePos.X;y:=MousePos.Y; 
     pLeft:=MyRect.Left; 
     pright:= MyRect.Right; 
     pTop:= MyRect.Top; 
     pBottom:=MyRect.Bottom; 
     if  (x>=pLeft ) and (x<=pright) and (y>=pTop)and (y<=pBottom) then 
        Result:=True; 
end; 
 
procedure TForm1.mxOutlookBarPro1ContextPopup(Sender: TObject; 
  MousePos: TPoint; var Handled: Boolean); 
var 
  Pos: TPoint; 
  w:Integer; 
  HeadRect:TRect; 
begin 
    Pos := ClientToScreen(MOUSEPOS); 
    If Sender Is TmxHeader Then 
    begin 
         HeadRect:=TmxHeader(Sender).ButtonRect; 
         if InRect(MousePos,HeadRect) then 
           PopupMenu1.Popup(Pos.X,Pos.Y) 
         else 
           PopupMenu2.Popup(Pos.X,Pos.Y); 
    end; 
    If Sender Is TmxButton Then 
    begin 
      CurSelButtonIndex:=  TmxButton(Sender).ButtonIndex; 
      PopupMenu3.Popup( Pos.X, Pos.Y ); 
    end; 
    Handled := True; 
end; 
 
Function  SetOutlookBarPre(OutlookBar:TmxOutlookBarPro;PreStr:string):Boolean; 
begin 
     Result:=True; 
     if   PreStr= 'psOffice2000' then 
        OutlookBar.PreSet:=psOffice2000 
     else if PreStr='psToolBox' then 
        OutlookBar.PreSet:=psToolBox 
     else if PreStr='psOutLook' then 
        OutlookBar.PreSet:=psOutLook 
     else 
        OutlookBar.PreSet:=psOffice2000; 
end; 
 
Function  LoadCfgFile(FileName:string):Boolean; 
var 
  MyIniFile:TIniFile; 
  PreStr:string; 
begin 
    Result:=False; 
    if not FileExists(FileName) then exit; 
    try 
        MyIniFile:=TIniFile.Create(FileName); 
        PreStr:= MyIniFile.ReadString('OutLookBar','PreSet','psOffice2000'); 
        IsUseMusic:=MyIniFile.ReadBool('OutLookBar','UseMusic',True); 
        CurSkn:=MyIniFile.ReadString('skn','skn','VistaXP-VISTAXPB2.skn'); 
        if Form3<>NIL then 
        begin 
          if PreStr='psToolBox' then 
              Form3.RadioButton1.Checked :=True 
          else 
              Form3.RadioButton2.Checked :=True; 
          Form3.CheckBox3.Checked:= IsUseMusic; 
        end 
        else 
        begin 
           SetOutlookBarPre(Form1.mxOutlookBarPro1,PreStr); 
        end; 
    finally 
        MyIniFile.Free; 
    end; 
end; 
 
Function  SaveCfgFile(FileName:string):Boolean; 
var 
  MyIniFile:TIniFile; 
  PreStr:string; 
begin 
    try 
        MyIniFile:=TIniFile.Create(FileName); 
        if Form3<>NIL then 
        begin 
            if Form3.RadioButton1.Checked then 
               PreStr:='psToolBox' 
            else 
               PreStr:='psOffice2000'; 
            MyIniFile.WriteBool('OutLookBar','UseMusic',Form3.CheckBox3.Checked); 
            MyIniFile.WriteString('OutLookBar','PreSet',PreStr); 
        end; 
        MyIniFile.WriteString('skn','skn',Curskn); 
    finally 
        MyIniFile.Free; 
    end; 
end; 
 
Function  InsertButtonInHeader:Boolean; 
var 
  i,HeaderNum:Integer; 
begin 
  HeaderNum:=Form1.mxOutlookBarPro1.HeaderCount; 
  if  HeaderNum=0 then exit; 
  for i:=0 to  HeaderNum-1 do 
       LoadFileForHeader(MyPath+HeaderFileName,Form1.mxOutlookBarPro1.Header[i]); 
end; 
 
function GetWeek:string ; 
var 
date:SYSTEMTIME; 
begin 
  GetLocalTime(date); 
  case date.wDayOfWeek of 
    0:Result:='星期天'; 
    1:Result:='星期一'; 
    2:Result:='星期二'; 
    3:Result:='星期三'; 
    4:Result:='星期四'; 
    5:Result:='星期五'; 
    6:Result:='星期六'; 
  end; 
end; 
 
 
procedure UpdateTimeThread; 
var 
  MyTime:TDateTime; 
begin 
    while(True) do 
    begin 
         MyTime:=now(); 
         Form1.Label1.Caption:=Format('%s %s %s',[FormatDateTime('mm月dd日',MyTime), 
              GetWeek,FormatDateTime('hh:mm:ss',MyTime)]); 
         sleep(500); 
    end; 
     
end; 
 
Function  LoadSknFile(FileDir:string):Boolean; 
var 
  i,SknCount:Integer; 
  SknList:TStringList; 
begin 
  if not DirectoryExists(FileDir) then exit; 
  try 
    SknList:=TStringList.Create; 
    SknList.Clear; 
    SearchFileEx(FileDir,'skn',SknList); 
    SknCount:=SknList.Count; 
    if  SknCount=0 then exit; 
    for i:=0 to  SknCount-1 do 
        Form1.CreateSubMenuItem(SknList[i],i,Form1.PopupMenu4.Items,1); 
 
  finally 
    SknList.Free; 
  end; 
end; 
 
Function  InitIco:Boolean; 
begin 
   Form1.ImageList2.GetBitmap(0,Form1.SpeedButton1.Glyph); 
end; 
 
procedure TForm1.FormCreate(Sender: TObject); 
var 
  ThreadID:DWORD; 
begin 
     SetWindowPos(Form1.handle,HWND_TOPMOST,Left,Top,Width,Height,0); 
     SetWindowLong(Application.handle,GWL_EXSTYLE,WS_EX_TOOLWINDOW);   
     Form1.Caption :=FormText; 
     Application.Title :=FormText; 
     MyPath:=ExtractFilePath(ParamStr(0)); 
     N6.OnClick:=CommonSetFun; 
     N11.OnClick:=CommonSetFun; 
     N19.OnClick:=CommonSetFun; 
     LoadCfgFile(MyPath+CfgFileName); 
 
     LoadAllHeader(MyPath+HeaderFileName); 
     InsertButtonInHeader;  
 
     DefaultWidth:=Form1.Width; 
     DefaultHeigth:=Form1.Height; 
     Top:=-2; 
     Label1.Color:=Form1.Color; 
     BeginThread(NIL,0,@UpdateTimeThread,NIL,0,ThreadID); 
 
     LoadSknFile(MyPath+sknFile);    //动态加载皮肤文件 
     if CurSkn<>'' then 
     begin 
        SkinData1.SkinFile:=MyPath+sknFile+CurSkn; 
     end; 
 
     InitIco; 
end; 
 
Function  RunExe(ExePath:string;Operation:string='open';ExeParam:string=''):Boolean; 
begin 
   ShellExecute(Form1.Handle,PChar(Operation),PChar(ExePath),PChar(ExeParam),PChar(ExtractFilePath(ExePath)),SW_SHOWDEFAULT); 
end; 
 
procedure TForm1.mxOutlookBarProHeadersButtonsClick(Sender: TObject); 
var 
  ExePath:string; 
begin 
    Operation:='open'; ExeParam:=''; 
    ExePath:=TmxButton(Sender).Hint; 
    ExeParam:=TmxButton(Sender).UserString; 
    RunExe(ExePath,Operation,ExeParam); 
end; 
 
procedure TForm1.N17Click(Sender: TObject); 
var 
  mxButton:TmxButton; 
begin 
   mxButton:=mxOutlookBarPro1.ActiveHeader.Button[CurSelButtonIndex]; 
   RunExe(ExtractFilePath(mxButton.Hint)); 
end; 
 
procedure TForm1.CommonSetFun(Sender: TObject); 
begin 
   if Form3=NIL then 
   begin 
      Application.CreateForm(TForm3,Form3); 
      u_CommonSetDlg.MyOutlookBar :=mxOutlookBarPro1; 
      LoadCfgFile(MyPath+CfgFileName); 
   end; 
   Form3.Caption :='常规设置';    
   if Form3.ShowModal=1 then 
   begin 
      SaveCfgFile(MyPath+CfgFileName); 
      IsUseMusic:=AcceptMusic; 
   end; 
end; 
 
 
procedure TForm1.mxOutlookBarPro1DragDrop(Sender: TmxOutlookBarPro; 
  Source: TObject; DataObject: IDataObject; const Formats: array of Word; 
  Shift: TShiftState; Pt: TPoint; var Effect: Integer; Mode: TmxDropMode); 
  Var 
  Button: TmxButton; 
  medium: TStgMedium; 
  DropFiles: PDropFiles; 
  Filename: PChar; 
 
 
  procedure CreateButton( FileName: String ); 
  begin 
    AddButtontoHeadFile( MyPath+HeaderFileName,Sender.CurrentTargetHeader.Caption,ExtractFileName(FileName)); 
    AddButtontoFile(MyPath+BtnFileName, 
        ExtractFileName(FileName), FileName); 
    Button:=AddNewButton(Sender.CurrentTargetHeader,ExtractFileName(FileName)); 
    ExtractFileIcon(FileName,Button); 
    Button.Hint := FileName; 
    Button.OnClick:=Form1.mxOutlookBarProHeadersButtonsClick; 
    Sender.ProcessOuterDrop( DataObject, Button, Sender.CurrentTargetButton, Effect, Sender.CurrentTargetButton.HitStatus ); 
  end; 
begin 
  If Mode = dmButton Then 
  Begin 
    If ( DataObject.GetData( HDropFormatEtc, medium ) <> S_OK ) Then exit; 
 
    Try 
      If ( medium.tymed = TYMED_HGLOBAL ) Then 
      Begin 
        DropFiles := PDropFiles( GlobalLock( medium.HGlobal ) ); 
        Try 
          Filename := PChar( DropFiles ) + DropFiles^.pFiles; 
          While ( Filename^ <> #0 ) Do 
          Begin 
            If ( DropFiles^.fWide ) Then 
            Begin 
              CreateButton( PWideChar( FileName ) ); 
              Inc( Filename, ( Length( PWideChar( FileName ) ) + 1 ) * 2 ); 
            End 
            Else 
            Begin 
              CreateButton( Filename ); 
              Inc( Filename, Length( Filename ) + 1 ); 
            End; 
          End; 
        Finally 
          GlobalUnlock( medium.HGlobal ); 
        End; 
      End; 
    Finally 
      ReleaseStgMedium( medium ); 
    End; 
  End; 
end; 
 
Function  DelBtnFromBtnFile(FileName:string;BtnText:string):Boolean; 
var 
  MyIniFile:TIniFile; 
begin 
     try 
       MyIniFile:=TIniFile.Create(FileName); 
       MyIniFile.EraseSection(BtnText); 
     finally 
       MyIniFile.Free; 
     end; 
end; 
 
procedure TForm1.N16Click(Sender: TObject); 
var 
  SelButton:TmxButton; 
  HeadStr,OldButtonText:string; 
begin 
   Application.CreateForm(TForm4,Form4); 
   Form4.Caption :='修改资料'; 
   HeadStr:=mxOutlookBarPro1.ActiveHeader.Caption; 
   SelButton:=mxOutlookBarPro1.ActiveHeader.Button[CurSelButtonIndex]; 
   OldButtonText:= SelButton.Caption ; 
   u_MondifyInfo.MondifyButton:= SelButton; 
   Form4.LabeledEdit1.Text :=  SelButton.Caption; 
   Form4.LabeledEdit2.Text :=  SelButton.Hint; 
   Form4.LabeledEdit3.Text :=  SelButton.UserString; 
   CopyBmptoImage(SelButton.Hint,Form4.Image1); 
   if Form4.ShowModal=1 then 
   begin 
      DelButtonOrHeadFromFile(MyPath+HeaderFileName,HeadStr,OldButtonText); 
      DelBtnFromBtnFile(MyPath+BtnFileName,OldButtonText); 
      AddButtontoHeadFile( MyPath+HeaderFileName,HeadStr,SelButton.Caption); 
      AddButtontoFile(MyPath+BtnFileName,SelButton.Caption,SelButton.Hint,SelButton.UserString); 
   end; 
   u_MondifyInfo.MondifyButton:=NIL; 
end; 
 
procedure TForm1.N12Click(Sender: TObject); 
var 
  mxButton:TmxButton; 
  BtnText,HeadStr:string; 
begin 
   HeadStr:= mxOutlookBarPro1.ActiveHeader.Caption; 
   mxButton:=mxOutlookBarPro1.ActiveHeader.Button[CurSelButtonIndex]; 
   BtnText:=mxButton.Caption; 
   if MessageBox(Handle,PChar(Format('你确实要删除 %s 吗?',[BtnText])),PChar(Form1.Caption), 
        MB_ICONWARNING or MB_YESNO	) = IDYES	then 
   begin 
      DelButtonOrHeadFromFile(MyPath+HeaderFileName,HeadStr,BtnText); 
      DelBtnFromBtnFile(MyPath+BtnFileName,BtnText); 
      mxOutlookBarPro1.ActiveHeader.DeleteButton(CurSelButtonIndex); 
   end; 
end; 
 
procedure TForm1.N4Click(Sender: TObject); 
var 
  HeadStr:string; 
  HeaderNum:Integer; 
  i,DelHeadsBtnNum:Integer; 
begin 
   HeadStr:= mxOutlookBarPro1.ActiveHeader.Caption; 
   if MessageBox(Handle,PChar(Format('你确实要删除 %s 吗?',[HeadStr])),PChar(Form1.Caption), 
        MB_ICONWARNING or MB_YESNO	) = IDYES	then 
   begin 
      DelHeadsBtnNum:=mxOutlookBarPro1.ActiveHeader.ButtonCount; 
      if DelHeadsBtnNum<>0 then 
      begin 
          for i:=0 to    DelHeadsBtnNum-1 do 
            DelBtnFromBtnFile(MyPath+BtnFileName,mxOutlookBarPro1.ActiveHeader.Button[i].Caption); 
      end; 
      DelButtonOrHeadFromFile(MyPath+HeaderFileName,HeadStr,'',True); 
      mxOutlookBarPro1.DeleteHeader(mxOutlookBarPro1.ActiveHeader.Index); 
      HeaderNum:= mxOutlookBarPro1.HeaderCount; 
      if  HeaderNum<>0 then 
         mxOutlookBarPro1.ActiveHeader:=mxOutlookBarPro1.Header[HeaderNum-1]; 
   end; 
end; 
 
 
procedure TForm1.WMSysCommand(var Msg: TMessage); 
var 
  Pt:TPoint; 
begin 
    if Msg.WParam=SC_MAXIMIZE then 
    begin 
      SendMessage(Handle,WM_NCACTIVATE,0,0); 
      GetCursorPos(Pt); 
      PopupMenu4.Popup(Pt.X,Pt.Y); 
    end 
    else   
      inherited; 
end; 
 
procedure TForm1.N7Click(Sender: TObject); 
var 
  SelButton:TmxButton; 
  HeadStr,OldButtonText:string; 
begin 
   Application.CreateForm(TForm4,Form4); 
   Form4.Caption :='添加文件'; 
   u_MondifyInfo.MondifyHeader:=mxOutlookBarPro1.ActiveHeader; 
   if Form4.ShowModal=1 then 
   begin 
 
   end; 
   u_MondifyInfo.MondifyButton:=NIL; 
end; 
 
Function  IsComponentHandle(MyHwnd:THandle):Boolean; 
var 
buffer: array[0..255] of Char; 
MyClassName:string; 
ParentHwnd:THandle; 
begin 
     Result:=False; 
     ParentHwnd:=GetParent(MyHwnd); 
     if ParentHwnd= Form1.Handle then 
     begin 
        Result:=True; 
        exit; 
     end; 
     if ParentHwnd= Form1.mxOutlookBarPro1.Handle then 
     begin 
        Result:=True; 
        exit; 
     end; 
 
     if MyHwnd=Form1.Handle then 
     begin 
        Result:=True; 
        exit; 
     end; 
     GetClassName(MyHwnd, buffer, 256); 
     MyClassName:= StrPas(Buffer); 
     if MyClassName='TmxOutlookBarPro' then 
     begin 
        Result:=True; 
        exit; 
     end;; 
end; 
 
procedure TForm1.Timer1Timer(Sender: TObject); 
const  
  cOffset = 2; 
var 
  pt:TPoint; 
begin 
    GetCursorPos(pt); 
    if InRect(pt,Form1.BoundsRect)  then 
    begin 
            IsShow:=False; 
            if akLeft in FAnchors then Left := 0; 
            if akTop in FAnchors then Top := -2; 
            if akRight in FAnchors then 
              Left := Screen.Width - Width; 
            if akBottom in FAnchors then 
              Top := Screen.Height - Height; 
     end 
      else 
      begin 
        if IsShow then exit; 
        if akLeft in FAnchors then Left := -Width + cOffset; 
        if akTop in FAnchors then Top := -Height + cOffset; 
        if akRight in FAnchors then 
          Left := Screen.Width - cOffset; 
        if akBottom in FAnchors then 
          Top := Screen.Height - cOffset; 
    end; 
end; 
 
procedure TForm1.N23Click(Sender: TObject); 
begin 
  Close; 
end; 
 
procedure TForm1.CnTrayIcon1DblClick(Sender: TObject); 
begin 
       IsShow:=True; 
       Form1.Top :=-2; 
       Form1.Width:=DefaultWidth; 
       Form1.Height:=DefaultHeigth+2; 
end; 
 
procedure TForm1.N24Click(Sender: TObject); 
begin 
       IsShow:=True; 
       Form1.Top :=-2; 
       Form1.Width:=DefaultWidth; 
       Form1.Height:=DefaultHeigth+2; 
end; 
 
procedure TForm1.N9Click(Sender: TObject); 
var 
  SelButton:TmxButton; 
  HeadStr,OldButtonText:string; 
begin 
   Application.CreateForm(TForm5,Form5); 
   Form5.Caption :='添加超链接'; 
   u_NetSite.MondifyHeader:=mxOutlookBarPro1.ActiveHeader; 
   if Form5.ShowModal=1 then 
   begin 
 
   end; 
end; 
 
procedure TForm1.mxOutlookBarPro1Change(Sender: TObject; OldIndex, 
  NewIndex: Integer); 
begin 
     if not IsUseMusic    then exit; 
     if  OldIndex<> NewIndex then 
     begin 
         sndPlaySound(PChar(MyPath+'Change.wav'),SND_ASYNC); 
     end; 
end; 
 
Function TForm1.CreateSubMenuItem(itemText:string; 
    ItemNum:Integer; 
    MenuItem:TMenuItem; 
    MsgID:Integer):TMenuItem; 
var 
  item:TMenuItem; 
begin 
     Result:=NIL; 
     item:=TMenuItem.Create(MenuItem); 
     item.Caption :=itemText; 
     Item.Tag:=WM_USER+MsgID; 
     if MsgID>=0 then 
         item.OnClick:=ScriptClick; 
     MenuItem.Insert(ItemNum,item); 
     Result:= item; 
end; 
 
procedure TForm1.ScriptClick(Sender: TObject); 
var 
  ItemText:string; 
begin 
  ItemText:=Trim(TMenuItem(Sender).Caption); 
  SkinData1.SkinFile:=MyPath+sknFile+ItemText; 
  CurSkn:=ItemText; 
  SaveCfgFile(MyPath+CfgFileName); 
end; 
 
procedure TForm1.SpeedButton1Click(Sender: TObject); 
begin 
    if Form6=NIL then 
      Application.CreateForm(TForm6,Form6); 
    Form6.ShowModal; 
end; 
 
 
 
procedure TForm1.N8Click(Sender: TObject); 
begin 
   // mxOutlookBarPro1.ActiveHeader; 
end; 
 
end.