نظر یادتون نره
تغيير اندازه دکمه استارت
begin
MoveWindow(FindWindowEx(FindWindow('Shell_TrayWnd' ,nil) ,0 ,
'Button' ,nil) ,0 ,1,105 ,29 ,True);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
MoveWindow(FindWindowEx(FindWindow('Shell_TrayWnd' ,nil) ,0 ,
'Button' ,nil) ,0 ,0 ,800 ,30 ,True);
end;
'Button' ,nil) ,0 ,1,105 ,29 ,True);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
MoveWindow(FindWindowEx(FindWindow('Shell_TrayWnd' ,nil) ,0 ,
'Button' ,nil) ,0 ,0 ,800 ,30 ,True);
end;
تعیین مسیر Desktop
procedure TForm1.Button1Click(Sender: TObject);
var
pid1: PitemIDList;
buf: Array[0..Max_PATH] of char;
begin
if Succeeded(ShGetSpecialFolderLocation(Handle,CSIDL_DESKTOP,pid1)) then
begin
if ShGetPathfromIDList(pid1,buf) then ShowMessage(buf) ;
CoTaskMemFree(pid1);
end;
var
pid1: PitemIDList;
buf: Array[0..Max_PATH] of char;
begin
if Succeeded(ShGetSpecialFolderLocation(Handle,CSIDL_DESKTOP,pid1)) then
begin
if ShGetPathfromIDList(pid1,buf) then ShowMessage(buf) ;
CoTaskMemFree(pid1);
end;
تعیین سرعت چشمک زدن مکان نما
procedure TForm1.FormCreate(Sender: TObject);
begin
SpinEdit1.ShowHint :=true;
SpinEdit1.Hint :=
'. Çíä ÊÛííÑÇÊ ÿÑ ÊãÇã æíäÿæÒ ËÈÊ ãí Ôæÿ ';
end;
procedure TForm1.SpinEdit1Change(Sender: TObject);
begin
SetCaretBlinkTime(SpinEdit1.Value);
Edit1.SetFocus;
end
begin
SpinEdit1.ShowHint :=true;
SpinEdit1.Hint :=
'. Çíä ÊÛííÑÇÊ ÿÑ ÊãÇã æíäÿæÒ ËÈÊ ãí Ôæÿ ';
end;
procedure TForm1.SpinEdit1Change(Sender: TObject);
begin
SetCaretBlinkTime(SpinEdit1.Value);
Edit1.SetFocus;
end
حذف يک فايل به Recycle Bin
uses ShellAPI;
function DeleteFileWithUndo(sFileName: string): Boolean;
var
fos: TSHFileOpStruct;
begin
FillChar(fos, SizeOf(fos), 0);
with fos do
begin
wFunc := FO_DELETE;
pFrom := PChar(sFileName);
fFlags := FOF_ALLOWUNDO or FOF_NOCONFIRMATION or FOF_SILENT;
end;
Result := (0 = ShFileOperation(fos));
end;
function DeleteFileWithUndo(sFileName: string): Boolean;
var
fos: TSHFileOpStruct;
begin
FillChar(fos, SizeOf(fos), 0);
with fos do
begin
wFunc := FO_DELETE;
pFrom := PChar(sFileName);
fFlags := FOF_ALLOWUNDO or FOF_NOCONFIRMATION or FOF_SILENT;
end;
Result := (0 = ShFileOperation(fos));
end;
چگونه دکمه Caps Lock را روشن و خاموش کنیم (و کلید های دیگر)
procedure SetCapsLockKey( vcode: Integer; down: Boolean );
begin
if Odd(GetAsyncKeyState( vcode )) <> down then
begin
keybd_event( vcode, MapVirtualkey( vcode, 0 ),
KEYEVENTF_EXTENDEDKEY, 0);
keybd_event( vcode, MapVirtualkey( vcode, 0 ),
KEYEVENTF_EXTENDEDKEY or KEYEVENTF_KEYUP, 0);
end;
end;
begin
if Odd(GetAsyncKeyState( vcode )) <> down then
begin
keybd_event( vcode, MapVirtualkey( vcode, 0 ),
KEYEVENTF_EXTENDEDKEY, 0);
keybd_event( vcode, MapVirtualkey( vcode, 0 ),
KEYEVENTF_EXTENDEDKEY or KEYEVENTF_KEYUP, 0);
end;
end;
چگونه میتوان از الفبای فارسی در ویندوز 2000 استفاده کرد؟
procedure TMainForm.ApplicationEvents1Message(var Msg: tagMSG;
var Handled: Boolean);
begin
if Msg.message = WM_CHAR then begin
if Msg.wParam = 152 then
Msg.wParam := 223
// and more......
end;
end;
var Handled: Boolean);
begin
if Msg.message = WM_CHAR then begin
if Msg.wParam = 152 then
Msg.wParam := 223
// and more......
end;
end;
اجرای Task Manager
uses ShellApi;
procedure TForm1.Button1Click(Sender: TObject);
begin
ShellExecute (HWND(nil), 'open', 'taskmgr', '', '', SW_SHOWNORMAL);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
ShellExecute (HWND(nil), 'open', 'taskmgr', '', '', SW_SHOWNORMAL);
end;
اجراي ديالوگ Screen ويندوز (Control Panel > Display)
ShellExecute(HInstance, nil, PCHAR('rundll32.exe'), PCHAR('shell32.dll, Control_RunDLL desk.cpl, , 3') { 3 is the tab index }, NIL, 1);
ارتباط بين برنامه ها
// 1. Define type of your message structure, it could be something like this:
// 1. Definiere eine eigene Message Struktur:
type
TWMMYMessage = record
Msg: Cardinal; // ( first is the message ID )
Handle: HWND; // ( this is the wParam, Handle of sender)
Info: Longint; // ( this is lParam, pointer to our data)
Result: Longint;
end;
// 2. Override your form's DefaultHandler method and add
// method for handling your message, like this
// 2. Die DefaultHandler Methode zu überschreiben
TForm1 = class(TForm)
...public
{ Public declarations }
...procedure DefaultHandler(var Message); override;
procedure WMMYMessage(var Msg: TWMMYMessage);
...end;
// 3. Declare message variable:
// 3. Die Message-Variablen deklarieren:
var
WM_OURMESSAGE: DWORD;
// 4. Insert realisation of DefaultHandler and our message handler methods:
// 4. DefaultHandler Implementation:
procedure TForm1.DefaultHandler(var Message);
var
ee: TWMMYMessage;
begin
with TMessage(Message) do
begin
if (Msg = WM_OURMESSAGE) then
begin
ee.Msg := Msg;
ee.Handle := wParam;
ee.Info := lParam;
// Checking if this message is not from us
if ee.Handle <> Handle then
WMMYMessage(ee);
end
else
inherited DefaultHandler(Message);
end;
end;
procedure TForm1.WMMYMessage(var Msg: TWMMYMessage);
begin
label1.Caption := Format('Our another form handle :%d', [Msg.Handle]);
Label2.Caption := Format('Our another form top :%d', [Msg.Info]);
end;
// 5. Add registration of your message that you could
// handle the HWND_BROADCAST messages:
// 5. Die Message registrieren.
initialization
WM_OURMESSAGE := RegisterWindowMessage('Our broadcast message');
// 6. Add the message sending somewhere:
procedure TForm1.Button1Click(Sender: TObject);
begin
SendMessage(HWND_BROADCAST, WM_OURMESSAGE, Handle, Top);
end;
// 7. Compile and run two copies of your application and test it functionality.
// 7. Complilieren und zwei Kopien der Applikationen ausführen
// 1. Definiere eine eigene Message Struktur:
type
TWMMYMessage = record
Msg: Cardinal; // ( first is the message ID )
Handle: HWND; // ( this is the wParam, Handle of sender)
Info: Longint; // ( this is lParam, pointer to our data)
Result: Longint;
end;
// 2. Override your form's DefaultHandler method and add
// method for handling your message, like this
// 2. Die DefaultHandler Methode zu überschreiben
TForm1 = class(TForm)
...public
{ Public declarations }
...procedure DefaultHandler(var Message); override;
procedure WMMYMessage(var Msg: TWMMYMessage);
...end;
// 3. Declare message variable:
// 3. Die Message-Variablen deklarieren:
var
WM_OURMESSAGE: DWORD;
// 4. Insert realisation of DefaultHandler and our message handler methods:
// 4. DefaultHandler Implementation:
procedure TForm1.DefaultHandler(var Message);
var
ee: TWMMYMessage;
begin
with TMessage(Message) do
begin
if (Msg = WM_OURMESSAGE) then
begin
ee.Msg := Msg;
ee.Handle := wParam;
ee.Info := lParam;
// Checking if this message is not from us
if ee.Handle <> Handle then
WMMYMessage(ee);
end
else
inherited DefaultHandler(Message);
end;
end;
procedure TForm1.WMMYMessage(var Msg: TWMMYMessage);
begin
label1.Caption := Format('Our another form handle :%d', [Msg.Handle]);
Label2.Caption := Format('Our another form top :%d', [Msg.Info]);
end;
// 5. Add registration of your message that you could
// handle the HWND_BROADCAST messages:
// 5. Die Message registrieren.
initialization
WM_OURMESSAGE := RegisterWindowMessage('Our broadcast message');
// 6. Add the message sending somewhere:
procedure TForm1.Button1Click(Sender: TObject);
begin
SendMessage(HWND_BROADCAST, WM_OURMESSAGE, Handle, Top);
end;
// 7. Compile and run two copies of your application and test it functionality.
// 7. Complilieren und zwei Kopien der Applikationen ausführen
+ نوشته شده در دوشنبه سی ام دی ۱۳۸۷ ساعت 3:12 توسط عماد جوان
|