Android smartphone

2010-06-27

Function WNetConnectionDialog() to map drive.

If WNetConnectionDialog(Handle, RESOURCETYPE_DISK) = NO_ERROR then
begin
     ShowMessage('New connection successfully set.');
end;

Technical review basic map drive

Technical review basic map drive.
Function GetNetworkDriveMappings(SList:TStrings):Integer;

Var
i:Char;
sPath:String;
dwMaxPathLen:DWord;
Begin
     SList.Clear;
     dwMaxPathLen:=MAX_PATH;
     SetLength(sPath,MAX_PATH);
     For I := 'A' to 'Z' Do
     If WNetGetConnection( PChar(''+i+':'),PChar(sPath),dwMaxPathLen)=NO_ERROR Then
          SList.Add(I+': '+sPath);
     Result := SList.Count;
End;

2010-06-17

Scrollbar, hide main form, hide the titlebar, Combobox

[quote=mailto:info@delphitips.comGustav Evertsson]



How can I get a horizontal scrollbar on a list box?

Send a LB_SetHorizontalExtent message to the listbox's window handle.For example, the message could be sent in the form's OnCreate:



procedure TForm1.FormCreate(Sender: TObject);

begin

   SendMessage(Listbox1.Handle, LB_SetHorizontalExtent, 1000, Longint(0));

end;

---------------------------------------------End----------------------------------------------

How to hide the main form ?

If you do not want your program starting up showing your main form, then add this line in your project (DPR) file, just after the Application.Initialize line.



Application.ShowMainForm := False;

---------------------------------------------End----------------------------------------------

How to hide the Titlebar ?

//Here is how to hide the titlebar:

Procedure TYourFormName.HideTitlebar;

Var

  Save : LongInt;

Begin

   If BorderStyle=bsNone then Exit;

   Save:=GetWindowLong(Handle,gwl_Style);

   If (Save and ws_Caption)=ws_Caption then

   Begin

      Case BorderStyle of bsSingle,

      bsSizeable : SetWindowLong(Handle,gwl_Style,Save and

                        (Not(ws_Caption)) or ws_border);

      bsDialog : SetWindowLong(Handle,gwl_Style,Save and

                     (Not(ws_Caption)) or ds_modalframe or ws_dlgframe);

      End;

      Height:=Height-getSystemMetrics(sm_cyCaption);

      Refresh;

   End;

end;

//And here is how we show it again:

Procedure TYourFormName.ShowTitlebar;

Var

  Save : LongInt;

begin

   If BorderStyle=bsNone then Exit;

   Save:=GetWindowLong(Handle,gwl_Style);

   If (Save and ws_Caption)<>ws_Caption then

   Begin

      Case BorderStyle of bsSingle,

      bsSizeable : SetWindowLong(Handle,gwl_Style,Save or

                        ws_Caption or ws_border);

      bsDialog : SetWindowLong(Handle,gwl_Style,Save or

                     ws_Caption or ds_modalframe or ws_dlgframe);

      End;

      Height:=Height+getSystemMetrics(sm_cyCaption);

      Refresh;

   End;

end;

---------------------------------------------End----------------------------------------------

How to make a TComboBox drop?

There is a windows API call to do it.



function SendMessage(Handle of the ComboBox, 1039, 1, 0);

So, if I had a TComboBox that was named LouieCombo, I would use the following code:

Procedure DropCombo(LouieCombo : TComboBox);

var

  ReturnValue : Longint;

begin

   ReturnValue := SendMessage(LouieCombo.Handle, 1039, 1, 0);

end;

---------------------------------------------End----------------------------------------------

[/quote]

2010-06-15

Get all videomodes supported by the system

[quote="zieglersoft@zieglersoft.dkZieglerSoft" ]

