Autor Beitrag
Aton
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 125

Windows XP
D7 Enterprise
BeitragVerfasst: Mo 05.04.04 11:18 
Hallo Forum,

ich habe in meinem StringGrid dynamische Checkboxen drin. Die werden so erzeugt:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
  CheckBox[Nr] := TCheckBox.Create(self);
  with CheckBox[Nr] do begin
    Visible := True;
    Width := 12;
    Height := 12;
    Color := clBtnFace;
    ParentWindow := EDImportMainForm.Handle;
  end;


Im StringGrid werden sie bei OnDrawCell folgendermaßen dargestellt:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
      with CheckBox[ARow-1] do begin
        CopyRect(R, Rect);
        R.TopLeft :=     EDImportMainForm.ScreenToClient(
                         StringGrid.ClientToScreen(R.TopLeft));
        R.BottomRight := EDImportMainForm.ScreenToClient(
                         StringGrid.ClientToScreen(R.BottomRight));
        SetBounds(R.Left+1, R.Top, R.Right-R.Left-4, R.Bottom-R.Top-3);
        BringToFront;  
      end;


Jetzt habe ich folgendes Problem:

Entweder, die CheckBoxen gehen nach unten über das StringGrid heraus. Das wird wohl daran liegen, dass als ParentWindow das ganze Formular zugewiesen wird. Wenn ich aber als ParentWindow das StringGrid zuweise, kann ich die CheckBoxen nicht mehr anklicken!

Wann kann ich tun, damit die CheckBoxen innerhalb der StringGrid bleiben und anzuklicken sind??

Danke,
Gruß Jens.

Moderiert von user profile iconMotzi: Quote- durch Delphi-Tags ersetzt.
Aton Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 125

Windows XP
D7 Enterprise
BeitragVerfasst: Mi 07.04.04 16:00 
Hallo,

ich habe das Problem pseudo-gelöst. Und zwar bringe ich jetzt jedes mal das darunterliegende Panel in den Vordergrund.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
    with CheckBox[ARow-1] do begin 
        CopyRect(R, Rect); 
        R.TopLeft :=     EDImportMainForm.ScreenToClient( 
                         StringGrid.ClientToScreen(R.TopLeft)); 
        R.BottomRight := EDImportMainForm.ScreenToClient( 
                         StringGrid.ClientToScreen(R.BottomRight)); 
        SetBounds(R.Left+1, R.Top, R.Right-R.Left-4, R.Bottom-R.Top-3); 
        BringToFront;<span style="color: red">
        Panel_Dadrunter.BringToFront;</span>
      end;


Die CheckBoxen, die nach unten herausragen, werden jetzt durch das Panel überzeichnet. Leider hat die Sache einen kleinen Hacken, nämlich der Rand des StringGrids wird auch überzeichnet...

Wenn jemand eine saubere Lösung weiß, wäre ich sehr dankbar. :nixweiss:

Gruß Jens.