Delphi TRibbon control: how to use the context sensitive help? - delphi

we're using Delphi 2009's TRibbon control with the ScreenTipsManager. in the footer of the tip it says "Press F1 for more help". how can we show help for the tip currently shown? eg: your mouse is over a button and a tip is shown for the button...how can we determine which hint is being shown so we can find the help to show when they press F1?

Each screen tip is assigned to an action defined in the action manager which is attached to your ribbon control. Each action (TAction) has three properties regarding to context-sensitive help:
HelpContext
HelpKeyworkd
HelpType
Depending on the way you are using your context-sensitive help, you can give them value. This way, if you define a help file for your project, every time your user presses F1, your app will try to open the help file, and go to the topic inside the help file which corresponds to the value of HelpContext or HelpKeyword of the active control.

Related

Unable to get my Application to detect the Delete button

I apologize in advance for this vague question but can anyone give me a pointer to this problem?
The Delete key does not work as normal in my application. e.g. The Delete key has no effect in an editbox (i.e. it will not delete highlighted text) but Shift Delete does work. This seems to be the case thoughout the application. I have disabled all keypreviews and OnKey events in case they were causing it but the problem persists.
Can anyone suggest where I might look for the problem?
Running Windows 10 Delphi 10.3.3
If this happens only in this particular application, it is likely that you have a TActionList or TActionManager with an action using Delete as its shortcut, or a simple menu item with such a shortcut.
For instance, you might have an Edit menu with a Clear item using Delete as its shortcut:
Then that action or menu item will respond to Delete, not allowing the focused control to do its own thing.
This kind of mistake is surprisingly common. For instance, in the Delphi IDE, you have an edit field above the editor, showing you the current class:
If you select this text and press Ctrl+C, you expect it to end up in the clipboard. But no! Instead, the selected text in the code editor (if any) is copied, even though the code editor didn't have keyboard focus.

Delphi - Activating the Hint from another control of Application

I'm trying to activate Hint from control of different application created from delphi upon focus, I'm using hook to identify the focused control, and then use WM_MOUSEMOVE, which I think will activate the Hint of that control, the handle would be the Control itself and the lParam is the Left and Top of the Control. The Control activate the OnMouseMove Event, but the Hint never shows. but when I use SetCursorPos, Hint show, but I need to show the Hint with out the cursor move on that Control. Can you please help me with this? Thank you in advance... by the way I'm using Delphi XE4
Among the really asked question is how to show the hint of a control that resides on another application (i am afraid without hook that application can not be done), the title is "Delphi - Activating the Hint from another control of Application".
First is first: That can be done without knowing what language the other app was done, but it is very complex to put it here (and i am not an expert on such way of coding, also i hate apps that work that way).
Second: The main idea is to hook the other application, search on Google some code of that apps, that can show you a rectangular hole square of the object the mouse is passing over, that application while doing it is iconized (i do not remember the name of it).
Waht such app does: As you move the mouse over the screen it overlays a rectangular over the control that mouse is over, then if you press the key to print screen, that small region is the only thing that goes to clipboard; on of such apps i saw had an extra funcion, they can move such controls if you press cursors on keyboard, also can hide/enable/disable such control... more, it can also make controls that are invisible to be visible, etc... i saw it working on my computer, and hey, for fun it is pretty and to DeBug or get extra things on some apps is also great (make some menús to be visible and enabled and then can use such funtions).
Please, please, understand i am agaist piracy and also against using such apps to let code to be run... some apps need pay for letting some menus enabled, but they have the code there, no need to change EXE to have/use that menus; just using this kind of apps makes that limited apps to be unlimited (just enable or show hidden menus and voila).
Note: To unhide menus, mouse point is not needed to be over the app, can be anywhere and is not moved.
The idea i want to say is: Any app can move, alter any control on any other app (at least on Windows) that is running, so maybe there can be a way to show such hint.
In the past i had use such app (sorry i do not remember the name) for DeBug my own apps, so i do not need to recompile in such cases where something was wrongly hidden, also work with buttons, labels, texts, combos, memos, etc.
Now my small problem is: I just need exactly what title say, but i can not make it to work.
Must be:
Mouse position must be irrelevant (it also must be able to be outside the application)
Just when a button that has focus is pressed with keyboard (Space or Enter) or just after some code somewhere on my application, i want to show the Hint of a specific TEdit for a short period of time.
I did not get Hint to be shown; not unless mouse point is over such TEdit but i want/need mouse pointer to not be over it, neither it to jump to the TEdit.
Idea Conept for that Hint to be shown: After doing some code that changes something, show extra info associated.
Example:
A button with that loads a file using an open dialog, filename is put on a ReadOnly TEdit (so it let user copy the text, but not change it); i want extra info that i punt on .Hint of such TEdit to be shown inmediatly.
That hint use is for not overload window with a lot of fields (TLabels) for showing such file data.
Simple idea: such Hint shows TimeStamp and size of the selected file.
P.D.: Not much related (since i am trying with a normal plain text hint), but hints can also store a full HTML page and with 3rd party tools be shown as an HTMLhint, so they can show a lot info of that file (also its content, etc) in a web based format; as i say i first try with standard plain text hints.
In order to show hint programatically you need to call TApplications ActivateHint method to which you specify the position parameter.
http://docwiki.embarcadero.com/Libraries/XE3/en/Vcl.Forms.TApplication.ActivateHint
Based on position parameter Application automatically finds which controll is at that position and shows its hint.
NOTE: Position parameter screen coordinates in pixels and not your controll coordinates. So you will have to use ClientToScreen method to change your coordinates apropriately.
You can see simple example of how to use this here: https://stackoverflow.com/a/15031208/3636228
Now if you need to do this from another application then you will have to add some comunication mechanizm to these two application so that one could send a proper message to tell the other to show the hint at specific position. But this does require you to be able to change both applications.
EDIT: This works with VCL applications but I'm not sure if it would work with FireMonkey applications.

