var classID: TCLSID; sOLEObject: string; bIsSupport : boolean; begin { is installed ? } sOLEObject := 'Microsoft.DirectMusic.1'; bIsSupport := CLSIDFromProgID( PWideChar( WideString( sOLEObject ) ), classID ) = S_OK; if bIsSupport then ShowMessage( 'Supported.' ); ...
Microsoft AX 2012, X++, C#, SQL server, SSRS, Java, JavaFX, Oracle, PL/SQL, Delphi - codes examples, step-by-step tutorials, experiences.
Thursday, April 19, 2018
DELPHI - How check if OLE library is installed on client
When you use some special OLE object, you can check, if is installed on client (Winapi.ActiveX):
AX - How to work with advanced filters (..with sql where condition)
When you need some special filters, especially in relation to another field(s) from table, you can write directly sql where code.
This example shows all production orders, where difference between Delivery date and End date is 10 days:
This example shows all production orders, where difference between Delivery date and End date is 10 days:
Wednesday, April 18, 2018
SQL SERVER - How and why use "N" prefix for unicode strings
N prefix before string takes string as unicode (without N is string converted to DB codepage). It is useful for some special chars in some alphabets.
select 'Počty vzrůstajících kusů' as description
union all
select N'Počty vzrůstajících kusů'
Output: description ------------------------ Pocty vzrustajících kusu Počty vzrůstajících kusů (2 row(s) affected)
Tuesday, April 17, 2018
DELPHI - How to create new directory (..and check if directory exists)
var sBackupPath : string; begin ... sBackupPath := gsExePath + gcsDictionarySubDir; { check if not exists } if not DirectoryExists( sBackupPath ) then begin { try to create new directory } b := ForceDirectories( sBackupPath ); if not b then begin ShowMessage( 'Backup directory cannot be created.' ); exit; end; end; ...
Thursday, April 12, 2018
DELPHI - How to make tray icon with WIN API support only (without TTrayIcon)
trayIconData : TNotifyIconData; ... { add icon } with TrayIconData do begin cbSize := sizeOf( trayIconData ); Wnd := Handle; uID := 0; uFlags := NIF_MESSAGE + NIF_ICON + NIF_TIP; uCallbackMessage := WM_ICONTRAY; hIcon := Application.Icon.Handle; StrPCopy( szTip, self.Caption ); end; Shell_NotifyIcon( NIM_ADD, @TrayIconData );And callback procedure:
procedure TFMain.WMIconTray( var msg : TMessage ); var pt : TPoint; begin case msg.lParam of { popup menu } WM_RBUTTONDOWN: begin GetCursorPos( pt ); PopupTray.Popup( pt.x, pt.y ); end; { doubleclick } WM_LBUTTONDBLCLK : begin MPopup_NextClick( nil ); end; { mouse over } WM_MOUSEMOVE : begin self.Caption := gcsTitle + GetNextWordTime; with TrayIconData do begin StrPCopy( szTip, self.Caption ); uFlags := NIF_TIP; Shell_NotifyIcon( NIM_MODIFY, @TrayIconData ); end; end; end; end;And removing after destroy:
procedure TFMain.FormDestroy(Sender: TObject);
begin
...
Shell_NotifyIcon( NIM_DELETE, @trayIconData );
end;
Output:Wednesday, April 11, 2018
AX - How to round values
Second parameter from round() function define how will be rounded.
real iValue = 15.5678532; real iResult1, iResult2; // round to 0.1 iResult1 = round( iValue, 0.1 ); // round to all number */ iResult2 = round( iValue, 1 ); info( num2str( iResult1, 15, 2, 1, 0 ) + " - " + num2str( iResult2, 15, 2, 1, 0 ) );Output:
15.60 - 16.00
DELPHI - How to make rotation of shape around point
Suppose this easy class for shape - triangle:
TShape = class( TObject ) p1 : TPoint; p2 : TPoint; p3 : TPoint; procedure Moving( _iDeltaX, _iDeltaY : integer ); procedure Rotation( _iAngle : integer ); procedure RotationAroundXY( _x, _y : integer; _iAngle : integer ); end;And initialization:
pShape := TShape.Create; pShape.p1.X := 300; pShape.p1.Y := 250; pShape.p2.X := 250; pShape.p2.Y := 280; pShape.p3.X := 350; pShape.p3.Y := 330;For rotation shape around point use this code:
procedure TShape.RotationAroundXY( _x, _y : integer; _iAngle : integer ); var iNewX, iNewY : integer; dCos, dSin : double; dRadian : double; p1x, p1y, p2x, p2y, p3x, p3y : integer; begin { -- angle } dRadian := ( 2 * pi ) / ( 360 / _iAngle ); dCos := cos( dRadian ); dSin := sin( dRadian ); { -- point for rotation around (in other case the rotation is around start of coords) } p1x := p1.x - _x; p1y := p1.y - _y; p2x := p2.x - _x; p2y := p2.y - _y; p3x := p3.x - _x; p3y := p3.y - _y; { -- calculation of the positions } iNewX := round( ( p1x * dCos ) - ( p1y * dSin ) ); iNewY := round( ( p1y * dCos ) + ( p1x * dSin ) ); p1.X := iNewX + _x; p1.Y := iNewY + _y; iNewX := round( ( p2x * dCos ) - ( p2y * dSin ) ); iNewY := round( ( p2y * dCos ) + ( p2x * dSin ) ); p2.X := iNewX + _x; p2.Y := iNewY + _y; iNewX := round( ( p3x * dCos ) - ( p3y * dSin ) ); iNewY := round( ( p3y * dCos ) + ( p3x * dSin ) ); p3.X := iNewX + _x; p3.Y := iNewY + _y; end;Output:
Tuesday, April 3, 2018
JAVA, JAVAFX - listener and lambda expression
Since JDK 1.8 you can use lambda expression. This article compares old and new variants on one example with CheckBox listener.
Old variant (response for change in CheckBox):
Both variant have same result:
Old variant (response for change in CheckBox):
@FXML CheckBox checkbox1; @FXML Label label1; @Override public void initialize( URL url, ResourceBundle rb ) { /* variant without lambda expression */ checkbox1.selectedProperty().addListener( new ChangeListener< boolean >() { @Override public void changed( ObservableValue observable, Boolean oldValue, Boolean newValue ) { label1.setText( newValue.toString() ); } } ); /* -- init */ checkbox1.selectedProperty().set( true ); }And new (optional - old variant is still working) with lambda expression:
@FXML CheckBox checkbox1; @FXML Label label1; @Override public void initialize( URL url, ResourceBundle rb ) { /* variant with lambda expression */ checkbox1.selectedProperty().addListener( ( ObservableValue observable, Boolean oldValue, Boolean newValue ) -> { label1.setText( newValue.toString() ); } ); /* -- init */ checkbox1.selectedProperty().set( true ); }
Both variant have same result:
SSRS - How disable fitting chart axis (..to more columns)
Sometimes SSRS chart left axis is fitted to more columns.
For solving that, set left axis property LabelsAutoFitDisabled to true.
For solving that, set left axis property LabelsAutoFitDisabled to true.
SQL SERVER - How get database instance version
print @@versionOutput:
Microsoft SQL Server 2014 (SP2-GDR) (KB4019093) - 12.0.5207.0 (X64) Jul 3 2017 02:25:44 Copyright (c) Microsoft Corporation Express Edition (64-bit) on Windows NT 6.3(Build 9600: ) (Hypervisor)
Subscribe to:
Posts (Atom)