Chat style RTB help...

11-28-2003, 07:33 PM
How would I go about making the text in an RichTextBox appear at the bottom instead of the top, like most chat programs?

11-28-2003, 07:40 PM
TextBoxName.SelStart = Len(TextBoxName.Text)
TextBoxName.SelText = "Text to add" & vbCrLf

11-28-2003, 07:49 PM
No, not like that... I mean for the text to appear at the bottom of the WINDOW. Like you know when you sign on to mirc and join a channel, the text starts at the bottom and goes up as more text is entered? That's what I'm trying to do.

11-28-2003, 07:56 PM
Well the textbox used in mIRC is a custom control which Khaled created by himself. Without
resorting to that, I think you'll just have to fill the textbox with a lot of blank lines.

11-28-2003, 07:58 PM
Yeah, I figured that, but isn't there a way to do it with the RTB's paragraph formatting or something? I mean, there are tons of chatting programs that do it that way, do you mean to tell me they ALL have custom controls?

11-28-2003, 08:06 PM
Well no, you're right. A quick flick through MSDN reveals the EM_SETPARAFORMAT message, which on a RichEdit 2.0 window, can also specify vertical spacing in the PARAFORMAT2 structure. This struct is not included within the API viewer which comes with VB, so you'll have to translate it from a C struct declaration.

typedef struct _paraformat {
UINT cbSize; Long
_WPAD _wPad1;
DWORD dwMask; Long
WORD wNumbering; Integer
WORD wReserved; Integer // redefined as wEffects in PARAFORMAT2
LONG dxStartIndent; Long
LONG dxRightIndent; Long
LONG dxOffset; Long
WORD wAlignment; Integer
SHORT cTabCount; Integer
LONG dySpaceBefore; Long // vertical spacing before para
LONG dySpaceAfter; Long // vertical spacing after para
LONG dyLineSpacing; Long // line spacing depending on Rule
SHORT sStyle; Integer // style handle
BYTE bLineSpacingRule; Byte // rule for line spacing (see tom.doc)
BYTE bCRC; Byte // reserved for CRC for rapid searching
WORD wShadingWeight; Integer // shading in hundredths of a per cent
WORD wShadingStyle; Integer // nibble 0: style, 1: cfpat, 2: cbpat
WORD wNumberingStart; Integer // starting value for numbering
WORD wNumberingStyle; Integer // alignment, roman/arabic, (), ), ., etc.
WORD wNumberingTab; Integer // space bet 1st indent and 1st-line text
WORD wBorderSpace; Integer // space between border and text (twips)
WORD wBorderWidth; Integer // border pen width (twips)
WORD wBorders; Integer // byte 0: bits specify which borders
// nibble 2: border style, 3: color index

Private Const EM_SETPARAFORMAT = (WM_USER + 71)
Private Const WM_USER = &H400

Private Const MAX_TAB_STOPS = 32

11-28-2003, 08:10 PM
Okay, um, seeing as I have absolutely zero C experience, would be so kind as to spell it out for this dimwit? ^^ Are you saying it's a SendMessage command?

11-28-2003, 08:14 PM
Yes, it would be something akin to:


Dim paraFormat As PARAFORMAT2

paraFormat.cbSize = Len(paraFormat)
paraFormat.dwMask = PFM_SPACEBEFORE
paraFormat.dySpaceBefore = 'Size, in twips, of space

SendMessage theBox.hWnd, EM_SETPARAFORMAT, 0, paraFormat


11-28-2003, 08:16 PM
Okay, so I need PARAFORMAT2 type, but I have no idea how to translate it from that bunch of C code you pasted @_@

EDIT: thank you so much for the help thus far ^^

11-28-2003, 08:18 PM
I annotated the VB equivalents in bold next to each member. Ignore the _WPAD member.

11-28-2003, 08:28 PM
Okay, so here's what I came out with:
Private Type PARAFORMAT2
cbSize As Long
dwMask As Long
wNumbering As Integer
wReserved As Integer
dxStartIndent As Long
dxRightIndent As Long
dxOffset As Long
wAlignment As Integer
cTabCount As Integer
rgxTabs As Long
dySpaceBefore As Long
dySpaceAfter As Long
dyLineSpacing As Long
sStyle As Integer
bLineSpacingRule As Byte
bCRC As Byte
wShadingWeight As Integer
wShadingStyle As Integer
wNumberingStart As Integer
wNumberingStyle As Integer
wNumberingTab As Integer
wBorderSpace As Integer
wBorderWidth As Integer
wBorders As Integer
End Type
Private Const WM_USER = &H400
Private Const EM_SETPARAFORMAT = (WM_USER + 71)
Private Const MAX_TAB_STOPS = 32
Private Const PFM_SPACEBEFORE = &H40

Public Sub InitRTB(RTB as RichTextBox)
Dim paraFormat As PARAFORMAT2

paraFormat.cbSize = Len(paraFormat)
paraFormat.dwMask = PFM_SPACEBEFORE
paraFormat.dySpaceBefore = 10
SendMessage RTB.hWnd, EM_SETPARAFORMAT, 0, paraFormat
End Sub

And.... it doesn't work ._.
What'd I do wrong?

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum