Solved

Floating a control over a dbgrid

Posted on 1998-01-18
15
233 Views
Last Modified: 2010-04-04
I am kind of stuck with the following:
I am currently floating a control (datepicker  from rxlib) over a grid with the following code:

procedure TLog.LogGridDrawColumnCell(Sender: TObject; const Rect: TRect;
  DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
    If DataCol = 0 then begin
      If LogModule.tblLog.State in [dsEdit, dsInsert] then begin
        If (gdFocused in State) then begin
         Date.Left := LogGrid.Left + Rect.Left;
         Date.Top := LogGrid.Top + Rect.Top;
         Date.Width := Rect.Right - Rect.Left;
         Date.Visible := True;
        end;
       end;
      end;
   end;

And  when I want to make the control invisible again I use the following code:

procedure TLog.LogGridColExit(Sender: TObject);
begin
  If LogGrid.Columns[0].Title.Caption = Date.Name then
 Date.Visible := False;
end;

Ok now to my question:

How do I make the control invisible when I click on the horizontal scroll bar and also when I click on a component outside of the grid.


P.S.   If you try the code above you will see it only makes the control invisible when I click on another field in the grid.

Thanks in advance for any help you can provide.

Note to Igor

If it would not take up much of your time then I think coming up with a
away to override the dbgrid would be the  best bet. And since this sound like a big task I have increased the points as you can see.

 
0
Comment
Question by:delbrad
  • 7
  • 4
  • 2
  • +1
15 Comments
 
LVL 5

Expert Comment

by:inter
ID: 1356959
Dear delbrad,
I can not find an easy way to your problem. Especially for scrolling, we have to oportunities. Either, create a new componenent from TDBGrid which also includes datepicker and handle WMVScroll and WMHScroll messages or in run-time, tell windows to send scroll commands to one of your methods. Or we may try to find a DBGrid component in which we can receive scrolling messages.

Which one do you prefer, If you want to override the component I try to help but it may took few hours(or an hour if no bugs, etc) or we may try to capture the scroll event.
Please notify!
Igor
0
 

Author Comment

by:delbrad
ID: 1356960
Edited text of question
0
 

Author Comment

by:delbrad
ID: 1356961
Adjusted points to 150
0
 
LVL 5

Expert Comment

by:inter
ID: 1356962
With joy I try to override it, however, in my time zone it is 24:25 now. So, if I can handle, I ask you to send you email. But if any one have a more briliant idea, I will see on tomorrow.
Note : I plan to combine DBGrid and datepicker so that you can set the column of it an it works as you want OK?
Thanks,
Igor
0
 
LVL 5

Expert Comment

by:inter
ID: 1356963
Hi delbrad
Notify me when you there, I am fixing up few things. It will be yours in a while.
Igor,(sleepless old guru)
0
 
LVL 5

Expert Comment

by:inter
ID: 1356964
I should leave, now. Since I do not have an internet connection at home, I can not send you the component.
Sorry,
Sincerely,
Igor
0
 
LVL 1

Expert Comment

by:millerw
ID: 1356965
Well I have your solution--this procedure is from a program I'm currently writting that uses the technique:

procedure TfrmJournalPosting.dbgTransactionsDrawColumnCell(Sender: TObject;
  const Rect: TRect; DataCol: Integer; Column: TColumn;
  State: TGridDrawState);
var
   Point     : TPoint;
   OutputStr : String;
begin
     Point.X := 1;
     Point.Y := 1;

//THESE LINES ARE THE ONES THAT WORK--AS YOU CAN SEE THERE IS
//A COLUMN RESIZING PROBLEM THAT IT FIXES TOO--WORKS WHEN YOU
//MAKE IT WIDER, BUT NOT WHEN YOU MAKE IT NARROWER :-)
     If (Sender as TDBGrid).ControlAtPos(Point, True) <>
        TControl((Sender as TDBGrid).Columns.Items[0]) then
        dlcAccountNum.Visible := False; //Fixes scrolling problem
     If Column.Field.FieldName = dlcAccountNum.DataField then
        dlcAccountNum.Width := Column.Width + 1; //Fixes column resizing problem
     If ((gdFocused in State) or (gdSelected in State)) and
        (Column.Field.FieldName = dlcAccountNum.DataField) and
        (Screen.ActiveControl = dbgTransactions) then
     begin
          dlcAccountNum.Left := Rect.Left + (Sender as TDBGrid).Left + 1;
          dlcAccountNum.Top := Rect.Top + (Sender as TDBGrid).Top + 1;
          dlcAccountNum.Visible := True;
     end
end;

To make it invisible when you exit, just define the following procedure for the OnExit event of the grid:

procedure TfrmJournalPosting.dbgTransactionsExit(Sender: TObject);
begin
     if Screen.ActiveControl <> dlcAccountNum then
        dlcAccountNum.Visible := False;
end;

There is a BIG problem with this however.  If you click on the column that uses the DateTimePicker and it is selected but the "floater" is not active (has been set invisible) the grid will pick it up and enter edit mode.  My suggestion to you is to just forget about doing it yourself and buying a product like InfoPower or SofTouch to do what you want.  Here are their sites:

www.woll2woll.com
www.softouchdev.com

If you have problems, I can give you all of the code dealing with the floating--just write me if you need it all or not.  What I gave you should work as is as long as you change all the references to your components and cut out what references things specific to my program.

Good Luck,
Scott

0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 5

Expert Comment

by:inter
ID: 1356966
Hi delbrad,

I am back again, the component is about 200 lines of code. Do you want me to send it as a comment or e-mail it to you.

I am waiting for your request
Igor
0
 

Author Comment

by:delbrad
ID: 1356967
To Igor
From delbrad
 
If you can, could you email it directly to me at

delbrad@brigadoon.com

P.S. Thank you for all your help!
0
 
LVL 5

Accepted Solution

by:
inter earned 150 total points
ID: 1356968
Got, it?
Please, try it with and send bug report!(Then I'll fix them and you go on your program)

Sincerely,
Igor
0
 
LVL 1

Expert Comment

by:millerw
ID: 1356969
Why the rejection?  Did you even try it?  An explanation of why you rejected would be nice so that I can improve the answer to your expectations.  

Scott
0
 

Author Comment

by:delbrad
ID: 1356970
To Igor

Currently the component is working, will advise if I find a bug


Thank you again.
0
 
LVL 3

Expert Comment

by:karouri
ID: 4739191
One actually feels good when he wants to find the answer to a previous question and pays 15 point only just to find the answer is in some e-mail. Isn't it?!
0
 
LVL 5

Expert Comment

by:inter
ID: 4744791
My friend, we are always here to serve, writedown a 0 point question, I would deal(note that this question is dated back to Jan 1998, delphi components change much (at least10 million new was created by this time) so, this solution may not be what you want in after 2 and a half year later, anyway

igor (inter)
0
 
LVL 3

Expert Comment

by:karouri
ID: 4755039
I have posted a question, igor, and I will bevery thankful for your help..
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

762 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

20 Experts available now in Live!

Get 1:1 Help Now