| Autor |
Beitrag |
DiamondDog
      
Beiträge: 460
|
Verfasst: Mo 08.12.08 14:17
Hallo Leute,
kann mir jemand von euch sagen wie ich es hinbekomme das von meinem Text, auch die 2te Zeile angezeigt wird?
Hier mein Code:
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: 56: 57: 58: 59: 60: 61: 62: 63:
| var ContactId : DWord; Cnv : TCanvas; R : PRect; wStr : WideString; R1 : TRect; TestIcon : HICON; begin if not Assigned(FfrmMain) then Exit; ContactId := FfrmMain.PlugMsg1.WParam;
if (ContactId <> FfrmMain.UniqContactId) then Exit;
Cnv := TCanvas.Create; try
Cnv.Handle := PlugMsg.NParam;
R := PRect(PlugMsg.Result);
SetBkMode(Cnv.Handle, TRANSPARENT);
TestIcon := LoadImage(0, IDI_INFORMATION, IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR or LR_SHARED or LR_LOADTRANSPARENT); DrawIconEx(Cnv.Handle, 8, 2, TestIcon, 16, 16, 0, 0, DI_NORMAL); DestroyIcon(TestIcon);
wStr := FfrmMain.Label1.Caption;
Cnv.Font.Name := 'Tahoma'; Cnv.Font.Color := clNavy; Cnv.Font.Size := 8; Cnv.Font.Style := [fsBold];
R1 := Rect(R^.Left + 26 + FSpecLeft, R^.Top + 1 + FSpecTop, R^.Right, R^.Bottom);
DrawTextW(Cnv.Handle, PWideChar(wStr), Length(wStr), R1, DT_LEFT);
finally Cnv.Free; end; end; | ich hab schon ein wenig gesucht und probiert, aber irgend wie krieg ich es nicht hin.
Danke schon mal fürs Helfen.
Mfg Dog
Edit:
Label1 sieht so aus:
Text +#10#13+ Text
Zuletzt bearbeitet von DiamondDog am Mo 08.12.08 14:59, insgesamt 1-mal bearbeitet
|
|
DeddyH
Ehemaliges Mitglied
Erhaltene Danke: 1
|
Verfasst: Mo 08.12.08 14:43
Versuch es mal mit dem Flag DT_WORDBREAK bei DrawText, außerdem ist unter Windows ein Zeilenumbruch #13#10.
|
|
DiamondDog 
      
Beiträge: 460
|
Verfasst: Mo 08.12.08 14:58
Also habs so gemacht:
Delphi-Quelltext 1:
| DrawTextW(Cnv.Handle, PWideChar(wStr), Length(wStr), R1, DT_LEFT+DT_WORDBREAK); | das funktioniert aber leider nicht wird immer noch nur die erste Zeile angezeigt.
Und da hab ich mich in der Eile wohl verschrieben sorry, habs koriegiert.
|
|
Nersgatt
      
Beiträge: 1581
Erhaltene Danke: 279
Delphi 10 Seattle Prof.
|
Verfasst: Mo 08.12.08 15:02
DiamondDog hat folgendes geschrieben : | | DT_LEFT+DT_WORDBREAK |
Versuch es mit DT_LEFT OR DT_WORDBREAK
Gruß,
Jens
|
|
DiamondDog 
      
Beiträge: 460
|
Verfasst: Mo 08.12.08 15:07
Immer noch das selbe Ergebniss, man sieht nur die erste Zeile
|
|
Nersgatt
      
Beiträge: 1581
Erhaltene Danke: 279
Delphi 10 Seattle Prof.
|
Verfasst: Mo 08.12.08 15:15
Komisch. Folgendes wird bei mir in 2 Zeilen ausgegeben:
Delphi-Quelltext 1: 2: 3: 4: 5: 6: 7: 8: 9: 10:
| procedure TForm1.Button1Click(Sender: TObject); var r : TRect; sText : WideString; begin sText := 'Test' + #13 + '2. Zeile'; r.Left := 0; r.Top := 0;
DrawTextW(self.Canvas.Handle,PWideChar(sText), length(sText), r, DT_LEFT or DT_WORDBREAK); end; |
Bist Du sicher, dass in deinem Text ein Zeilenumbruch drin ist? Ich habe es mit #13#10, #10 und #13 probiert. Alle Möglichkeiten funktionieren.
Gruß,
Jens
|
|
DiamondDog 
      
Beiträge: 460
|
Verfasst: Mo 08.12.08 15:21
Ja bin mir 100%tig sicher.
Hab es auch extra noch mal so getestet:
Delphi-Quelltext 1: 2:
| wStr := 'Das ist'+#10#13+'Ein Test'; | führ aber zum selben Ergebniss wie die andern male auch.
Edit liegt es vll an der Zeile:
Delphi-Quelltext 1:
| R1 := Rect(R^.Left + 26 + FSpecLeft, R^.Top + 1 + FSpecTop, R^.Right, R^.Bottom); |
|
|
Nersgatt
      
Beiträge: 1581
Erhaltene Danke: 279
Delphi 10 Seattle Prof.
|
Verfasst: Mo 08.12.08 15:27
DiamondDog hat folgendes geschrieben : |
Edit liegt es vll an der Zeile:
Delphi-Quelltext 1:
| R1 := Rect(R^.Left + 26 + FSpecLeft, R^.Top + 1 + FSpecTop, R^.Right, R^.Bottom); | |
das war auch mein Gedanke. Vielleicht ist Dein Rect zu klein. Die 2. Zeile wird zwar gezeichnet, aber weil das Rect zu klein ist, nicht angezeigt.
Gruß,
Jens
|
|
DiamondDog 
      
Beiträge: 460
|
Verfasst: Mo 08.12.08 15:37
Ok habs nun so versucht:
Delphi-Quelltext 1:
| R1 := Rect(R^.Left + 26 + FSpecLeft, R^.Top + 1 + FSpecTop, R^.Right+10, R^.Bottom+10); | Mir wird die 2te Zeile angezeigt aber nur so gerade ebend, so das man sehn kann das da was ist. Aber egal ob ich jetzt + 10 oder + 100 dahinter setze es wird kein Stück größer.
|
|
DeddyH
Ehemaliges Mitglied
Erhaltene Danke: 1
|
Verfasst: Mo 08.12.08 15:51
Es gibt ja auch noch DT_CALCRECT, damit kann man errechnen lassen, wie hoch das Rechteck sein muss, um den ganzen Text anzuzeigen.
|
|
DiamondDog 
      
Beiträge: 460
|
Verfasst: Mo 08.12.08 18:58
Wenn ich es so mache:
Delphi-Quelltext 1:
| DrawTextW(Cnv.Handle, PWideChar(wStr), Length(wStr), R1, DT_LEFT OR DT_WORDBREAK OR DT_CALCRECT); | dann wird kein Text mehr angezeigt.
Kannes vll auch an dem Bild was vorher gezeichnet wird liegen?
|
|
DeddyH
Ehemaliges Mitglied
Erhaltene Danke: 1
|
Verfasst: Di 09.12.08 12:05
Wirft eigentlich außer mir noch irgendwer gelegentlich einen Blick in die Hilfe?
| Zitat: | DT_CALCRECT
Determines the width and height of the rectangle. If there are multiple lines of text, DrawText uses the width of the rectangle pointed to by the lpRect parameter and extends the base of the rectangle to bound the last line of text. If there is only one line of text, DrawText modifies the right side of the rectangle so that it bounds the last character in the line. In either case, DrawText returns the height of the formatted text but does not draw the text. |
|
|
DiamondDog 
      
Beiträge: 460
|
Verfasst: Mi 10.12.08 09:06
DeddyH hat folgendes geschrieben : | Wirft eigentlich außer mir noch irgendwer gelegentlich einen Blick in die Hilfe?
| Zitat: | DT_CALCRECT
Determines the width and height of the rectangle. If there are multiple lines of text, DrawText uses the width of the rectangle pointed to by the lpRect parameter and extends the base of the rectangle to bound the last line of text. If there is only one line of text, DrawText modifies the right side of the rectangle so that it bounds the last character in the line. In either case, DrawText returns the height of the formatted text but does not draw the text. |
|
Ok und was soll ich Bitte nun noch machen?
|
|
Nersgatt
      
Beiträge: 1581
Erhaltene Danke: 279
Delphi 10 Seattle Prof.
|
Verfasst: Mi 10.12.08 09:10
Du musst DrawTextW 2x aufrufen. Das erste mal mit DT_CALRECT, um zu berechnen, wie groß das Rect für Deinen Text sein muss (das übergebene Rect wird entsprechend geändert). Danach nochmal aufrufen (mit DT_LEFT OR DT_WORDBREAK), um den Text zu zeichnen.
Gruß,
Jens
|
|
DiamondDog 
      
Beiträge: 460
|
Verfasst: Mi 10.12.08 13:58
Ich habs hinbekommen, hab was im übersehen:
Delphi-Quelltext 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19:
| ButtonAdd.Enabled := False;
PlugMsg1.Msg := PM_PLUGIN_SPEC_ADD_CNT;
PlugMsg1.WParam := 38; PlugMsg1.LParam := 0;
PlugMsg1.DllHandle := FDllHandle; FPluginSvc.OnPluginMessage(PlugMsg1);
if (PlugMsg1.Result <> 0) then UniqContactId := PlugMsg1.Result; |
|
|