Kako da u celoj aplikaciji na numeričkoj tastaturi decimalnu tačku zamenim sa decimalnim zarezom
Numerička tačka
Zaključano
Zakačeno
DecimalSeparator := ',';
Nasao sam resenje koje ujedno omogucava Dos-ovski nacin rada u Windowsu
procedure TForm1.FormCreate(Sender: TObject);
begin
Application.OnMessage := ApplicationMessage;
end;
procedure TForm1.ApplicationMessage(var Msg: TMsg;
var Handled: Boolean);
var
ActiveControl : TWinControl;
Form : TCustomForm;
ShiftState : TShiftState;
KeyState : TKeyboardState;
begin
case Msg.Message of
WM_KEYDOWN, WM_KEYUP:
case Msg.wParam of
VK_RETURN:
// Replaces ENTER with TAB, and CTRL+ENTER with ENTER...
begin
GetKeyboardState(KeyState);
ShiftState := KeyboardStateToShiftState(KeyState);
if (ShiftState = []) or (ShiftState = [ssCtrl]) then begin
ActiveControl := Screen.ActiveControl;
if (TCustomComboBox(ActiveControl) is TCustomComboBox) and
(TCustomComboBox(ActiveControl).DroppedDown) then begin
if ShiftState = [ssCtrl] then begin
KeyState[VK_LCONTROL] := KeyState[VK_LCONTROL] and $7F;
KeyState[VK_RCONTROL] := KeyState[VK_RCONTROL] and $7F;
KeyState[VK_CONTROL] := KeyState[VK_CONTROL] and $7F;
SetKeyboardState(KeyState);
end;
end else if (TCustomEdit(ActiveControl) is TCustomEdit)
and not (TCustomMemo(ActiveControl) is TCustomMemo)
or (TCustomCheckbox(ActiveControl) is TCustomCheckbox)
or (TRadioButton(ActiveControl) is TRadioButton)
or (TCustomListBox(ActiveControl) is TCustomListBox)
or (TCustomComboBox(ActiveControl) is TCustomComboBox)
// You can add more controls to the list with "or"
then
if ShiftState = [] then begin
Msg.wParam := VK_TAB
end else begin // ShiftState = [ssCtrl]
Msg.wParam := 0; // Discard the key
if Msg.Message = WM_KEYDOWN then begin
Form := GetParentForm(ActiveControl);
if (Form <> nil) and
(ActiveControl.Perform(CM_WANTSPECIALKEY,
VK_RETURN, 0) = 0) and
(ActiveControl.Perform(WM_GETDLGCODE, 0, 0)
and DLGC_WANTALLKEYS = 0) then
begin
KeyState[VK_LCONTROL] := KeyState[VK_LCONTROL] and $7F;
KeyState[VK_RCONTROL] := KeyState[VK_RCONTROL] and $7F;
KeyState[VK_CONTROL] := KeyState[VK_CONTROL] and $7F;
SetKeyboardState(KeyState);
Form.Perform(CM_DIALOGKEY, VK_RETURN, Msg.lParam);
end;
end;
end;
end;
end;
VK_DOWN:
begin
GetKeyboardState(KeyState);
if KeyboardStateToShiftState(KeyState) = [] then begin
ActiveControl := Screen.ActiveControl;
if (TCustomEdit(ActiveControl) is TCustomEdit)
and not (TCustomMemo(ActiveControl) is TCustomMemo)
// You can add more controls to the list with "or"
then
Msg.wParam := VK_TAB;
end;
end;
VK_UP:
begin
GetKeyboardState(KeyState);
if KeyboardStateToShiftState(KeyState) = [] then begin
ActiveControl := Screen.ActiveControl;
if (TCustomEdit(ActiveControl) is TCustomEdit)
and not (TCustomMemo(ActiveControl) is TCustomMemo)
// You can add more controls to the list with "or"
then
begin
Msg.wParam := 0; // Discard the key
if Msg.Message = WM_KEYDOWN then begin
Form := GetParentForm(ActiveControl);
if Form <> nil then // Move to previous control
Form.Perform(WM_NEXTDLGCTL, 1, 0);
end;
end;
end;
end;
// Replace the decimal point of the numeric key pad (VK_DECIMAL)
// with a comma (key code = 188). For Spanish applications.
VK_DECIMAL:
begin
GetKeyboardState(KeyState);
if KeyboardStateToShiftState(KeyState) = [] then begin
Msg.wParam := 188;
end;
end;
end;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Application.OnMessage := ApplicationMessage;
end;
procedure TForm1.ApplicationMessage(var Msg: TMsg;
var Handled: Boolean);
var
ActiveControl : TWinControl;
Form : TCustomForm;
ShiftState : TShiftState;
KeyState : TKeyboardState;
begin
case Msg.Message of
WM_KEYDOWN, WM_KEYUP:
case Msg.wParam of
VK_RETURN:
// Replaces ENTER with TAB, and CTRL+ENTER with ENTER...
begin
GetKeyboardState(KeyState);
ShiftState := KeyboardStateToShiftState(KeyState);
if (ShiftState = []) or (ShiftState = [ssCtrl]) then begin
ActiveControl := Screen.ActiveControl;
if (TCustomComboBox(ActiveControl) is TCustomComboBox) and
(TCustomComboBox(ActiveControl).DroppedDown) then begin
if ShiftState = [ssCtrl] then begin
KeyState[VK_LCONTROL] := KeyState[VK_LCONTROL] and $7F;
KeyState[VK_RCONTROL] := KeyState[VK_RCONTROL] and $7F;
KeyState[VK_CONTROL] := KeyState[VK_CONTROL] and $7F;
SetKeyboardState(KeyState);
end;
end else if (TCustomEdit(ActiveControl) is TCustomEdit)
and not (TCustomMemo(ActiveControl) is TCustomMemo)
or (TCustomCheckbox(ActiveControl) is TCustomCheckbox)
or (TRadioButton(ActiveControl) is TRadioButton)
or (TCustomListBox(ActiveControl) is TCustomListBox)
or (TCustomComboBox(ActiveControl) is TCustomComboBox)
// You can add more controls to the list with "or"
then
if ShiftState = [] then begin
Msg.wParam := VK_TAB
end else begin // ShiftState = [ssCtrl]
Msg.wParam := 0; // Discard the key
if Msg.Message = WM_KEYDOWN then begin
Form := GetParentForm(ActiveControl);
if (Form <> nil) and
(ActiveControl.Perform(CM_WANTSPECIALKEY,
VK_RETURN, 0) = 0) and
(ActiveControl.Perform(WM_GETDLGCODE, 0, 0)
and DLGC_WANTALLKEYS = 0) then
begin
KeyState[VK_LCONTROL] := KeyState[VK_LCONTROL] and $7F;
KeyState[VK_RCONTROL] := KeyState[VK_RCONTROL] and $7F;
KeyState[VK_CONTROL] := KeyState[VK_CONTROL] and $7F;
SetKeyboardState(KeyState);
Form.Perform(CM_DIALOGKEY, VK_RETURN, Msg.lParam);
end;
end;
end;
end;
end;
VK_DOWN:
begin
GetKeyboardState(KeyState);
if KeyboardStateToShiftState(KeyState) = [] then begin
ActiveControl := Screen.ActiveControl;
if (TCustomEdit(ActiveControl) is TCustomEdit)
and not (TCustomMemo(ActiveControl) is TCustomMemo)
// You can add more controls to the list with "or"
then
Msg.wParam := VK_TAB;
end;
end;
VK_UP:
begin
GetKeyboardState(KeyState);
if KeyboardStateToShiftState(KeyState) = [] then begin
ActiveControl := Screen.ActiveControl;
if (TCustomEdit(ActiveControl) is TCustomEdit)
and not (TCustomMemo(ActiveControl) is TCustomMemo)
// You can add more controls to the list with "or"
then
begin
Msg.wParam := 0; // Discard the key
if Msg.Message = WM_KEYDOWN then begin
Form := GetParentForm(ActiveControl);
if Form <> nil then // Move to previous control
Form.Perform(WM_NEXTDLGCTL, 1, 0);
end;
end;
end;
end;
// Replace the decimal point of the numeric key pad (VK_DECIMAL)
// with a comma (key code = 188). For Spanish applications.
VK_DECIMAL:
begin
GetKeyboardState(KeyState);
if KeyboardStateToShiftState(KeyState) = [] then begin
Msg.wParam := 188;
end;
end;
end;
end;
end;
Citat:
edin_jak: Nasao sam resenje koje ujedno omogucava Dos-ovski nacin rada u Windowsu
Zaista mi nije jasno zašto programeri ne shvate da je DOS MRTAV? DOS način rada je za DOS. Windows ima novi način rada i treba ga primenjivati. Pa jesi li DOS ili Windows programer...
Ne radi se o tome jeli covek Djokista ili Mikista ili je od Erriksonovih ili nokijinih vec o tome hoce li njegov softver zaziveti ili ne.
Imate pregtst softvera napisanog u dosu i veli broj ljudi koji su se na taj nacin rada navikli. Piritisne na enter ono ide na sledeci tab ako im to ne ispostujes njima je tvoj program neprihvatljiv.
I sam imam takvu situaciju sada.... jednostavno knjigovodje hoce da im bude kako su naucili...
AKO NECE BREG MUHAMEDU....
Imate pregtst softvera napisanog u dosu i veli broj ljudi koji su se na taj nacin rada navikli. Piritisne na enter ono ide na sledeci tab ako im to ne ispostujes njima je tvoj program neprihvatljiv.
I sam imam takvu situaciju sada.... jednostavno knjigovodje hoce da im bude kako su naucili...
AKO NECE BREG MUHAMEDU....
offtopic: koristi code tagove kad postavljas kod
Potpis
Citat:
dekys:I sam imam takvu situaciju sada.... jednostavno knjigovodje hoce da im bude kako su naucili...
Stoji, ali valjda ima malo i do volje da nametnes ono sto je ispravno i ne prihvatis svaku tupavu zelju korisnika. Da vidis kako moji radosno lupaju po TAB-u...
Pre nego neko pocne - ne zelim da se raspravljam o tome da li treba i kako treba, da li se korisniku treba uvlaciti, tetositi ga i ispunjavati i njegovu najgluplju zelju ili se drzati standarda. Ja ih teram da promene nacin rada i kraj. Ja sam programer i ja znam sta i kako treba a ne on. Ako nece mene, neka nadje drugog programera.
Kako da pročitam decimalni separator, valutu... od Regional Settings?
Potpis
routing protocols enable routers to route routed protocols!
Evo situacije zbog čega mi treba DOS-ovski način rada. Preko 100 firmi u gradu koristi softver napisan u clliper-u, uglavnom su svi stariji knjigovođe koji osim tog programa ne znaju ništa drugo da koriste na računaru. Čik sve njih kao zapovedni programer nateraj da koriste tab umesto entera i pri tom im dobro naplati usluge.
Hm, nisu knjigovođe baš za sve krive,
realno gledajući, tab tipka je jedna i obično nepotrebno zauzima i
lijevu ruku, dok se enter može koristiti i uz slovni i uz numerički dio tastature
(ovo zadnje posebno). Kad se koristi samo enter, i većinom unose cifre,
onda je moguće osloboditi lijevu ruku i dobija se na brzini.
Drugi slučaj - registar kase, lijeva ruka se obično koristi za bar kod a desna za
unos i prihvatanje (sa enter).
Evo za separator i ostalo:
realno gledajući, tab tipka je jedna i obično nepotrebno zauzima i
lijevu ruku, dok se enter može koristiti i uz slovni i uz numerički dio tastature
(ovo zadnje posebno). Kad se koristi samo enter, i većinom unose cifre,
onda je moguće osloboditi lijevu ruku i dobija se na brzini.
Drugi slučaj - registar kase, lijeva ruka se obično koristi za bar kod a desna za
unos i prihvatanje (sa enter).
Evo za separator i ostalo:
Code:
uses
SysUtils;
var
loc: TFormatSettings;
s1, s2: String;
begin
GetLocaleFormatSettings(LOCALE_SYSTEM_DEFAULT, loc);
s1 := loc.DecimalSeparator;
s2 := loc.CurrencyString;
// .......
end;
uses
SysUtils;
var
loc: TFormatSettings;
s1, s2: String;
begin
GetLocaleFormatSettings(LOCALE_SYSTEM_DEFAULT, loc);
s1 := loc.DecimalSeparator;
s2 := loc.CurrencyString;
// .......
end;
Recimo da imas Edit1 i Edit2 i iz edit1 trebas da predjes u edit2 pritiskom na enter.
Samo postavis u onKeyDown event edit1 kontrole
i eto ti enter umesto tab....
Samo postavis u onKeyDown event edit1 kontrole
Code:
if Key = VK_ENTER then Edit2.SetFocus;
if Key = VK_ENTER then Edit2.SetFocus;
i eto ti enter umesto tab....
A sta ako ima jako mnogo edit-a? :)
Potpis
procedure TForm1.FormKeyPress(Sender: TObject; var Key: Char);
begin
if Key = #13 then
begin
Key := #0;
if GetKeyState(VK_Shift) and $8000 <> 0 then
PostMessage(Handle, WM_NEXTDLGCTL, 1, 0)
else
PostMessage(Handle, WM_NEXTDLGCTL, 0, 0);
end;
end;
Takodje i KeyPreview na Formi postavi na True.
begin
if Key = #13 then
begin
Key := #0;
if GetKeyState(VK_Shift) and $8000 <> 0 then
PostMessage(Handle, WM_NEXTDLGCTL, 1, 0)
else
PostMessage(Handle, WM_NEXTDLGCTL, 0, 0);
end;
end;
Takodje i KeyPreview na Formi postavi na True.