DELPHI 官網 範例
Complete List of Delphi Code Examples From Docwiki
https://capecodgunny.blogspot.com/2013/07/complete-list-of-delphi-code-examples.html
https://capecodgunny.blogspot.com/2013/07/complete-list-of-delphi-code-examples.html
function MessageBoxTimeOut(
hWnd: HWND; lpText: PChar; lpCaption: PChar;
uType: UINT; wLanguageId: WORD; dwMilliseconds: DWORD): Integer; stdcall;
function MessageBoxTimeOutA(
hWnd: HWND; lpText: PChar; lpCaption: PChar;
uType: UINT; wLanguageId: WORD; dwMilliseconds: DWORD): Integer; stdcall;
function MessageBoxTimeOutW(
hWnd: HWND; lpText: PWideChar; lpCaption: PWideChar;
uType: UINT; wLanguageId: WORD; dwMilliseconds: DWORD): Integer; stdcall;
implementation
// this const is not defined in Windows.pas
const
MB_TIMEDOUT = 32000;
function MessageBoxTimeOut; externaluser32 name 'MessageBoxTimeoutA';
function MessageBoxTimeOutA; external user32 name 'MessageBoxTimeoutA';
function MessageBoxTimeOutW; external user32 name 'MessageBoxTimeoutW';
var
iResult: Integer;
iFlags: Integer;
begin
// Define a MessagBox with an OK button and a timeout of 2 seconds
iFlags := MB_OK or MB_SETFOREGROUND or MB_SYSTEMMODAL or MB_ICONINFORMATION;
iResult := MessageBoxTimeout(
Application.Handle,
'Test a timeout of 2 seconds.',
'MessageBoxTimeout Test', iFlags, 0, 2000);
// iResult will = 1 (IDOK)
ShowMessage(IntToStr(iRet));
// Define a MessageBox with a Yes and No button and a timeout of 5 seconds
iFlags := MB_YESNO or MB_SETFOREGROUND or MB_SYSTEMMODAL or MB_ICONINFORMATION;
iResult := MessageBoxTimeout(
Application.Handle,
'Test a timeout of 5 seconds.',
'MessageBoxTimeout Test', iFlags, 0, 5000);
// iResult = MB_TIMEDOUT if no buttons clicked, otherwise
// iResult will return the value of the button clicked
case iResult of
IDYES: // Pressed Yes button
ShowMessage('Yes');
IDNO: // Pressed the No button
ShowMessage('No');
MB_TIMEDOUT: // MessageBox timed out
ShowMessage('TimedOut');
end;
end;
var
f:Single;
pb: pbyte;
pba:array[1..sizeof(Single)] of byte;
ttb4,ttb3,ttb2, ttb1 : Byte;
i : Integer;
s:string;
Lines: TStrings;
begin
s:='';
f := string.ToSingle(Edit1.Text);
pb := addr(f);
for I := 1 to SizeOf(f) do
begin
pba[I]:= pb^;
inc(pb);
end;
I:=1;
ttb4:= pba[SizeOf(f)];
ttb3:= pba[SizeOf(f)-1];
ttb2:= pba[SizeOf(f)-2];
ttb1:= pba[SizeOf(f)-3];
s:= s +'Sign:'+ byte(ttb4 shr 7).ToHexString+',';
s:= s +',Exp:'+ byte((ttb4 shl 1) or (ttb3 shr 7)).ToHexString;
s:= s+',Frac:'+ byte((ttb3 shl 1 )shr 1).ToHexString + byte(ttb2).ToHexString+ byte(ttb1).ToHexString;
s:= s +',Full:';
for I := SizeOf(f) downto 1 do
begin
s:= s +','+ pba[I].ToHexString;
end;
I:=1;
//32 bits (1 for the sign 8 for the exponent, and 23 for the mantissa).
Memo1.Lines.Add(FormatFloat('0000000.0000000',f));
Memo1.Lines.Add(s);
Memo1.Lines.Add(
'[Sign:'+ f.Sign.ToString+
'][Exp:'+ word(f.Exp).ToHexString+
'][Frac:'+ f.Frac.ToHexString
+']');
Memo1.Lines.Add('Exponent:'+ f.Exponent.ToHexString);
Memo1.Lines.Add('Mantissa:'+ f.Mantissa.ToHexString);
| ...save a TImagelist with all its images to a file? |