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.
Related
I have a TTaskDialog that has an OnButtonClicked event handler, in which a lengthy process (several seconds) is performed. This works fine, but I'd like some indication to the user that things are happening while that lengthy process is chugging along. I would like to have a marquee progress bar on the dialog that is initially hidden, appears when the CommandLink is clicked, and runs while the lengthy process is performed - I'd settle for a progress bar that is visible but not enabled when the dialog is displayed and is "turned on" in the OnButtonClicked event. Just including the tfShowMarqueeProgressBar flag causes the bar to appear and be scrolling when the dialog first displays, and the ProgressBar property of the dialog doesn't have Enabled or Visible type properties to control this behavior.
There are TaskDialogs in Windows itself that do what I want, so I know it's theoretically possible, though I realize that the structure of the VCL wrapper around the native control may make it difficult or impossible using the VCL object.
Is what I want possible using the TTaskDialog VCL object?
The Windows API provides the message TDM_NAVIGATE_PAGE to change the TaskDialog at runtime. You would have to pass a TASKDIALOGCONFIG structure along with this message that defines the dialog's properties. In its dwFlags field you could specify the TDF_SHOW_PROGRESS_BAR flag to show the progress bar. But this requires a lot of work as the other fields in the TASKDIALOGCONFIG structure must match the properties that you have set for Delphi's TTaskDialog component.
Delphi creates a TASKDIALOGCONFIG structure as a local variable in the function TCustomTaskDialog.DoExecute in Dialogs.pas that is used to display the TaskDialog.
Is there a way to setup Gimp to use a held key (e.g control or alt) to do the same as mouse click?
The general answer is no.
There are some mouse clicks in the tool boxes and editor dialogs which change parameters (like brush size) - these are mapped as "actions" inside GIMP and you can create keyboard shortcuts for them (including using the F keys) under Edit->Preferences->Interface->Edit Keyboard Shortcuts...
But probably that is not what you want - the main mouse button-click effect in GIMP is stroking the image with a paint tool - and that is wired in a different way inside the program: it can't be replaced by a keypress.
However, there are different painting devices that can be used that might serve your needs - a graphics tablet like those sold by Wacon provide a fundamentally different interface than mouse not just for GIMP, but for all drawing programs.
And GIMP is somewhat a unique program that can actually make use of a MIDI controler
(like a MIDI foot controller) to control the pressure of the painting - so, if your problem is getting rid of the "click and hold" action for painting with the mouse, a proper configured such peripheral could serve you.
That said, this question would be ontopic for https://graphicdesign.stackexchange.com/ and is offtopic here - I hope someone can move both the question and this answer there.
If GIMP does not allow such function. I have a suggestion, if you are using Ubuntu you can enable mouse control by numeric keypad as explained here. After enabling mouse control by numeric keypad you must turn Num Lock ON and press the key 5 to simulate a mouse click.
One workaround I use is to rebind an unused key to left mouse button, through macro or some other method.
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.
I have an interesting observation and question, but first a comment. I have been using Delphi for 14 years and have taken a job developing an iOS mobile application using XE5. This is my first time using FMX and frankly I feel like I am stepping back in time many moons ago. In other words, if this is the future, then it feels like I have crippled. No problem though. Roll with the punches. Developing in this brave new world is not just a job. It is an adventure.
Now my question. Start a FMX mobile project using the "Header/Footer with Navigation" as your base. Then add an edit control (Edit1) to the first tab item. Then set the tab control align to none and move it to the right until you can clearly see the form itself. Then add an edit control (Edit2) to the form.
Now set the form's active control to Edit1 and run the app - no focus on Edit1. Now set the form's active control to Edit2 and run the app - focus is placed on Edit2. Interesting. Tab is a foreign word to tablets, right? Why have active control or even setfocus available? Is this an oversight by Embarcadero? Any thoughts?
Long story short I think they both have potential uses.
I use the SetFocus call to manually show the keyboard. Lets say the user navigates to a page where they're 100% sure to be putting in their username (or any text), I'll use ctrl.SetFocus to show the keyboard just to save them having to click (or is it press now?) on the edit.
I don't see ActiveControl being as useful, but it could definitely still be used. You could possibly use it to set up some sort of tabbing like structure for when the user presses Next on the keyboard (when the edit's ReturnKeyType is rkNext).
Okay, I have an on-screen keypad made up of a panel with buttons with the kind of functionality you would expect 0 .. 9, Delete, BkSpace and Enter. It's an application for a touchscreen system.
The values entered by "pressing" the keys are shown in a TEdit. Almost all of it works perfectly, but I have an issue with passing a keystroke to the TEdit control when I want to backspace within the TEdit. I can simply delete the last character in the TEdit by using the Copy function and I guess I could do something similar for Delete.
But it would be much neater to pass the "key" button tag for backspace to the TEdit control and have it convert that to VK_BACKSPACE or VK_DELETE.
The problem is that while I've captured and used the virtual keycodes before, I've never tried to pass one to a control's event before and I can't find anything which really helps, either here or doing a general search or trawling through the Embarcadero documentation.
I'm sure this is dreadfully simple and I'm missing something easy, but could somebody point me at it, please?
I think you are looking for the SendMessage() method. Here is an example:
http://www.swissdelphicenter.ch/de/showcode.php?id=220