Delphi own collection

zhaozj2021-02-16  63

[Keyword: Delphi, ADO, Access] [ado.connectionstring: = 'DBQ = dbpath' '; driver = {Microsoft Access Driver (* .mdb)}; uid = admin; pwd = _c1b9b6g! 6'] [keyword: delphi, TStream, FileReadWrite] [procedure TForm1.btnReadFileClick (Sender: TObject); var FileStream: TfileStream; myWriter: TWriter; i: integer; strPath: string; begin strPath: = 'd: /test.txt'; FileStream: = TFileStream.create (STRPATH, FMOENWRITE); MyWriter: = twriter.create (FileStream, 1024); MyWriter.writelistBegin; for i: = 0 to memo1.lines.count-1 do mywriter.writestring (Trim (Trim (Memo1.Lines [i ]) CHR (13) CHR (10)); MyWriter.writelistend; FileStream.seek; MyWriter.Free; FileStream.free; showMessage ('ok'); end;

procedure TForm1.Button1Click (Sender: TObject); var FileStream: TfileStream; MyReader: TReader; i: integer; strPath: string; begin strPath: = 'd: /test.txt'; FileStream: = TfileStream.Create (strPath, fmOpenRead ); MyReader: = TReader.Create (fileStream, 1024); memo1.Lines.Clear; Myreader.ReadListBegin; while not MyReader.EndOfList do begin memo1.Lines.Add (MyReader.ReadString); end; myReader.ReadListEnd; MyReader. Free; FileStream.free; showMessage ('Okok');

procedure TForm1.btnReadPicClick (Sender: TObject); Var Source, TarGet: TfileStream; MyFileSize: integer; strFN, strFN2: string; begin strFN: = 'd: /logo.jpg'; strFN2: = 'd: /test.dat '; Source: = TfileStream.Create (strFN, fmOpenRead); TarGet: = TfileStream.Create (strFN2, fmOpenWrite); TarGet.Seek (0, sofromEnd); TarGet.CopyFrom (source, 0); MyFileSize: = Source.Size ; TarGet.WriteBuffer (MyfileSize, sizeof (MyfileSize)); TarGet.Free; Source.Free; ShowMessage ( 'ok'); end; procedure TForm1.WritePicClick (Sender: TObject); Var Source, TarGet, f: TfileStream; MyFileSize , isize: integer; strfn, strfn2, strfn3: string; begin strfn: = 'd: /1.dat'; strfn2: = 'd: /test.dat'; strfn3: = 'D: /LOGO.JPG'; f: = TFileStream.Create (strFN3, fmOpenRead); iSize: = f.Size; Source: = TfileStream.Create (strFN2, fmOpenRead); TarGet: = TfileStream.Create (strFN, fmOpenWrite); TarGet.Seek (iSize, soFromBeginning ); Target.copyfrom (source, isize); target.writebuffler (isize, sizeof (isize)); target.free; SOURGET.FREE; ShowMessage ('ok'); end;] [keYwor d: Delphi, Dll, CreateUse] [{Create Dll} library ProjDll; uses SysUtils, Classes, Dialogs; {$ R * .res} function functionname (): type; stdcall; begin end; procedure procedurename (): type; stdcall Begin end;

Exports functionName; ProcedureName;

Begin

. End {Use Dll} procedure procedurename (): type; type Tfname: = function (): type; stdcall; Tpname: = procedure (): type; stdcall; var H: Thandle; fname: Tfname; begin H: = LoadLibrary ('dllname'); @fname: = getProcaddress (h, 'fname'); // user fname freelibrary (h)

end;] [KeyWord: Delphi, Api, RunProgram] [ShellExecute ();] [KeyWord: Delphi, Word, Doc] [Unit: Word2000, OleServer; component: WordApp: TWordApplication; WordDoc: TWordDocument; WordApp.Documents.open ( WordDoc.connectto (Wordapp.Documents.Item (Docinx)); Wordapp.Visible: = true; WordDoc.Tables.Item (1) .Cell (4, 1) .range.text: = 'Hello Science'; WordDoc .Tables.item (1) .Rows.add (emptyparam); Finally if Assigned (WordDoc) Then Begin WordDoc.close; WordDoc.disconnect; WordDoc.free; WordDoc: = NIL; End; if Assigned (WordApp). WordApp. Wordapp.disconnect; Wordapp.Free; WordApp: = nil; end;] [Keyword: Delphi, Excel, XLS] [Unit: Excel2000, Oleserver, Comobj; Var Sheet, XLAPP, Workbook: Variant; Irow, Maxrow, i : integer; begin //screen.cursor :=Crhourglass;

// Create an object xlapp: = createoleObject ('Excel.Application'); xlapp.displayalerts: = false; xlapp.screenupdating: = false; xlapp.workbooks.add ('d: /book1.xls'); workbook: = xlapp .workbooks [1]; Sheet: = Workbook.works Heets [1]; xlapp.activecell.specialcells (xllastcell) .select; maxrow: = xlapp.activecell.row; showMessage (INTTOSTR (Maxrow); for i: = 2 to Maxrow Do ShowMessage (Sheet.cells [i, 1]);

] [Keyword: Display, MH] [Function getDisplayFrequency: Integer; Var DeviceMode: TDEviceMode; // This function returned to the refresh rate is BeGin EnumdisplaySettings (NIL, Cardinal (-1), DeviceMode) in Hz. Result: RESULT: = DeviceMode.dmdisplayFrequency; END;

] [Keyword: Mouse, NOTITLE, MAX, MIN] [

constSC_DRAGMOVE: Longint = $ F012; beginReleaseCapture; SendMessage (Handle, WM_SYSCOMMAND, SC_DRAGMOVE, 0);] [KeyWord: File, TextFile, AssignFile, Append] [// Open a file, Append content procedure WriteErrInfo (strErrInfo: string); var strFileName: string; F: TextFile; begin strFileName: = ExtractFilePath (application.ExeName) 'ErrLog.txt'; AssignFile (F, strFileName); Append (F); WriteLn (F, strErrInfo); Close (F); end ;] [Keyword: getCount, Letter] [// Return Count, Strmark In Strv // Must Give STRV, STRMARKFunction Getmarkcount (strmarkfunction getmarkcount): Integer; Var i, count: integer; begin i: = POS (strmark) , STRV); count: = 0; While i <> 0 do begin delete (STRV, 1, I); i: = POS (strmark, strv); count: = count 1; end; result: = count; End; ;] [Keyword: Array, Mark, Split] [// Split STRV to Array // STRMARK THE SPLITING MARK // Arytemp The Value // CAN Use 'getmarkcount ()' firstly // THEN USE SETLENGTH () Difine Array; // Put Arytemp Into ProcedureProcedure Splittoary (STRV, STRMARK: STRING; VAR ARYTEMP: Array Off); VAR POS1, I: Integer; Arylen: Integer; Begin // First assured // ShowMessage (Intench)); for i: = 0 to high (arytemp) do Arytemp [i] : = '';

// Get the position of the first division POS1: = POS (Strmark, STRV); // The value of the first element // strmark is Chinese characters Arytemp [0]: = COPY (STRV, 1, POS1 1); / / For strmark is Chinese characters // Arytemp [0]: = COPY (STRV, 1, POS1-1); i: = 1; // If there is a split symbol, delete the previous character // When i is not subscript Then exit cycle // If the split is not the last character //, deposit the last string into the last element while Pos1 <> 0 do begin // strmark is Chinese characters delete (STRV, 1, POS1 1); / / For e-text characters // delete (STRV, 1, POS1 1); STRV: = Trim (STRV); POS1: = POS (Strmark, STRV); if i> high (arytemp) Then Break; // Strmark is Chinese characters if Copy (STRV, 1, POS1 1) <> 'Then Begin Arytemp [I]: = COPY (STRV, 1, POS1 1); i: = i 1; end; // strmark is e Text characters {if copy (STRV, 1, POS1-1) <> 'Then Begin Arytemp [i]: = COPY (STRV, 1, POS1-1); i: = i 1; end;} end; if STRV <> '' TEN ARYTEMP [High (AryTemp)]: = STRV; END;

] [Keyword: Close, Message, Se] [SendMessage (Handle, WM_Close, 0, 0);] [Keyword: API, EXE, Window] [FindWindowEx () // Find A Window of Exe FindWindow () // Same Winexec (); // Run a Exe Programer Windows.SetParent () // set a window into another window for son window setwindowpos () // Play a window in position

] [KeyWor: Pointer, ^, @, address] [var P: ^ integer //p is a pointer pionted integer x: integer; begin p: = @ x // Get x's address, give it to pp ^: = 100 // x = 100

END;

] [KeyWord: display, HZ, Screen, EnumDisplaySettings, ChangeDisplaySettings] [procedure TForm1.Button1Click (Sender: TObject); var lpDevMode: TDeviceMode; begin // back to the original setting EnumDisplaySettings (nil, Cardinal (-1), lpDevMode) ; lpDevmode.dmPelsWidth: = x; lpDevmode.dmPelsHeight: = y; lpDevMode.dmDisplayFrequency: = displayHZ; ChangeDisplaySettings (lpDevMode, 0); end; procedure TForm1.FormCreate (Sender: TObject); var DeviceMode: TDeviceMode; // this function The returned display refresh rate is Begin / / obtained in Hz, which is the original resolution, refresh rate enumdisplaySettings (NIL, Cardinal (-1), DeviceMode; displayHz: = DeviceMode.dmdisplayFrequency; x: = screen.width; y : = Screen.height; End;

procedure TForm1.FormShow (Sender: TObject); var lpDevMode: TDeviceMode; begin // change to change the resolution lpDevmode.dmFields: = DM_PELSWIDTH or DM_PELSHEIGHT; lpdevmode.dmPelsWidth: = 800; lpdevmode.dmPelsHeight: = 600; ChangeDisplaySettings (lpDevMode, 0 ) end;] [KeyWord: Delphi, Dll, Filter, IIS, IIS Apllcation GetFilterVersion, HttpFilterProc] [// registered version, and event information function GetFilterVersion (Var pVer: THTTP_FILTER_VERSION): BOOL; stdcalbegin pVar.dwFlags: = (SF_NOTIFY_NONSECURE_PORT or SF_NOTIFY_SEND_RAW_DATA OR sf_notify_order_default or sf_notify_end_of_request // $ 80) // Register Processing Event // Security Port, Send Data, Lacking Authentication, End Request PVER.DWFILTERVSITION: = HTTP_FILTER_REVISION; // Filter Version Description PVER.LPSZFILTERDESC [0]: = 'a '; Perver.lpszfilterDesc [1]: = # 0; // the location in which to store a short string description // filter Description of the ISAPI Filter Application // Filter Result: = true; // Returns true END;

function HttpFilterProc (var pfc: THTTP_FILTER_CONTEXT; Notificationtype: DWORD; pvNotification: Pointer): DWORD; stdcall; varp: PHTTP_FILTER_RAW_DATA; // a PHTTP_FILTER_RAW_DATA structure pointer i: integer; pc: pchar; begin if Notificationtype = SF_NOTIFY_END_OF_REQUEST then begin // If the time is the end request, the pointer of the storage context information is empty pfc.pfilterContext: = nil; end else begin // Pointer Pointing Pointer P: = phttp_filter_raw_data (notificationType); // pvindata [in] A PC: = P ^ .pvindata; //pfc.pfiltercontext // a Pointer to be used by the filter for any context // information That the filter wants to associate with // this . request Any memory associated with this request // can be safely freed during the SF_NOTIFY_END_OF_NET_SESSION notification case integer (pfc.pFilterContext) of 0: // first call, to check the mime begin pfc.pFilterContext: = pointer (2);. // Pointer I: = 0; // cbinbuffer [in] the size of the buffer pointed to // by pvind Ata. Whilte I

End; end; end; result: = sf_status_req_next_notification; // Always return success, and if there is any other filter, continue call // the next filter in the notification chain shop be caled.end;] [keyword: SQLServer , SQL, TABLENAME] [// Get Table's Name Select Name from sysobjects where xtype = 'u'] [Keyword: Win98, System, SFC] [// SFC Command // Run-> SFC // Cack System File, Then Repire it; SFC

] [Keyword: Delphi, Form] [// Transparent Form 1. New project; 2. Place an Image control on the window and transfer to a picture, as shown, image1.autosize: = true; 3. Form1.autosize: = true; form1.oldcreateOrder: = true; form1.transparentColor: = true; form1.transparentColorValue: = CLWHITE (Because the edge of this picture is white); 4. Ok, you can see a transparent window if you are set to bsnone, which is the shaped window.

] [Keyword: JavaScript, JS, SELECT, OPTION] [// alert option's value var i = form.select.selectedIndIndex; // for (i; i; i

] [Keyword: Delphi, Property, Set, Get, Set, Get] [Unit Myclass; Interface Uses Windows, Messages, Sysutils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Stdctrls, Menus

type TmyClass = class private myValue: string; function GetStrcon (): string; procedure SetStrCon (const Value: string); public property StrCon: string read GetStrCon write SetStrcon; end; var strC: string; implementation uses unit3; procedure TmyClass.SetStrCon (const value: string); begin myvalue: = value; end; function TMYCLASS.GETSTRCON (): string; begin result: = myValue; end;] [keyword: delphi, format, string] [headlight format (const format: String; constrays: array of const): String; $ [sysutils.pas feature Returns the character form of formatting a array constant in the specified mode Description This function is the most used function in Delphi, and now list several examples Give you an intuitive understanding "%" [index ":"] ["-"] [width] ["." Summary] type Format ('x =% d', [12]); // 'x = 12 '// Most normal format (' x =% 3D ', [12]); //' x = 12 '// Specify the width Format (' x =% f ', [12.0]); //'x=12.00 '// floating point Format (' x =%. 3F ', [12.0]); //' ==12.000 '// Specify decimal format (' x =%. * F ', [5, 12.0]); / / 'X =%. 5D', [12]); // 'x = 00012' // The front supplement 0Format ('x =%. 5x', [12]) ; // 'x = 0000c' // hex Format ('x =% 1: D% 0: D', [12, 13]); // 'x = 1312' // Using Index Format (' X =% P ', [NIL ]); // 'x = 00000000' // Pointer Format ('x =% 1.1e', [12.0]); // '=1.2e 001' // Scientific counting method Format ('x =% % ', []); //' x =% '// Get "%" S: = Format ('% s% d ', [s, i]); // s: = s start (i) ; // Connecting string reference proceduer sysutils.fmtstr example edit1.text: = format (edit2.text, [strtofloatdef (edit.3.text, 0)]);

] [Keyword: SQL, RENAME, Cloumn] [exec sp_rename 'mytable. [Id]', 'myid', 'column'] [keyword: SQL, DELETE, TABLE, TRUNCATE] [Truncate Table Company16400] [Keyword: SQL, Cursor] [Declare Cursorname Cursor for Select Statement Open CURSORNAME FETCH NEXT from Cursorname INTO @Myvaialbe While @@ fetch_status = 0 Begin Fetch next from cursorname Into @myvaialbend;

] [SQL, Proc, Procedure, Create] [CREATE PROC [DURE] Procedure_name [; Number] [@Parameter_name] [OUTPUT] [, _N]] [with {recompile | encryption}] [for replication] as number is used The process of grouping the same name is integrated. The group is to combine all the processes into one group through the Drop Procedure statement. @Parameter_name Specifies the name of the parameter. Recompile indicates compilation of each execution process. Encryption The text of the process is encrypted in the "SysComments" table. The for Replication indicates that the process cannot be executed on the submission server. ] [KeyWord: sql, trigger, database, db, sqlserver, create] [CREATE TRIGGER CREATE TRIGGER trig2 ON authorsFOR INSERT, UPDATEAS DECLARE @fax varchar (12) SELECT @fax = phone FROM authorsGO] [Keyword: Delphi, String, Int , Strtointdef;] [n = startDef (string, defalUTNuMerber); // n = startDef ('12345', 0) // n = 12345 // n = startdef ('ttt', 0) // n = 0

]

[Keyword: Delphi, StringGrid, stringgrid] [var r: TRECT; org: tpoint; begin with sender as tstringgrid do begin Perform (WM_CANCELMODE, 0, 0); R: = CellRect (acol, arow); org: = Self. ScreenToClient (CLIENTSCREEN (R.Topleft); with cmbhagin setbounds (org.x, org.y, r.right - r.left, height); itemindex: = items.indexof (cells [acol, all); show; BringTofront; SetFocus; DroppedDown: = true; end; end; TempRect: = StringGrid.CellRect (ACol, aRow); TempRect.Left: = TempRect.Left StringGrid.Left; TempRect.Right: = TempRect.Right StringGrid TempRect.top:=TemPRect.top StringGrid.top; TempRect.Bottom: = TempRect.bottom stringGrid.top; with cmb Do Begin Left: = TempRect.Top 1; Top: = TempRect.top 1 Width: = (TempRect.Right 1) -Left; Height: = (TempRect.bottom 1) -top; visible: = true; setfocus; end;] [OnGetText () Event location Double-click AdoQuery, appear box , Right-click Add All Fields and select a Field, there is getText () in its event to write] [Keyword: Delphi, PIC, PIC] [IMGIMPORTDA Ta.parent.doublebuffled: = true;] [[ee = true; resource, res] [// Create Tmyrc.rcbg rcdata "bg.jpg" BG_BLUE RCDATA "BG_BLUE.JPG" BG_YELLOW RCDATA "BG_YELLOW.JPG" // builder / /BRCC32.EXE TMYRC.RC / / GET TMYRC.RC // in Delphi {$ r * .dfm} {$ R TMYRC.RES} Var S: TSTREAM; P: TJPEGIMAGE; Begin S: = TRESOURCESTREAM.CREATE (0, 'Bg_yellow', rt_rcdata); p: = tjpegimage.create; p.LoadFromstream (s); image1.picture.assign (p); p.free; s.free;

] [Keyword: Delphi, Task Bar, Stop] [Protected Procedure CreateParams; Override; . . .

procedure T **** Form.CreateParams (Var Param: TCreateParams); begin Inherited CreateParams (Param); Param.wndParent: = GetDesktopWindow; end; procedure CreateParams (var Params: TCreateParams); override;

Procedure TMYFORM.CREATEPARAMS (VAR params: tcreateparams); begin inherited; params.exStyle: = params.exstyle or ws_ex_appwindow;

Setwindowlong (Handle, GWL_EXSTYLE, GETWINDOWLONG (Handle, GWL_EXSTYLE) or WS_EX_APPWINDOW);

Protected Procedure CreateParams (Var params: TcreateParams); OVERRIDE;

Procedure tform1.createparams (var params: tcreateparams); begin inherited; params.wndparent: = getDesktopwindow;

] [Keyword: Delphi, String, Matching] [Function TFRMCATSEARCH.ISINCLUDE (STRBLANK, STRV: STRING): Bool; Var Strmark, Strtemp: String; BLNINCLUDE: BOOL; NPOS: INTEGER; Begin Strmark: = '; NPOS: = POS (strMark, strark); blninclude: = true; while npos> 0 do begin straTemp: = copy (strblank, 1, npos); blninclud: = blninclude and (pOS (Trtemp), STRV)> 0); IF not blninclude dam result: = false; end; delete (strblank, 1, npos); npos: = POS (Strmark, strark) end; if strark <> '' Then Result: = BLNINCLUDE AND (POS (Trim " ), STRV)> 0) Else Result: = BLNINCLUDE; END;

] [DELPHI, WORD, DRAWTEXT] [CMB.canvas.FillRect (Rect); DrawText (CMB.canvas.Handle, Pchar (STR), - 1, Rect, DT_WordBreak);] [Delphi, ComboBox, Stye] [csdropdownlist, The project cannot be written in CSOWNERDRAWVARIABLE, change the Item size DrawItem item content MeasureItem Settings Item Height

] [Delphi, combobox, select sub procedure Tform1.cmbWndProd (var Message: TMessage); begin if Message.Msg = WM_CTLCOLORLISTBOX then begin nSelect: = SendMessage (cmb.Handle, CB_GETCURSEL, 0, 0); if nSelect> 0 then Label1.caption: = StringReplace (s.strings [nselect], '[', '[' # 13 # 10, [RFREPLACEALL]); ELSE mycmdwndproc (message); end;] [keyword: Delphi, Draw, Pic, BMP, StringGrid] [if arow = 0 THEN DRAWTILE ELSE BEGIN STRV: = stringgrid.cells [acol, arow]; bmp: = tbitmap.create; bmp.loadfromfile ('d: /1.bmp'); stringgrid.canvas. FillRect (Rect); stringgrid.canvas.draw (Rect.LEFT, RECT.TOP, BMP); stringgrid.canvas.brush.style :=bsclear; stringgrid.canvas.textout (Rect.canvas.Textout (Rect.Canvas.Textout (Rect.ch 2, Rect.top 2 STRV);

END;

] [KeyWord: delphi, transparent, richedit, control] [Procedure ClearRichEdit (var Message: TMessage); form_create //Self.RichedtWnd:=Self.RichEdit.WindowProc; //Self.RichEdit.WindowProc:=Self.ClearRichEdit; / /SetWindowlong (RichEdit.Handle, GWL_EXSTYLE, //GetWindowlong (RichEdit.handle, GWL_EXSTYLE) or WS_EX_TRANSPARENT); Procedure TFRMDetail.clearrichedit (Var Message: tMessage); Begin

if Message.Msg = WM_ERASEBKGND then Message.Result: = 1 else if (Message.Msg = CN_CTLCOLORMSGBOX) or (Message.Msg = CN_CTLCOLORSTATIC) then begin bb: = null; Message.result: = bb end else Self.RichedtWnd (Message );

END;

] [Keyword: Delphi, Chinese characters] [STRV: = Copy (Edit1.Text, 3, 1); if ISDBCSLEADBYTE (ORD (STRV [1])) Then ShowMessage ('NOT IS') ELSE ShowMessage ;

] [Keyword: Delphi, QRT, Report, Folding] [// Folded Procedure TFORM1.ADOTABLETABLETERPRISEGETTEXT (Sender: Tfield; Var Text: STRING; WIDESTRING; begin strv: wideString; Sender.dataset.fieldValues ​​['Enterprise']; Insert (# 13 # 10, strv, 10); text: = STRV; END;

] [] [] [$ 00F4F0F2

Decades if the Grid has a scroll bar?

IF (stringgrid1.handle, gwl_style) and ws_vscroll) <> 0 THEN

ShowMessage ('Vertical Scrollbar is Visible!');

IF (stringgrid1.handle, gwl_style) and ws_hscroll) <> 0 THEN

ShowMessage ('Horizontal Scrollbar is Visible!');

StringGrid AutoSize ... AutoSize A StringGrid-Column To Fit ITS Content?

{1.}

Procedure setgridcolumnwidths (grid: tstringgrid;

Const columns: array of integer;

{

When You Double-Click on a column-header the column

AutoSizes to Fit ITS Content

BEI Doppelk Auf Eine Fixierte Spalte Passt Sich

DIE Spaltenbreite der textgr? SSE AN

}

Procedure autosizegridcolumn (grid: tstringgrid; column, min, max: integer);

{Set for max and min some minimal / maximial value}

{BEI max and min kann eine minimal- resp. Maximalbreite angegeben Werden}

VAR

i: integer;

Temp: integer;

Tempmax: integer;

Begin

TEMPMAX: = 0;

For i: = 0 to (grid.rowcount - 1) DO

Begin

Temp: = Grid.canvas.TextWidth (Grid.cells [Column, I]);

IF TEMP> Tempmax Ten Tempmax: = Temp;

IF Tempmax> max life

Begin

Tempmax: = max;

Break;

END;

END;

IF Tempmax

Grid.colwidths [column]: = Tempmax Grid.GridLineWidth 3;

END;

Procedure TFORM1.STRINGGRID1DBLCLICK (Sender: TOBJECT);

VAR

P: tpoint;

Icolumn, Irow: longint

Begin

GetCursorpos (P);

With stringgrid1 do

Begin

P: = ScreenToClient (p); MouseTocell (P.x, P.Y, IColumn, IROW);

IF P.Y

AutoSizeGridColumn (StringGrid1, Icolumn, 40, 100);

END;

END;

{***************************************************

{2.}

Procedure TFORM1.BUTTON1CLICK (Sender: TOBJECT);

{by p. below}

Const

DEFBORDER = 8;

VAR

MAX, TEMP, I, N: Integer;

Begin

With grid do

Begin

Canvas.font: = font;

For N: = Low (Column) To High (Column) DO

Begin

Max: = 0;

For i: = 0 to rowcount - 1 do

Begin

Temp: = canvas.textwidth (Cells [Column [N], I]) DEFBORDER;

IF Temp> max life

Max: = TEMP;

End; {for}

IF max> 0 THEN

COLWIDTHS [Column [N]]: = max;

End; {for}

End; {with}

End; {setgridColumnWidths}] [keyword: Delphi, file, file, file attribute] [Try nattr: = filegetttr (filename); if (nattr and fareadonly) = FareadOnly kiln FileSetattr (filename, 0); Result: = 1; ELSE RESULT: = 1; Except Application.MessageBox ('Unable to modify read-only properties, error number 006', PCHAR (WARINGTITLE)); result: = 0; exit; end;] [Keyword: Delphi, property; property, Setting] [UNIT TCLASS;

interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs; type Ttest = Class constructor Create (); protected RCa, Wca: string; public name: string; procedure ChangeT (const Value: string); property CA: String Read Rca Write Change; End; ImplementationConstructor TTest.create (); Begin Rca: = 'Test Now';

End; procedure ttest.changet (const value: string); begin rca: = value 'Hello Science';

. End] [keyWord: delphi, printscreen, screen theme] [id4: Integer; procedure WMHotKey (var Msg: TWMHotKey); message WM_HOTKEY; procedure TForm1.FormCreate (Sender: TObject); begin id4: = GlobalAddAtom ( 'Hotkey4') ; // function adds a character string to the global atom table and returns a // unique value (an atom) identifying the string RegisterHotKey (Handle, id4, 0, VK_SNAPSHOT);. // function defines a hot key for the current thread . end; procedure TForm1.WMHotKey (var Msg: TWMHotKey); begin if Msg.HotKey = id4 then ShowMessage ( '! Print Screen was pressed'); inherited; end; procedure TForm1.FormDestroy (Sender: TObject); begin UnRegisterHotKey ( Handle, ID4); End;] [Keyword: Delphi, DB, JPG, Database, Picture] [VAR S: TMemoryStream; JPG: tjpegimage; begin s: = tmemorystream.create; tblobfield (ds.dataset.fieldbyname ))). SaveTroupTream (s); s.Position: = 0; JPG: = tjpegimage.create; jpg.loadfromstream (s); image1.picture.Assign (JPG);

Var logofilename, T: String; IMGPATH: STRING; I: integer; begin t: = edtdir.text; for i: = 0 to ds.dataset.recordcount-1 do begin imgpath: = ds.dataset.fieldValues ​​['IMGPATH' ]; LogoFileName: = T imgPath; if FileExists (LogoFileName) then begin DS.DataSet.Edit; TBlobField (DS.DataSet.FieldByName ( 'ImgContent')) LoadFromFile (LogoFileName); DS.DataSet.Post; end; DS. .Dataset.moveby (1); end; showMessage ('OVER');

] [Keyword: asp, class] [Dim MyToolboxSet MyToolbox = New CToolboxResponse.Write "UserName:" & MyToolbox.UserName & "
" & vbCrLfResponse.Write "UserPhone:" & MyToolbox.UserPhone & "
" & Vbcrlfset MyToolbox = NothingClass CToolBoxPrivate M_CONN, M_RSPRIVATE M_USERNAME, M_USERPHONE

Public property get usrname () username = m_usernameend property

Public property Get Userphone () Userphone = m_usend proteme

Private Sub Class_Initialize () Set m_conn = Server.CreateObject ( "ADODB.Connection") m_conn.ConnectionString = "Some connection string" m_conn.Open Set m_rs = Server.CreateObject ( "ADODB.Recordset") Set m_rs.ActiveConnection = m_conn m_rs .Open "Select * from users where userid = '" & required.servervariables ("logon_user") & "'" if not m_rs.eof kilns ("username" m_userphone = m_rs.fields ("Userphone" ) End ifend sub

Private sub class_terminate () on error resume next m_rs.close set m_rs = nothing m_conn.close set m_conn = nothingend sub

END CLASS

class TUser private mUserName, mUserPwd 'public UserName, UserPwd public property Get UserName () UserName = mUserName end property public property Let UserName (Byval value) mUserName = value end Property private sub Class_Initialize () mUserName = "aerly"' UserPwd = "123456 "END SUB

Private sub coplass_terminate () end sub * = new tuserauser.username = "ttt" response.write ("Class a.username: auser.username)]

转载请注明原文地址:https://www.9cbs.com/read-20802.html

New Post(0)