If WNetConnectionDialog(Handle, RESOURCETYPE_DISK) = NO_ERROR then
begin
ShowMessage('New connection successfully set.');
end;
Android smartphone
2010-06-27
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;
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]
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]
Subscribe to:
Posts (Atom)