procedure GetVideoModes(ModeList: TStringList);
{ proc to retrieve a list of acceptable video modes of the current video card. }
{ **********************************************
Usage:
procedure TForm1.FormCreate(Sender: TObject);
var
StrList: TStringList;
begin
StrList := TStringList.Create;
try
GetVideoModes(StrList);
Memo1.Lines := StrList;
finally
StrList.Clear;
StrList.Free;
end;
end;
{************************************************ }
var
i, j: integer;
MoreModes,
AddMode: boolean;
dm: TDeviceMode;
Mode: string;
begin
ModeList.Clear;
MoreModes := True;
Mode := '';
i := 0;
while MoreModes do
begin
MoreModes := EnumDisplaySettings(nil, i, dm);
Mode := IntToStr(dm.dmBitsPerPel) + ' Bits Per Pixel ' +
IntToStr(dm.dmPelsWidth) + ' x ' +
IntToStr(dm.dmPelsHeight);
AddMode := True;
{ Check to make sure this mode is not already in the list. }
for j := 0 to ModeList.Count-1 do
if Mode = ModeList[j] then
AddMode := False;
if AddMode then
ModeList.Add(Mode);
Inc(i);
end;
end;
[/quote]

2010-01-25

detect, which version of ADO is installed ?

Author: Simon Carter

With different versions of MDAC available it is sometimes

useful to know that your application won't fail because a user
hasn't got the latest version installed.
The following function returns the ADO version installed,
you need to place ComObj in the uses clause to use this function. }

function GetADOVersion: Double;
var
ADO: Variant;
begin
try
ADO := CreateOLEObject('adodb.connection');
Result := StrToFloat(ADO.Version);
ADO := Null;
except
Result := 0.0;
end;
end;

// To use this function try something like:

procedure TForm1.Button1Click(Sender: TObject);
const
ADOVersionNeeded = 2.5;
begin
if
GetADOVersion <>then
ShowMessage('Need to install MDAC version 2.7')
else
ShowMessage(Format('ADO Version %n, is OK', [GetADOVersion]));
end;

make an ADODB Connection using OLE-Automation ?

Author: Daniel Henrique Monteiro de Carvalho (Brasil)

{...}

uses
ComObj;
{...}

function OpenConnection(ConnectionString: AnsiString): integer;
var
ADODBConnection: OleVariant;
begin
ADODBConnection := CreateOleObject('ADODB.Connection');
ADODBConnection.CursorLocation := 3; // User client
ADODBConnection.ConnectionString := ConnectionString;
Result := 0;
try
ADODBConnection.Open;
except
Result := -1;
end;
end;

function DataBaseConnection_Test(bMessage: boolean): AnsiString;
var
asTimeout,
asUserName,
asPassword,
asDataSource,
ConnectionString: AnsiString;
iReturn: Integer;
OldCursor: TCursor;
begin
OldCursor := Screen.Cursor;
Screen.Cursor := crHourGlass;
asTimeout := '150';
asUserName := 'NT_Server';
asPassword := 'SA';
asDataSource := 'SQL Server - My DataBase';

ConnectionString := 'Data Source = ' + asDataSource +
'User ID = ' + asUserName +
'Password = ' + asPassword +
'Mode = Read|Write;Connect Timeout = ' + asTimeout;
try
iReturn := OpenConnection(ConnectionString);

if (bMessage) then
begin
if
(iReturn = 0) then
Application.MessageBox('Connection OK!', 'Information', MB_OK)
else if (iReturn = -1) then
Application.MessageBox('Connection Error!', 'Error', MB_ICONERROR

+ MB_OK);
end;
if (iReturn = 0) then

Result := ConnectionString
else if (iReturn = -1) then
Result := '';
finally
Screen.Cursor := OldCursor;
end;
end;


procedure TForm1.Button1Click(Sender: TObject);
begin
DataBaseConnection_Test(true);
end;

check, if the Borland Database Engine (BDE) is installed ?

Author: tom

Uses
Bde;

function BDEInstalled : boolean;
begin
result := (dbiInit(nil) = 0)
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
if
BDEInstalled then
ShowMessage('BDE is installed.')
else
ShowMessage('BDE is not installed.')
end;