Solved

Touch Screen Monitor Button

Posted on 2004-09-12
19
520 Views
Last Modified: 2010-04-05
Hi Everyone!

I am creating an application that will be using a touchscreen instead of the mouse pointer.

The problem now is that if i used the TButton or any buttons found on DELPHI, it hardly responds when i placed my hands on the screen or it do responds but the button seems not to work as pressed.

Anybody here knows how to create a sensitive button? when  i press the button, the button image is "down" when i get my fingers off the button then it may look as "Up" or in normal state.

Thanks in advance!

0
Comment
Question by:girlswants_me
  • 8
  • 6
  • 4
  • +1
19 Comments
 
LVL 11

Expert Comment

by:robert_marquardt
ID: 12041633
A touchscreen is an absolute pointing device. It is a mouse and is handled as mouse by Windows.
Your problems have to be elsewhere. Obviously you do not get the messages as expected.
Probably the driver gives you only MouseDown/MouseUp pairs if you tap on the screen.
This is standard touchscreen behavior. It is an interpretation of the touchscreen driver.
In fact there is no way that the touchscreen driver can generate separate MouseDown and MouseUp messages.
0
 
LVL 12

Expert Comment

by:esoftbg
ID: 12041682
download an example for Touch Screen Monitor (it works great) from:
page:        http://www.geocities.com/esoftbg/
  link:        Q_21122981.zip
0
 

Author Comment

by:girlswants_me
ID: 12041702
Have you tried to run your TButton on the touchscreen?
I have 1 touch screen here, when uses a mouse pointer i can see the button image changes to "Down" then "Up"
when i use my fingers, the button will not stay to "Down" but instead remains to "UP" and run the showmessage('ss') instead.

procedure onclick(Sender:TObject);
begin
 showmessage('ss');
end;

i also tried the onmousedown event still dont serve the purpose.
0
 
LVL 12

Expert Comment

by:esoftbg
ID: 12041968
I just uploaded an improved version on the above example which buttons after pressing holds down (you alwais see the last pressed button). If you would like to see how OnPress button is Down and after a while is back Up, I could do that ....
0
 
LVL 11

Expert Comment

by:robert_marquardt
ID: 12042407
The easiest solution is to install the control panel for disabled persons which should allow to make the mouse buttons click & lock,
ie first click generates only mouse down whereas next click generates only mouse up.
0
 

Author Comment

by:girlswants_me
ID: 12050958
esoftbg,

How can i cannot run your apps? im using delphi 3 here and whenever i open your apps. it prompts me a "Variant" error etc..

0
 

Author Comment

by:girlswants_me
ID: 12051611
Sorry for the poor english.
0
 
LVL 12

Expert Comment

by:esoftbg
ID: 12051649
Oh, I didn't know you use Delphi 3. My example is written by Delphi 7....
0
 
LVL 12

Expert Comment

by:esoftbg
ID: 12051677
May be you have to delete Variants from the uses-clause, but I'm not sure. I have Delphi 5, Delphi 6 and Delphi 7 on CD Roms, but I have not Delphi 3 ....
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

Author Comment

by:girlswants_me
ID: 12051765
I know this sounds "dumn", can you share me a copy of those delphi you have?
0
 
LVL 12

Expert Comment

by:esoftbg
ID: 12051842
Even you promise to use Delphi 7 only for evaluation purposes, how can I share 651 MB ?
0
 

Author Comment

by:girlswants_me
ID: 12052340
How about splitting it by 60mb each and i will just download it tru FTP. Anyway, still i can't ran the apps you created on my delphi 3.0
0
 
LVL 11

Expert Comment

by:robert_marquardt
ID: 12052430
Please no illegal activities here!
0
 
LVL 12

Expert Comment

by:esoftbg
ID: 12052531
Sorry girlswants_me, you see that's illegal !
0
 

Author Comment

by:girlswants_me
ID: 12052650
That's OK, i understand. sorry.

anyway, what should i do with the button problem????
0
 
LVL 12

Expert Comment

by:esoftbg
ID: 12053048
This code will keep the SpeedButton1 dow for about 2 seconds:
Ofcourse you should add your own code here

procedure TForm1.SpeedButton1Click(Sender: TObject);
var
  B:      Boolean;
  DTB:    TDateTime;
  DTC:    TDateTime;
begin
  if (Sender is TSpeedButton) then
  with (Sender as TSpeedButton) do
  begin
    DTB := Now;
    DTC := DTB;
    B := True;
    Down := True;
    while B do
    begin
      B := (DTC-DTB<0.000016);
      DTC := Now;
      Down := B;
    end;
  end;
end;
0
 
LVL 11

Expert Comment

by:robert_marquardt
ID: 12055638
Still the basic problem is that the touchscreen always generates a mouse down and a mouse up aka click when you touch it.
Touching and moving is only mouse movement not mouse click.
0
 
LVL 12

Accepted Solution

by:
esoftbg earned 125 total points
ID: 12064095
Or better using GetTickCount function retrieves the number of milliseconds that have elapsed since Windows was started.

procedure TForm1.SpeedButton1Click(Sender: TObject);
var
  B:      Boolean;
  GTCB:   Cardinal; // DWORD;
  GTCC:   Cardinal; // DWORD;
begin
  if (Sender is TSpeedButton) then
  with (Sender as TSpeedButton) do
  begin
    GTCB := GetTickCount;
    GTCC := GTCB;
    B := True;
    Down := True;
    while B do
    begin
      B := (GTCC-GTCB<1000);
      GTCC := GetTickCount;
      Down := B;
    end;
  end;
end;
0
 
LVL 2

Expert Comment

by:insomniac92
ID: 12072786
Have you looked at the settings for the touch screen. Normally the drivers for the touch screen have modes you can set the screen to. I can't remember off hand, but these are usually something like drawing mode, button mode, etc...I know Microtouch screens have this setting. These settings can make a big difference to how your buttons react when you press on them.
Cheers


0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now