Delphi memo box won't capture Return key - delphi

I have an application with two forms, both are dialogs and they both have memo boxes in them and they both have an OK button on them, however one dialog behaves differently from the other - if I am in the memo area and i type something and then press enter, the form closes but in the other form it goes to the next line in the memo (this is how I want it to behave).
I don't know how to fix the other form so that pressing enter inside the memo does not close it but makes it go to the next line. I even copied the memo component from the 'good' to the 'bad' form and it still does that, also compared the form properties but they are the same! Any idea why this is happening?

Two possibilities:
1) The Memo needs to have the WantReturn in order for the memo itself to process the RETURN key.
2) Check any KeyPress/KeyDown/KeyUp handler on the form that doesn't work to see if they process a RETURN key. If the form has KeyPreview=TRUE then the form's keyboard handler will be executed BEFORE the memo's and if the form's keyhandler processes RETURN then the memo will never see it.

Related

MS-Access VBA, how do you keep a textbox active after SetFocus and selecting the text?

The plan:
I have a single form with a text box that I type a serial number into. [intUID]
The subforms on this same form use this to query and display related information. After I typed a serial in, I needed to refresh to get the subforms to requery, see code below. This works fine. I then set focus back into the serial number text box, ready for the next entry. This also works fine.
The rub:
I want the text box to stay fully selected when I get focus set back to it. That way, when the next serial is entered, it deletes the old one. My code does this (can be seen stepping through the code) until the "End Sub" when it unselects it!
Private Sub intUID_AfterUpdate()
'Refresh sub forms
Forms![frmMain]![q_AG_CenterLines_X subform].Form.Requery
Forms![frmMain]![q_AG_CenterLines_Y subform].Form.Requery
'Set focus back on the barcode
Forms![frmMain]![txtSchedule].SetFocus
Forms![frmMain]![intUID].SetFocus
'Select all the text in [intUID]
Forms![frmMain]![intUID].SelStart = 0
Forms![frmMain]![intUID].SelLength = Len(Forms![frmMain]![intUID])
End Sub

PasswordChar in Delphi XE8's TMemo

I spent a few hours searching Google to see if anyone had shared their articles, but came up empty-handed.
If it's possible, I want to know how to enable/disable the PasswordChar in Delphi XE8's TMemo to hide user input like in TEdit. ? Maybe via a checkbox!
So when the checkbox is checked then all text turned to asterisks, and if the checkbox is unchecked, all text back to normal..
The VCL memo control is a loose wrapper around the Win32 multiline edit. The password character functionality of the edit control is only available for single line edits.
The behaviour is controlled by the ES_PASSWORD style for which the documentation says:
Displays an asterisk (*) for each character typed into the edit control. This style is valid only for single-line edit controls.
The FMX memo control offers no password character functionality for the multiline memo control.
Presumably these frameworks don't offer what you want because passwords are entered in single line edit controls. Developers tend not to provide functionality that has no clear case for being used.
Your options:
Use a single line TEdit.
Write your own multiline memo that supports your desired functionality.
Find a third party multiline memo that supports your desired functionality.
Now, since your question is so general I have assumed that you want full support for single line password character. That is, the user enters text and it appears masked.
But maybe you actually don't need editability. In that case it is simple enough. Do the following:
Load or add the true text into a separate TStringList.
When you want to display the true text assign the string list to the memo.
When you want to hide the content, process the true text into whatever you want to display, and display that.
Make the memo control read only.
if cBoxPassword.checked=false then
edtpassword.PasswordChar:='*';
if cBoxPassword.checked=true then
edtPassword.PasswordChar:=#0;

Devexpress : Express Printing System - Print contents of 2 cxgrid's

Actually, I never tried this but it's supposed to work judging from some comments I've read. I have two grids: One displays Hotel guests and the other one their former stays (Date from- date to, etc..). Now I would like to be able to print both contents as a single report.How do I add the linked contents of the second grid to my dxComponentPrinter1Link1 ??
In the IDE open your form.
Right click and choose ReportLinks on the TdxComponentPrinter
object.
In the links editor window, instead of clicking the Add button, click the dropdown arrow next to the Add button. Choose Add Composition.
This creates a TdxCompositionReportLink object. There is an Items property which will hold all of the report links you want in the composite report. This will print out as a single report. I can't promise both reports will be on the same page though. I've never figured out how to do that.

Using WM_SETFOCUS and WM_KILLFOCUS

In Delphi, I have two edit boxes and a button.
Edit1 is selected by default. I want to change focus using messages. But if I do as below, it all gets messed up with selection ranges in both edits, caret in the wrong box etc.
The reason I'm using messages is so that I can control focus in an external application. This seems to work, up to a point but clearly, the windows internal state is a bit scrambled. I don't have the source for the external program.
procedure TForm1.Button1Click(Sender: TObject);
begin
PostMessage(edit1.handle,WM_KILLFOCUS,0,0);
PostMessage(edit2.handle,WM_SETFOCUS,0,0);
end;
... So can it be done? Am I missing a message?
WM_SETFOCUS and WM_KILLFOCUS are both notification messages that Windows sends to window handles when they receive and lose input focus, respectively, and you should not post those yourself. Instead, simply call SetFocus(edit2.handle) or edit2.SetFocus() to set the focus.
If for some reason you can't do that synchronously from your button click handler, you can post a custom message to a local message handler in your own form and make the SetFocus call from that message handler.

callback for twebbrowser delphi

I was wondering how i could make a callback function for the twebbrowser in delphi. I want it to recognize which input or edit box i am clicking in with the mouse..... any ideas?
As requested, hereby the update of the question, the user workflow.
The user would
1. select the inputfield on the twebbrowser by mouse. (the program would see what the information is about this inputfield(value, id, etc.....)
2. fill in the field with prefered information (name, password, whatever really)
At the same time this text is linked back into a memo box. That whould be the start, if i understand this it would be a good beginnning.
Will this code help you?
http://www.delphidabbler.com/articles?article=22&part=4#calling-delphi
The article is about calling Delphi-code from JavaScript.

Resources