Solved

DBGrid Onclick

Posted on 1997-11-13
5
520 Views
Last Modified: 2011-04-14
Since the DBGrid Object doesn't have an OnClick-Event,how do I know when it's clicked? And where?
PS. Can anybody help me on a book in which this sort of problem is dicussed? I'm getting tired of having to ask and bother you all the time,while there's some book with the solutions already in it!
0
Comment
Question by:lizzzard
  • 3
  • 2
5 Comments
 
LVL 3

Accepted Solution

by:
Pegasus100397 earned 50 total points
ID: 1350352
Lizzard,

Interesting question!

Try this in the Private declarations

procedure WMMouseActivate(VAR Msg)
    message WM_MOUSEACTIVATE

then

procedure TForm1.WM_MOUSEACTIVATE(Var Msg);
Begin
Form1.Caption := 'Mouse clicked!';
end;

you could expand this to indicate which control sent the click but it works well on my dbGrid :)

One of the best books for offbeat, strange Delphi solutions is:
DELPHI PROGRAMMING PROBLEM SOLVER
by Neil Rubenking
ISBN #1-56884-795-5

Good luck with your project!
Pegasus

0
 

Author Comment

by:lizzzard
ID: 1350353
Dear Pegasus,

Thanks for your answer and I almost got it working except for on e thing..:)
The click on the dbgrid is to check or uncheck a checkbox that is on it. In order to write the code for updating the physical field and the checkboxdrawing I'll have to know what column was clicked. If I try to use dbgrid.selectedfield.fieldname it's always 1 click behind on the Tform.WM_MOUSEACTIVATE event you suggested,so in the code fired by the click I still don't know wether or not to update the field. Or have I done this al wrong in the first place? Please help me...

Regards Lizzzard (alexg@molyvos.net)
0
 
LVL 3

Expert Comment

by:Pegasus100397
ID: 1350354
Lizzzard,

Sorry for the long time to reply, I've been out with the flu for a week or two. Look in the Win32s help file for the WM_MOUSEACTIVATE keyword and it will show you how to determine not only what the mouse action was, but WHO (or what in this case, like a column) actually sent the click message. If you get into a bind or can't understand it lemme know and I'll hunt down some examples.

By the way, why do the checkboxes in the grid NOT work? They should work by default unless the column is disabled or marked as read-only. Let me know

Thanks & good luck!
Pegasus
0
 

Author Comment

by:lizzzard
ID: 1350355
Hi Pegasus,

Hope you're better now (lots of orangejuice?). Thanks for your comment. I managed to get it working and it works great!
I only programmed 4GL till a vew months ago, Then I started with Delphi and at first I was hopelessly lost in 3GL language. But now things start to work out and I really enjoy programming Delphi.
Thanks for all the good advices!

Lizzzard
0
 
LVL 3

Expert Comment

by:Pegasus100397
ID: 1350356
Heya Lizzzard,

Glad to hear the problem is solved! Also glad to hear you *started* programming in Delphi instead of a real-language wanna-be like Visual Basis hehehaha Everything you learn with Delphi will only lead you to be utterly dissappointed with the limitations of other languages ;^D

Pegasus
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

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…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

708 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

13 Experts available now in Live!

Get 1:1 Help Now