打印本文 打印本文 关闭窗口 关闭窗口
DELPHI基础开发技巧
作者:武汉SEO闵涛  文章来源:敏韬网  点击数3989  更新时间:2009/4/23 18:31:02  文章录入:mintao  责任编辑:mintao
p;  Result := GetWinFlags;
      {$ENDIF}
    end;
    procedure TForm1.Button1Click(Sender: TObject);
    begin
      edit1.Text:=inttostr(gethdserialnumber);
    end;
(19).限定光标移动范围。
    procedure TForm1.Button1Click(Sender: TObject);
    var
    rect1:trect;
    begin
      rect1:=button2.BoundsRect;
      mapwindowpoints(handle,0,rect1,2);
      clipcursor(@rect1);
    end;
    procedure TForm1.Button2Click(Sender: TObject);
    var
    screenrect:trect;
    begin
      screenrect:=rect(0,0,screen.Width,screen.Height);
      clipcursor(@screenrect);
    end;
(20).限制edit框只能输入数字。
    procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
    begin
      if not (key in [''''0''''..''''9'''',''''.'''',#8]) then
      begin
        key:=#0;
        Messagebeep(0);
      end;
    end;
(21).dbgrid中根据任一条件某一格变色。
    procedure TForm_main.DBGridEh1DrawColumnCell(Sender: TObject;
    const Rect: TRect; DataCol: Integer; Column: TColumnEh;
    State: TGridDrawState);
    begin
      if (trim(DataModule1.ADOQuery1.FieldByName(''''dczt'''').AsString)=''''OK'''') then
      begin
        if datacol=6 then
        begin
          DbGrideh1.Canvas.Brush.Color:=clGradientActiveCaption;
          DbGrideh1.DefaultDrawColumnCell(Rect,datacol,column,state);
        end;
      end;
    end;
(22).打开word文件。
    procedure TfjfsglForm.SpeedButton4Click(Sender: TObject);
    var
    MSWord: Variant;
    str:string;
    begin
      if trim(DataModule1.adoquery27.fieldbyname(''''fjmc'''').asstring)<>'''''''' then
      begin
        str:=trim(DataModule1.ADOQuery27.fieldbyname(''''fjmc'''').AsString);
        MSWord:= CreateOLEObject(''''Word.Application'''');//
        MSWord.Documents.Open(''''d:\Program Files\Common Files\Sfa\''''+str, True);//
        MSWord.Visible:=1;//
        str:='''''''';
        MSWord.ActiveDocument.Range(0, 0);//
        MSWord.ActiveDocument.Range.InsertAfter(str);//?úWord?D???ó×?·?''''Title''''
        MSWord.ActiveDocument.Range.InsertParagraphAfter;
      end
      else
      showmessage('''''''');
    end;
(23).word文件传入和传出数据库。
    uses IdGlobal;
    procedure TdjhyForm.SpeedButton2Click(Sender: TObject);
    var
    sfilename:string;
    function BlobContentTostring(const Filename:string):string;
    begin
      with Tfilestream.Create(filename,fmopenread)  do
      try
        setlength(result,size);
        read(pointer(result)^,size);
      finally
        free;
      end;
    end;
    begin
      if opendialog1.Execute then
      begin
        sfilename:=opendialog1.FileName;
        DataModule1.ADOQuery14.Edit;
        DataModule1.ADOQuery14.FieldByName(''''word'''').AsString:=blobcontenttostring(sfilename);
        DataModule1.ADOQuery14.Post;
      end;
    end;
    procedure TdjhyForm.SpeedButton1Click(Sender: TObject);
    var
    sfilename:string;
    bs:Tadoblobstream;
    begin
      bs:=Tadoblobstream.Create(TBLOBfield(DataModule1.ADOQuery14.FieldByName(''''word'''')),bmread);
      try
        sfilename:=extractfilepath(application.ExeName)+trim(DataModule1.adoquery14.fieldbyname(''''hybh'''').AsString);
        sfilename:=sfilename+''''.''''+''''doc'''';
        bs.SaveToFile(sfilename);
        try
          djhyopenform:=Tdjhyopenform.Create(self);
          djhyopenform.olecontainer1.CreateObjectFromFile(sfilename,false);
          djhyopenform.OleContainer1.Iconic:=true;
          djhyopenform.ShowModal;
        finally
          djhyopenform.Free;
        end;
      finally
        bs.free;
      end;
    end;
(24).中文标题的提示框。
    procedure TdjhyForm.SpeedButton5Click(Sender: TObject);
    begin
      if Application.MessageBox('''''''', Mb_YesNo + Mb_IconWarning) =Id_yes then DataModule1.ADOQuery14.Delete;
    end;
(25).运行一应用程序文件。
    WinExec(''''HH.EXE D:\Program files\common files\MyshipperCRM e-sales help\MyshipperCRM e-sales help.chm'''',SW_NORMAL);


上一页  [1] [2] [3] [4] [5] [6] [7] 

打印本文 打印本文 关闭窗口 关闭窗口