Autor Beitrag
galbe19
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 56



BeitragVerfasst: So 17.06.07 16:05 
Hallo

wie kann ich einstellen das ich den Scroll von der mouse in einem DBGrid benutzen kann?

mfg
alex
Andreas Schilling
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 128
Erhaltene Danke: 1

WIN XP, WIN 7
Delphi 5 Ent, Delphi 2007 Pro, XE4
BeitragVerfasst: Mo 18.06.07 06:09 
Ich benutze dazu eine Applicationsevent-Komponente
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
procedure TForm1.ApplicationEvents1Message(var Msg: tagMSG;
  var Handled: Boolean);
  var  i: SmallInt;
begin
   if Msg.message = WM_MOUSEWHEEL then
   begin
     Msg.message := WM_KEYDOWN;
     Msg.lParam := 0;
     i := HiWord(Msg.wParam) ;
     if i > 0 then
     begin
       DBGrid.datenquelle.Prior;
     end
     else begin
       DBGrid.Datenquelle.next;
     end;

     Handled := False;
   end;
end


Es scrollt auch dann im Grid, wenn das nächste Formular geöffnet wird und dort das Scrollrad bewegt wird.
galbe19 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 56



BeitragVerfasst: Di 19.06.07 15:06 
Hallo

ich werstehe ein bischen die dattenquelle nicht.
wenn ich sie so kopiere wie sie ist bekomme ich error meldungen.
was muss ich andern das es funktioniert?

mfg
alex
Andreas Schilling
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 128
Erhaltene Danke: 1

WIN XP, WIN 7
Delphi 5 Ent, Delphi 2007 Pro, XE4
BeitragVerfasst: Di 19.06.07 15:29 
dbgrid.datenquelle ist die TTable oder TDataset oder TQuery oder ..., was über das Datasource mit dem datengrid verbunden ist und die Daten zum Anzeigen liefert. War also nur ein Dummy. Also statt dbgrid.datenquelle.prior dann Table1.prior.
galbe19 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 56



BeitragVerfasst: Fr 22.06.07 11:09 
ich habe es geschaft aber trotzdem habe ich ein kleines problem.
ich habe tabl1.prior eingetellt.
meine table1 ist in einem DBGrid.
wenn ich es so mache beim scrollen scrollt mir die tabll1 in dbgrid aber nur die pozitionen die man zum moment in DBgrid sieht(zB ich sehe poztion 1-10, ich bin gerade auf 6 und dann bewegt sich der cursor bis 1 und bis 10 )
also es funktioniert nicht das das DBGrid scrollt selbst scrollt un ich alle pozitionen sehe.

was muss ich machen.

mfg alex
galbe19 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 56



BeitragVerfasst: Fr 22.06.07 13:19 
hallo

ich habe die Applicationsevent-Komponente ins programm eingebracht.
aber jetzt ein sehr dumme Frage.
wo rufe ich sie auf und wie?

mfg
Alex
FiceGoesDelphi
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 485

Win XP Prof
Delphi 2006
BeitragVerfasst: Fr 22.06.07 13:21 
Versuchs doch mal mit F1 ...
Die OH (OnlineHilfe) von Delphi ist sehr gut!

_________________
<(^^<) <(^^)> (>^^)>
===================
galbe19 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 56



BeitragVerfasst: Fr 22.06.07 14:42 
Hallo

ich habe es geschaft es zu machen aber ich habe ein aderes Problem.
ich habe 2 DBGrid auf meiner Form.
wie kann ich es machen damit nur wenn ich auf einem DbGrid bin das es scrollt.
ich habe es versucht mit if DBGrid.visible=true..
aber es funktioniert nicht

habt ihr eine Idee?

mfg
Alex
galbe19 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 56



BeitragVerfasst: Do 28.06.07 07:59 
hallo

ich habe es geschaft mit dem scroll aber habe ein anderes problem und zwar.
ich habe 2 DBgrids und wie kann ich auswählen damit wenn ich in eienem DbGrid bin den scrolle und wenn ich in den anderen bin den Scrolle?

mfg
Alex
Andreas Schilling
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 128
Erhaltene Danke: 1

WIN XP, WIN 7
Delphi 5 Ent, Delphi 2007 Pro, XE4
BeitragVerfasst: Do 28.06.07 10:19 
Musste ich erstmal ausprobieren.
So wird das Grid gescrollt, über dem sich die Maus befindet, wenn das Scrollrad betätigt wird.
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
procedure TForm1.ApplicationEvents1Message(var Msg: tagMSG;
  var Handled: Boolean);
  var  i: SmallInt;
      Maus : TPoint;
      PanelTop : integer;
begin
   if Msg.message = WM_MOUSEWHEEL then
   begin
     Msg.message := WM_KEYDOWN;
     Msg.lParam := 0;
     i := HiWord(Msg.wParam) ;
     // Mausposition bestimmen auf Bildschirm
     GetCursorPos(Maus);

     // was befindet sich noch über den DBGrids
     // self.top = der Abstand des Formular vom oberen Bildschirmrand
     // Panel_Kopf = ein Panel mit tasten
     // 27 = Form1.height - Form1.clientheight
     paneltop := self.top + Panel_Kopf.Height + 27;
     // die beiden DBGrid sind so breit wie Formular, also ist da nur Form1.left/ self.left wichtig

     // wenn Mausposition innerhalb Position Grid1 then scrolle Table1
     if (maus.x > DBGrid1.left + self.left)
     and (maus.x < (DBGrid1.left + DBGrid1.Width + self.left))
     and (maus.y > (PanelTop + DBGrid1.top))
     and (maus.y < (paneltop + DBGrid1.top + DBGrid1.Height))
     then begin
       if i > 0 then
       begin
         Table1.Prior;
       end
       else begin
         Table1.next;
       end;
     end;

     // wenn Maus über Grid2 dann scrolle Table2
     if (maus.x > DBGrid2.left + self.left)
     and (maus.x < (DBGrid2.left + DBGrid2.Width + self.left))
     and (maus.y > (PanelTop + DBGrid2.top))
     and (maus.y < (paneltop + DBGrid2.top + DBGrid2.Height))
     then begin
       if i > 0 then
       begin
         Tabel2.Prior;
       end
       else begin
         Table2.next;
       end;
     end;
     // mausposition ausserhalb der beiden Grids --> dann passiert nichts

     Handled := False;
   end;
end;
galbe19 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 56



BeitragVerfasst: Do 28.06.07 10:41 
Danke

ich habe an der idee mit der Mouse nicht gedacht nur an andere.

Vielen Dank

mfg
Alex