Highlights word in a RichView component programmatically:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
uses Winapi.RichEdit; procedure SetTextColor(oRichEdit : TRichEdit; sText : String; rAttributes : TTextAttributes); var iPos : Integer; iLen : Integer; Format: CHARFORMAT2; begin FillChar(Format, SizeOf(Format), 0); Format.cbSize := SizeOf(Format); Format.dwMask := CFM_BACKCOLOR; Format.crBackColor := rAttributes.BackColor; iPos := 0; iLen := Length(oRichEdit.Lines.Text) ; iPos := oRichEdit.FindText(sText, iPos, iLen, []); while iPos > -1 do begin oRichEdit.SelStart := iPos; oRichEdit.SelLength := Length(sText) ; oRichEdit.SelAttributes.Color := rAttributes.Font.Color; oRichEdit.SelAttributes.Size := rAttributes.Font.Size; oRichEdit.SelAttributes.Style := rAttributes.Font.Style; oRichEdit.SelAttributes.Name := rAttributes.Font.Name; oRichEdit.Perform(EM_SETCHARFORMAT, SCF_SELECTION, Longint(@Format)); iPos := oRichEdit.FindText(sText,iPos + Length(sText),iLen, []) ; end; end; |
How to highlitgh full cell in a DBGrid:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
procedure TfrmRuleCreator.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState); var mstr: String; I : Integer; currValue: string; begin currValue := Column.Field.AsString.ToUpper().Trim; if (Length(currValue) > 3)and(Column.Field.FieldName.ToUpper <> 'NOTE') then Begin If FDMemTable1.FieldByName('NOTE').AsString.ToUpper.IndexOf(currValue) <> -1 then Begin DBGrid1.Canvas.Brush.Color := clYellow; End End; if Column.Field.FieldName.ToUpper = 'NOTE' then DBGrid1.Canvas.Brush.Color := $00D7FFD7; DBGrid1.DefaultDrawColumnCell(Rect, DataCol, Column, State); end; |
A reverse proxy is a type of proxy server that accepts HTTP (S) requests and transparently distributes them to one or more backend servers. You can use a reverse proxy to prevent direct access to these underlying application servers. They can also be used to distribute the load of incoming requests to different application servers.…
Read more
Configuring an OpenVPN over pfSense is quite simple. In this video you can see, how to configure a VPN on the lastest release of pfSense using the VPN Wizard.
Configure svn server over Apache2, using https.
1 2 3 4 5 6 7 8 9 10 11 12 |
sudo apt update sudo apt upgrade sudo apt-get install apache2 sudo apt-get install subversion libapache2-mod-svn subversion-tools libsvn-dev sudo a2enmod dav dav_svn sudo service apache2 restart sudo mkdir -p /var/lib/svn/ sudo svnadmin create /var/lib/svn/apprepo sudo chown -R www-data:www-data /var/lib/svn sudo chmod -R 775 /var/lib/svn sudo touch /etc/apache2/dav_svn.passwd |
now let’s set the password of the first user:
1 |
sudo htpasswd -cm /etc/apache2/dav_svn.passwd <username> |
configuriamo gli accessi:
1 |
sudo nano /etc/apache2/mods-enabled/dav_svn.conf |
we configure the accesses to the svn folders
1 |
sudo nano /etc/apache2/dav_svn.authz |
Apache restart:
1 |
sudo service apache2 restart |
TFormatsettings is record type in Delphi which is used to get or set local information’s like DateTimeFormat, CurrencyFormat, DecimalSeparator etc. wich is declared in System.SysUtils. For Example you need to retrive your current DecimalSeparator:
1 2 3 4 5 6 7 |
procedure TForm1.Button1Click(Sender: TObject); var fs: TFormatSettings; begin GetLocaleFormatSettings(LOCALE_SYSTEM_DEFAULT, fs); ShowMessage('Actual decimalseparato is:' + fs.DecimalSeparator); end; |
If you need to force some local settings for conversions you can do for example:
1 2 3 4 5 6 7 8 9 10 11 |
procedure TForm1.Button1Click(Sender: TObject); var myMoney : String; FS : TFormatSettings; myMoneyFloat: Extended; begin myMoney := '100000,66'; FS.DecimalSeparator := ','; myMoneyFloat := StrToFloat(myMoney,FS); ShowMessage('Your actual balance:' + myMoneyFloat.toString); end; |
If you want to…
Read more
How to get record number of dataset using row_number window function with over().
1 2 3 4 |
SELECT row_number() over(), t.* FROM test t |
Example of record number of dataset with even and odd column sorting.
1 2 3 4 5 6 7 8 9 |
SELECT row_number() over(), (CASE WHEN mod(row_number() over(),2) = 0 THEN 'even' ELSE 'odd' END) AS my_column, custom.* FROM ( SELECT t.* FROM test t ORDER BY t.description ) custom |