Author | Message | Time |
---|---|---|
LordNevar | I am currently working on drawing ladder rankings to the icon, and this is what I have so far. [code]If scrank = 1 Then code = frmMain.LadderRating.Picture Dim sPrintText As String Dim MyRect As RECT Dim lSuccess As Long frmMain.LadderRating.Font.Size = 8 Scalmode = vbPixels MyRect.Left = 0 MyRect.Right = frmMain.LadderRating.ScaleWidth MyRect.Top = 80 MyRect.Bottom = 80 sPrintText = scrank lSuccess = DrawText(frmMain.LadderRating.hdc, sPrintText, Len(sPrintText), _ MyRect, DT_CENTER Or DT_WORDBREAK) End If[/code] It shows the icon just fine, but it's not printing anything to the icon like it should be, and can't seem to figure it out. I am new with this so any input would be greatly appreciated on this one. Yes I searched the forums on this already, which is how I cam up with using DrawText API. | October 16, 2005, 7:38 PM |
UserLoser. | is your listview owner drawn? if not, then probably whenever it repaints the window it's just ignoring that text you drew out so it disappears. | October 17, 2005, 3:17 AM |
LordNevar | Yes it is. | October 17, 2005, 3:59 AM |
Elneroth | Tell me if I'm wrong, but you're modifying the background picture of your listview then (as I can't see in the coding), you're using the background picture as an icon to add an item to the listview? OR. is "LadderRank" a picturebox and your modifying that then using it as an icon to add an item to the listview? First off, [code]If scrank = 1 Then code = frmMain.LadderRating.Picture[/code] If that's the same If.. Then statement as the bottom where it says "End If", you should have it after the If line. Also, you have a lot of useless declarations. [code]If scrank = 1 Then code = frmMain.LadderRating.Picture Dim MyRect As RECT frmMain.LadderRating.Font.Size = 8 Scalmode = vbPixels MyRect.Left = 0 MyRect.Right = frmMain.LadderRating.ScaleWidth MyRect.Top = 80 MyRect.Bottom = 80 DrawText frmMain.LadderRating.hdc, scrank, Len(scrank), MyRect, DT_CENTER Or DT_WORDBREAK) End If[/code] Also, May I see this "DrawText" function you have there? [code]DrawText frmMain.LadderRating.hdc, scrank, Len(scrank), MyRect, DT_CENTER Or DT_WORDBREAK)[/code] Correct me if I'm way off on how you're doing this ;) | October 17, 2005, 1:12 PM |
rabbit | [tt]Declare Function DrawText Lib "user32" Alias "DrawTextA" (ByVal hdc As Long, ByVal lpStr As String, ByVal nCount As Long, lpRect As RECT, ByVal wFormat As Long) As Long · hDC Identifies the device context. · lpString Points to the string to be drawn. If the nCount parameter is -1, the string must be null-terminated. · nCount Specifies the number of characters in the string. If nCount is -1, then the lpString parameter is assumed to be a pointer to a null-terminated string and DrawText computes the character count automatically. · lpRect Points to a RECT structure that contains the rectangle (in logical coordinates) in which the text is to be formatted. · uFormat Specifies the method of formatting the text. It can be any combination of the following DT_BOTTOM Justifies the text to the bottom of the rectangle. This value must be combined with DT_SINGLELINE. 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. DT_CENTER Centers text horizontally in the rectangle. DT_EDITCONTROL Duplicates the text-displaying characteristics of a multiline edit control. Specifically, the average character width is calculated in the same manner as for an edit control, and the function does not display a partially visible last line. DT_END_ELLIPSIS or DT_PATH_ELLIPSIS Replaces part of the given string with ellipses, if necessary, so that the result fits in the specified rectangle. The given string is not modified unless the DT_MODIFYSTRING flag is specified. You can specify DT_END_ELLIPSIS to replace characters at the end of the string, or DT_PATH_ELLIPSIS to replace characters in the middle of the string. If the string contains backslash (\) characters, DT_PATH_ELLIPSIS preserves as much as possible of the text after the last backslash. DT_EXPANDTABS Expands tab characters. The default number of characters per tab is eight. DT_EXTERNALLEADING Includes the font external leading in line height. Normally, external leading is not included in the height of a line of text. DT_LEFT Aligns text to the left. DT_MODIFYSTRING Modifies the given string to match the displayed text. This flag has no effect unless the DT_END_ELLIPSIS or DT_PATH_ELLIPSIS flag is specified. DT_NOCLIP Draws without clipping. DrawText is somewhat faster when DT_NOCLIP is used. DT_NOPREFIX Turns off processing of prefix characters. Normally, DrawText interprets the mnemonic-prefix character & as a directive to underscore the character that follows, and the mnemonic-prefix characters && as a directive to print a single &. By specifying DT_NOPREFIX, this processing is turned off. DT_RIGHT Aligns text to the right. DT_RTLREADING Layout in right to left reading order for bi-directional text when the font selected into the hdc is a Hebrew or Arabic font. The default reading order for all text is left to right. DT_SINGLELINE Displays text on a single line only. Carriage returns and linefeeds do not break the line. DT_TABSTOP Sets tab stops. Bits 15-8 (high-order byte of the low-order word) of the uFormat parameter specify the number of characters for each tab. The default number of characters per tab is eight. DT_TOP Top-justifies text (single line only). DT_VCENTER Centers text vertically (single line only). DT_WORDBREAK Breaks words. Lines are automatically broken between words if a word would extend past the edge of the rectangle specified by the lpRect parameter. A carriage return-linefeed sequence also breaks the line. Note that the DT_CALCRECT, DT_EXTERNALLEADING, DT_INTERNAL, DT_NOCLIP, and DT_NOPREFIX values cannot be used with the DT_TABSTOP value.[/tt] | October 17, 2005, 11:29 PM |
Elneroth | Ahh, didn't realize it was an API Call, thought he made his own. | October 17, 2005, 11:32 PM |