Lena Posted May 29, 2015 Share Posted May 29, 2015 Hi. How to block editing UniDateTimePicker from the keyboard? void __fastcall TMainForm::UniDateTimePicker3KeyUp(TObject *Sender, WORD &Key, TShiftState Shift) { Key = 0; } It does not work. Quote Link to comment Share on other sites More sharing options...
tappatappa Posted May 29, 2015 Share Posted May 29, 2015 static void fixDateTimePicker(TUniCustomDateTimePicker * dt) { TUniDateTimePicker * dtp = dynamic_cast<TUniDateTimePicker*>(dt); TUniDBDateTimePicker * dbdtp = dynamic_cast<TUniDBDateTimePicker*>(dt); TUniDateTimeKind kind; if (dtp != NULL) kind = dtp->Kind; else if (dbdtp != NULL) kind = dbdtp->Kind; else return; UnicodeString ev = L" function(sender) { sender.editable = false; }"; if (kind == tUniDate || kind == tUniTime) { if (dtp != NULL) dtp->ClientEvents->ExtEvents->Values[L"afterrender"] = ev; else if (dbdtp != NULL) dbdtp->ClientEvents->ExtEvents->Values[L"afterrender"] = ev; } else { if (dtp != NULL) { dtp->ClientEvents->ExtEvents->Values[L"date.afterrender"] = ev; dtp->ClientEvents->ExtEvents->Values[L"time.afterrender"] = ev; } else if (dbdtp != NULL) { dbdtp->ClientEvents->ExtEvents->Values[L"date.afterrender"] = ev; dbdtp->ClientEvents->ExtEvents->Values[L"time.afterrender"] = ev; } } } this works for both DB and non-DB components. Quote Link to comment Share on other sites More sharing options...
Lena Posted May 29, 2015 Author Share Posted May 29, 2015 Thank you very much! I will try. Quote Link to comment Share on other sites More sharing options...
tappatappa Posted May 29, 2015 Share Posted May 29, 2015 Thank you very much! I will try. Glad to be of help. I just copy-pasted a function I wrote a while ago. Quote Link to comment Share on other sites More sharing options...
NelsonFS Posted May 29, 2015 Share Posted May 29, 2015 Please, port source code to Delphi. Quote Link to comment Share on other sites More sharing options...
tappatappa Posted June 1, 2015 Share Posted June 1, 2015 Please, port source code to Delphi. Come on! Is non THAT hard! For starters, here is a quick and dirty port (I am not even sure that compiles). If you can improve it please reply with your solution. procedure fixDateTimePicker(dt:TUniCustomDateTimePicker) var dtp: TUniDateTimePicker; dbdtp: TUniDBDateTimePicker; kind: TUniDateTimeKind; ev: string; begin dtp := nil; dbdtp := nil; if dt is TUniDateTimePicker then begin dtp := dt as TUniDateTimePicker; kind := dtp.Kind; end elsif dt is TUniDBDateTimePicker then begin dbdtp := dt as TUniDBDateTimePicker; kind := dbdtp.Kind; end else Exit; ev := ' function(sender) { sender.editable = false; }'; if (kind = tUniDate) or (kind = tUniTime) then begin if (dtp <> nil) then dtp.ClientEvents.ExtEvents.Values['afterrender'] := ev elsif (dbdtp <> nil) then dbdtp.ClientEvents.ExtEvents.Values['afterrender'] := ev; end else begin if (dtp <> nil) then begin dtp.ClientEvents.ExtEvents.Values['date.afterrender'] := ev; dbdtp.ClientEvents.ExtEvents.Values['time.afterrender'] := ev; end elsif (dbdtp <> nil) then begin dtp.ClientEvents.ExtEvents.Values['date.afterrender'] := ev; dbdtp.ClientEvents.ExtEvents.Values['time.afterrender'] := ev; end; end; end; 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.