[code language=”delphi”]
procedure TForm1.Button1Click(Sender: TObject);
var
a, b: integer;
begin
a := strtoint(Edit1.Text);
try
try
b := a div a;
except
on e: Exception do
b := 0;
end;
finally
Edit3.Text := inttostr(b);
end;
end;
[/code]
Category: IT
Bracket sequence
()((())((())
Is it correct sequence?
I need just a counter.
foreach char in string {
If next bracket is “(” then inc(counter);
If next bracket is “)” then dec(counter);
If counter < 0 then showmessage(“Error”);
}
delphi key state
[code language=”delphi”]
procedure TForm1.Button1Click(Sender: TObject);
var
KeyState : Word;
S : String;
begin
KeyState := GetKeyState(VK_SCROLL);
S := ‘Клавиша: VK_SCROLL. Состояние:’;
if KeyState and $8000 = $8000 then
S := s+’down’
else
S := s+’up’;
if KeyState and 1 = 1 then
S := S + ‘toggle on’
else
S := S + ‘toggle off’
;
ShowMessage( S );
end;
[/code]
Delphi keyboard
[code language=”delphi”]
function GetRealChar(AKey: Word): Char;
var
Layout: HKL;
KeyboardState: TKeyboardState;
RealCode: AnsiString;
ScanCode: Integer;
s: string;
begin
Layout := GetKeyboardLayout(GetCurrentThreadID);
SetLength(RealCode, 1);
FillChar(RealCode[1], Length(RealCode), 0);
FillChar(KeyboardState[0], SizeOf(KeyboardState), 0);
KeyboardState[AKey] := 0;
ScanCode := (AKey shr 16) and $FF;
ToAsciiEx(AKey, ScanCode, KeyboardState, PChar(RealCode), 0, Layout);
s := RealCode;
Result := s[1];
end;
[/code]
Delphi, Windows memory
articles from Gunsmoker
- blogal variables (pdf)
- windows memory (pdf)
- windows memory – myths and legends (pdf)