Using barcode scanner with Delphi

I'm developing a POS (pet project) and I'm thinking of adding a bar code scanner to capture the sales faster. I do not have a scanner at the moment with me, and would like to ask some questions, as I'm stuck a bit.
On the sales screen my initial idea was to have an TEdit component and when a person scans the product it would fill the TEdit with the string. Now the problem I'm encountering is that I want to make the TEdit invisible so that the person does not see it. But once you make the TEdit invisible, you cannot set focus on it, so that plan cannot work.
So can anyone suggest what I can use to "capture" the scanned string? How would I make the component to listen and wait for the scanner? I assume that the scanner would be like a normal keyboard event, like button down or up.
There's KeyPreview property on TForm. Set it to true, so all key presses are processed by form first before controls.
Article about keyboard processing in Delphi: http://delphi.about.com/od/objectpascalide/a/keyboard_events.htm
Related SO question: How does Delphi's KeyPreview work?
What I have done is use the KeyPreview to monitor for a function key like F9 which the bar code scanner is set to prefix scans with. When this is received, I pop up a dialog with a single edit box and OK button. This then receives the rest of the barcode information, and the scanner ends the entry with the Enter key. I can then determine the purpose of the scanned data (in my case, one type starts with a prefix) and then put the data into the appropriate field on my main form.
I chose F9 because it seems inert in most applications, so you can use the scanner in other ways, but I support other keys too for flexibility. My application also has a scanner test mode where it shows the keys sent.
You can use a TEdit with a height and width of 0 so it won't appears and make sure it get focused when you scan your barcode.
You can also place the TEdit outside of the visible window, setting the component's Top and Left properties to something like -50. You can then set focus to it just like a regular visible TEdit box, but it will be invisible to the user.

Simulate F1 kepress on active control to load help system - Delphi

We are adding a help button to the toolbar of our application.
When the user clicks on this button, we need to load the help system for the control that they were on
For example, if they are on the address box of the contacts form, I need to load the help system for this using its context id
I was thinking about trying to mimic an F1 keypress which would then take care of the context id element of things and load the help file
However, I cant get this to work because it tries to load the help based on the active control not the one I was on, i.e. the contact address
Is there a way to do this? Essentially I need to send an F1 keypress from previously active control (assuming that the currently active control is my toolbar button)
We are using Delphi 2010
Cheers
Paul
I think you need a tool button OnClick handler that can be as simple as this:
procedure TMyForm.ToolButton1Click(Sender: TObject);
begin
if Assigned(ActiveControl) then begin
Application.HelpContext(ActiveControl.HelpContext);
end;
end;
What makes this work is the fact that the controls on a toolbar do not ever become the active control.
There's something wrong with your toolbar. The system toolbar doesn't ordinarily get the focus — it's never the active control. If you're using a real TToolBar and TToolButton, you won't have this problem. Even TSpeedButton won't have this problem. Use the right control for the job.
Also, don't try to "simulate" a keyboard event. Just call Application.HelpContext directly.

How to display tooltip or hint similar to Delphi XE tooltip code insight

I'm looking at wanting to implement a tooltip similar to the way Delphi XE does when you're debugging and you hover over an object. ie, it opens up a hint window with + signs which you can expand etc.
I'm trying to create a hint window which will show a list of items (for example) when hovering over a control (such as a button) which will let the user click on an item and I can then do something based on the item they've selected.
Are there any components out there that might do that already? Or am I better of just creating a borderless form and handle the showing/hiding myself with mouse events?
Thanks
Jason
I know there are hint components with embedded html. So you can have a kind of html treeview inside you hint!
I think it is a solution for you.
HTMLHint from TMS Software
THintBox from Cramon Utilities (freeware!)

Resources