Solved

Floating a control over a dbgrid

Posted on 1998-01-18
15
234 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …

932 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

10 Experts available now in Live!

Get 1:1 Help Now