Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Text Align API... Help


I am printing text in Picturebox, Unfortunately VB doesn't include text alignment except for label or textbox. But there's API function that can get print text alignment in picture box. Check it out

http://builder.com.com/5100-6228-5421501.html

I added.. Declare Sub SetTextAlign Lib "gdi32" (ByValhDC As Long, ByValwFlags As Long) At very top (Where Option Explicit are) and I get complie error... So I am not sure how to implement it since I am not very familar with API calls, So help me.

Code written already on my form, where do I implement Text Align API function in my form?

Code:
Option Explicit

Private Sub Form_Load()
Picture1.FontBold = True
Picture1.FontSize = 12
Picture1.FontName = "Arial"
Picture1.ForeColor = VbWhite
Picture1.BackColor = vbBlacK

End Sub




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Vertical Align Text In Text Box / Label Control
I searched on "vertical align" in all forums and did not find this mentioned. (Not that it hasn't been, I just didn't get a hit.)

Anyway, is there a way to vertically align text within a VB 6.0 textbox or label control? (i.e., some programmatic equivalent to the Alignment property) It looks really goofy when the text is crammed against the top of the control ...

Getting some other toolset is not an option. (I am doing this at home for kicks and grins.)

Thanx,

P

Text Align When Outputting To Text File
I have three variables here: item number, description, and price. Each line can be a maximum of 50 characters. I need the first two variables left aligned and the last one right aligned on the same line when outputting to a text file, so it looks like:


Code:
01234567890123456789012345678901234567890123456789
itemno description, color price


I already wrote functions for right alignment but I cannot figure out how to have two different alignments when outputting to the text file on the same line. Anyone have any ideas? Thanks.

Word Text Boxes Align Text?
Is there a way of aligning text to bottom in a text box like you can in the cell of a table?

 

Align In Text Box
hi i have an external file named myfile.txt w/c was properly aligned in two columns now wen extracted try to display iton a textbox the texts were not aligned anymore, i used this code

module:

Public Function Combine(txt As TextBox, Sfile As String)
Dim stxt As String
X = FreeFile
Open App.Path & Sfile For Input As X
txt = StrConv(InputB(LOF(1), 1), vbUnicode)
Close #X
End Function

Align Text Vertically ?
In any label.caption or txt.text
There is option in Properties windows to align text Horizantly (left , Center,Right) But
But there is no Option seen to Align text Verticaly (Top,Mid,Botom).
If there is no available then how can I do this ?

Align Text In MsFlexGrid
Hi,

i have a problem with flesgrid here:

After loading the data into the flexgrid. i realised that some of the data in the cells are either aligned to the left or right.How can i standardise the alignment of the text in every cells?

Apart from the above, i would also like to know whether can i add rows (flexgrid) using codes rather than specifying in the property? I'll be better if a sample code can be provided.

Thanks a million,friends!

Regards!

Align Text To TextBox
I have a form that has one line of text and a textbox. I would like to align the text to the left of the textbox, and centered vertically to the textbox. Is there a way to do this without typing in coordinates or turning off the snap-to-grid and moving it manually? Or, am I just missing the fact that you can do labels for the textbox itself...and all this is taken care of automatically? Thanks in advance!

Toolbar Text Align Help
hi,

Can someone help me or give some info on how to set the Text alignment on the button to the left in a Toolbar, all I can see is tbrTextAlignBottom and tbrTextAlignRight

using the tbrTextAlignBottom is just totaly usless cos there is like a large gap, and if I use the tbrTextAlignRight it just looks even wose and just makes the buttons looks unnatural as the text is closer to the next button.

is there any API call I can use. or anything else.

How To Align Text In A List Box
hello everyone, below is a screen shot of my program.



The text in the list box is read from a text file when the refresh button is clicked.

What i wish to do is align the text so that it comes under the headings like this: (i edited it in paint to give you gys a visual representation :P)



i have attached the whole vb program so you gys can have a look.

Thank you

Using Space() To Align Text
Is it possible to use Space() to get text to left align with headings? Here is what I'm doing now and the result is shown in the attached file.

VB Code:
strMsg = strMsg & "TAG" & Space(11) & "VARIABLE" & Space(11) & "STATUS" & Space(11) _    & "VALUE" & Space(11) & "UNITS" & Space(11) & "TIME" & vbCrLfstrMsg = strMsg & "27-QAO49D" & Space(11) & "PD Pull Roll" & Space(11) & " " & _    Space(11) & "BREAK SHEET" & Space(11) & " " & Space(11) & "15-Sep-05 12:00:00"

Align Text Verticaly ?
In any label.caption or txt.text
There is option in Properties windows to align text Horizantly(left , Center,Right) But
But there is no Option seen to Align text Verticaly(Top,Mid,Botom).
If there is no available then how can I do this ?

Align Text In A ListBox
Is there an easy way right align text in a listbox? I'm currently using tabs to set the colums, but the columns are left aligned and i need my last colum (Numbers) to line up by decimal. is this possibal?

Thanks,

nathan

To Align The Text Box With The Form.......
Hi everybody,

I have created a notepad application. My problem is whenever i maximize the form the text box on the form does not maximize properly or does not fit to the size of the form. I used the resize event of the form. I assigned the height and the width of the form to the height and width of the textbox. But the scrollbars are not adjusted properly. I want that it should maximize properly or fit to the size of the form and also the scrollbars of the textbox should be visible clearly.

Regards

Samir

Align Text In A Label
Is it possible to set text in a multiline label to justify? I don't want left, right or center alignment.

Thanks

Align Rich Text
Is it possible to align the text in a richtext box center?

Textbox.text Can't Right Align...anyone Know If
this a know bug in visual basic?

is there a work-around?

Align Text In A Message Box
Hey guys. has anybody else tried this? it doesn't work.
strMessage = ""
for x = 1 to 5
strMessage = strMessage & vbCrLf & strArray(x)
For y = 1 to (70 - Len(strArray(x)))
strmessage = strMessage & " "
Next y
strMessage = strMessage & strArray2(x)
Next x
MsgBox(strMessage)

What is this for? It should take these 2 arrays and make even columns out of them. But it doesn't. The number of characters in the first array aren't always the same width and so the second column is not aligned.

Since I won't know what is going to print in this array, I can't "make" it line up.

Any thoughts?


Thanks
wengang

Align Columns In Text Box
I have a text box in which multiple columns of figures are displayed as they are computed within my application. Each column may have a varying number of digits or letters.

I want each column to begin at the same relative position in the text box so visually I don't end up with uneven columns. The right side of each column doesn't matter. I realize the font may contribute to unevenness depending upon the character so which font would give me the best results? I don't have a problem with the hard copy output since I convert the contents of the text box to a file and use tabs in the printed results.

Is there a simple way to do this? If I could use tabs in the text box, it would solve the problem. I suppose a series of text boxes (1 for each column) would also work but that would really be a pain. Since the data may go for many lines, I need to have scroll bars or maybe a picture box would do, using currentx,y. I appreciate any advice or solution.

 

To Align The Text In Richtextbox
hai guys,

I am using the form named as billing repot. In this form,we have print button to pritn the content of the bill details in the richtext box. my code is working fine,but all the details of the bill is to be printed in overwrited format.My ques tion is how to align the space for print the bill details in the rich textbox.



Code:
Public Sub PrintView(title As String, query As String, n As Integer, column As Variant)
Dim rs1 As New ADODB.Recordset
Dim colwidth(7) As Integer
rs1.Open "select b.billno,b.bdate,c.caddr,b.quantity,b.rate,b.discount,b.netamt from billing b,CREGISTER c where b.clientname=c.clientname", con, adOpenDynamic, adLockReadOnly
Dim col, ss, sp, Line As String
Line = String$(99, "_") + vbCrLf + vbCrLf
colwidth(0) = 15
colwidth(1) = 10
colwidth(2) = 35
colwidth(3) = 20
colwidth(4) = 25
colwidth(5) = 30
colwidth(6) = 40
colwidth(7) = 45
col = Space(36)
sp = Space(15)
ss = Space(37)
Dim rs As New ADODB.Recordset
rs.Open query, con, adOpenDynamic, adLockReadOnly
View = ""
View = View + vbCrLf + vbCrLf + vbCrLf
View = View + Space(5)

frmprintbill.RichTextBox1.Text = rs1("billno")
View = View + vbCrLf + vbCrLf + vbCrLf
View = View + Space(10)
frmprintbill.RichTextBox1.Text = rs1("bdate")
View = View + vbCrLf + vbCrLf + vbCrLf
View = View + Space(15)
frmprintbill.RichTextBox1.Text = rs1("caddr")
View = View + vbCrLf + vbCrLf + vbCrLf
View = View + Space(20)
frmprintbill.RichTextBox1.Text = rs1("quantity")
View = View + vbCrLf + vbCrLf + vbCrLf
View = View + Space(25)
View = View + vbCrLf + vbCrLf + vbCrLf
frmprintbill.RichTextBox1.Text = rs1("rate")
View = View + Space(30)
frmprintbill.RichTextBox1.Text = rs1("discount")
View = View + vbCrLf + vbCrLf + vbCrLf
View = View + Space(35)
frmprintbill.RichTextBox1.Text = rs1("netamt")
View = View + vbCrLf + vbCrLf + vbCrLf
View = View + Space(40)
View = View + Space$(5) + title + vbCrLf + vbCrLf
View = View + vbCrLf + vbCrLf + vbCrLf
View = View + Line
Dim j
For j = 0 To n - 1
    If j = 0 Or j = 1 Then
        LSet col = rs(j)
        View = View + sp + col
    Else
        LSet ss = rs(j)
        View = View + sp + ss
    End If
Next j
View = View + vbCrLf
View = View + Line
While Not rs.EOF
'Dim i
    For i = 0 To n - 1
        If i = 0 Or i = 1 Then
            LSet col = rs(i)
            View = View + sp + col
        Else
            ss = Space(colwidth(i))
            LSet ss = rs(i)
            'View = View + sp + ss
            View = View + ss
        End If
    Next i
    View = View + vbCrLf
    rs.MoveNext
Wend
frmprintbill.Show
End Sub
[code]

Plzzzz trace the code and swend the solution for me.


bye
ram

How To Align Text In RichTextBox
Can anybody help me?

I want to print the text from the richtextbox in the format aligned by the user. How shall i go for it?

Thanks

Vertically Align Label Text
This is probably a really silly question, but is it possible to vertically centre text displayed in a label?
Any help greatly appreciated

How To Align Text In A Flexgrid Cell??
Could anyone plz tell me how to center your text within a cell
in a flexgrid??
I have to do this for a project for school and I can't find it
Please help me out

Align Text To Right Side In Textbox?
hi

I have a textbox (Text1) and have a large amount of text which fills the textbox and beyond.

How do I align this text such that the last character is always aligned to the right of the text box (and is visible)?

cheers

Text Align Property When Unavailable
How can I left-align the caption of a command button? Is there any trick using the API functions?

Align Text Box Array With List Box
I have a list box and wish to be able to enter data to the side of the list box , for each item in the list box
eg
List box                         Text Box
aaaaaaaaaa                       mmmmm
bbbbbbbbbb                       pppppp

I have set the text box up as text1(0)  etc so that i can
create an array beside the list box

Is there any way of getting the depth of the text box = depth of the list box or visa versa.

Or is there any other trick of being able to enter data beside a list box , line by line.

I suppose at a last resort i could put the data to a table and use a data entry box.


Appreciate any help or ideas.


Align Text With Column Headings
Good day

I would like to have code to align the text within the headings. I have the following headings :
Name: Surname: Comments:
The code is printing but the text is not aligned especially the comments column where the text sometimes overlaps to the next line.

Thx in advance



bednarjm - move to vb6 forum




Edited by - bednarjm on 7/16/2008 10:49:43 AM

How Do You Align Header Text In A Datagrid?
Is it possible to align text in the headers of a datagrid?

TIA
Deke

Align Text Within Label Or Text Box
Can someone tell me how to vertically align text within a txt box or a label in visual basic 6.

Left Align Text In Command Button?
Can anyone tell me how to left align a command button caption, I thought it would be an easy thing to do, but I can't figure it out.
I know this seems like a stupid question!

Align Text/formating In Excel Sheet Using VB 6
Hi,

I am having a problem with aligning text while creating an Excel sheet from VB 6, I implemented the late binding concept and hence I cannot use any property/method specific to one lib. I started off by referencing Excel 10.0 object lib in my VB project and used some properties and methods to align text and draw borders. But since I used late binding, I am not able to use the same properties. For example,

objExcelApp.Cells(2, 4).HorizontalAlignment = xlVAlignCenter
objExcelSheet.Range("A111").Borders(xlEdgeRight).Color = vbRed

I am getting an error when I run the project which reads "variable not declared/defined" and is pointing to xlVAlignCenter

Are there any other properties/methods I can use to achieve the same without referencing any object libraries in my project. Any help is appreciated.

Thanks in advance
Praveen

Left Align Text In A Command Button?
Can anyone tell me how to left align a command button caption, I thought it would be an easy thing to do, but I can't figure it out.
I know this seems like a stupid question!

API Question: Picture Box Print Text Align
I am printing text in Picturebox, Unfortunately VB doesn't include text alignment except for label or textbox. But there's API function that can get print text alignment in picture box. Check it out

http://builder.com.com/5100-6228-5421501.html

I added.. Declare Sub SetTextAlign Lib "gdi32" (ByValhDC As Long, ByValwFlags As Long) At very top (Where Option Explicit are) and I get complie error... So I am not sure how to implement it since I am not very familar with API calls, So help me.

Code written already on my form, where do I implement Text Align API function in my form?

VB Code:
Option Explicit Private Sub  Form_Load()Picture1.FontBold = TruePicture1.FontSize = 12Picture1.FontName =  "Arial"Picture1.ForeColor = VbWhitePicture1.BackColor  = vbBlacK End Sub

Align Text On Standard Command Button
I had found this code awhile ago, I think from this site, and I
never used it until now. I am trying to left or right align some text
on a standard command button. I havve searched the forums
extensively and couldn't find a solution on this. Does anyone
have an idea how to do this?

Thanks.


VB Code:
Option Explicit Public Const GWL_STYLE As Long = (-16) 'these are not true Windows button stylesPublic Const BS_ALIGN_CENTRELEFT As Long = &H100Public Const BS_ALIGN_CENTRERIGHT As Long = &H200Public Const BS_ALIGN_CENTRE As Long = &H300Public Const BS_ALIGN_TOPMIDDLE As Long = &H400Public Const BS_ALIGN_TOPLEFT As Long = &H500Public Const BS_ALIGN_TOPRIGHT As Long = &H600Public Const BS_ALIGN_BOTTOMMIDDLE As Long = &H800Public Const BS_ALIGN_BOTTOMLEFT As Long = &H900Public Const BS_ALIGN_BOTTOMRIGHT As Long = &HA00 Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long   Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, _ByVal dwNewLong As Long) As Long Public Type ControlLayoutData   totalRows As Long   totalColumns As Long   rowPadding As Long   colPadding As Long   ctlHeight  As Long   ctlWidth As Long   pgridTop As Long   pgridLeft As LongEnd Type Public style As Long

MSFlexgrid Text Align In Fixed Row - > Can It Be Changed?
can i chnge the text align of the MsFlexGrid Fixed row using API?

Thanks in advanced!

Command Button With Icon And Text??? Align???
I have a command button on a form that should have both a icon and a text. The problem I have is that the icon and the text aligns on the center of the button. I want the icon to the left of text. Can this be done without having to make an image with both the icon and the text???


/Smirre

Center Align Text On VB Print Output
How does one center align text on a print output from VB rather than using X Y coordinates?  This is what I have so far, but I would like the two lines of text to always center no matter what part number prints... tia.  Maureen

iNumCopies = 1
LoadLbl = MsgBox("Large " & Lblinternaldel & " label required for " & Lblrscitemno & ".  Load label stock in Printer.", 1, "AUME Special Label")
        If LoadLbl = 2 Then GoTo errHandler
        CommonDialog1.CancelError = True
        On Error GoTo errHandler
        CommonDialog1.ShowPrinter
        CommonDialog1.FromPage = 1
        CommonDialog1.ToPage = 1
        NumCopies = CommonDialog1.Copies
        For iNumCopies = 1 To NumCopies
            On Error GoTo 0
            Printer.Orientation = 2    '2 = Landscape
            Printer.FontName = "Arial"
????        Printer.CurrentX = 800
????        Printer.CurrentY = 2000
            Printer.FontSize = 150
            Printer.FontBold = True
            Printer.Print Lblcustitemno
????        Printer.CurrentX = 4600
????        Printer.CurrentY = 6000
            Printer.FontSize = 160
            Printer.FontBold = True
            Printer.Print Format(Lblqty, "#####0")
            Printer.EndDoc
        Next iNumCopies

You Can Align Text In A Text Box But Not Rich Text Box????
I dont see a way to centre or align text to the rigth in a rich text box, which such features are there in a normal basic text box.

thats very odd..... Rich text box is ment to be advance with stuff like that no???

or am i missing something here?

can it be done programmicaly maybe?

Abe

Flexgrid Column Width And Text Align Problem
Hi,

i have the flexgrid which is not connected to database.I have set the first row with the captions and second onwards rows contain data according to the caption.I want to set the column width that should fit the content of the row and align the text left justified.

i tried :

flexgrid.CellAlignment = vbAlignLeft
flexgrid1.colwidth(0) = len(data)


if any of the experts know ,please help.

Thanks.

---Solved ---How To Set Text In MS FlexGrid Align To Left Or Right In Column ?
How to set data in MS FlexGrid align to left or right in each column ? Thanks

MDI Align
I need to make a mdi child centered in the MDI form on startup but when I try to do this in the windows property i get a message stating invalid property value. Any ideas how to do this?

GDI+ Rright-align
I am new to GDI+. I need to create a document template. How do I left-align text?

I have this:

Code:
Dim header As String = "CAPITAL RECOVERY, INC" & vbTab & vbTab & vbTab & _
"Recovery Specialists of Valuable Property" & vbCrLf & _
"P.O. BOX 408" & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & "Se Habla Espanol" & vbCrLf & _
"LOGAN, UT 84323" & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & "Phone 1-800-837-3759" & vbCrLf
Dim messageFont As New Font("Times New Roman", 12, System.Drawing.GraphicsUnit.Point)
g.DrawString(header, messageFont, Brushes.Black, 75, 50)

I need stuff aligned instead of using tabs. Please help! Thanks!

MSFlexGrid Not Align?
I have the printing function of the MSFlexGrid where it is set to print the MSFlexGrid however when it prints... the first row is align to the left while from the second row it goes to the right? Whats the problem to it?

I have been to forum thread about the MSFlexGrid.. does the only solution for me is to use the autoresizing? No other solutions?

How To Right-align The Table
I created a table but I can't right-align it.
The code is below..
How will I be able to do this?


Code:
objDoc.ActiveWindow.Selection.Tables.Add objWord.Selection.Range, 1, 1, wdWord9TableBehavior
objDoc.ActiveWindow.Selection.Tables(1).ApplyStyleHeadingRows = True
objDoc.ActiveWindow.Selection.Tables(1).ApplyStyleLastRow = True
objDoc.ActiveWindow.Selection.Tables(1).ApplyStyleFirstColumn = True
objDoc.ActiveWindow.Selection.Tables(1).ApplyStyleLastColumn = True

objDoc.ActiveWindow.Selection.Tables(1).Borders(wdBorderLeft).LineStyle = wdLineStyleNone
objDoc.ActiveWindow.Selection.Tables(1).Borders(wdBorderRight).LineStyle = wdLineStyleNone
objDoc.ActiveWindow.Selection.Tables(1).Borders(wdBorderTop).LineStyle = wdLineStyleNone
objDoc.ActiveWindow.Selection.Tables(1).Borders(wdBorderBottom).LineStyle = wdLineStyleNone
objDoc.ActiveWindow.Selection.Tables(1).Borders(wdBorderHorizontal).LineStyle = wdLineStyleNone
objDoc.ActiveWindow.Selection.Tables(1).Borders(wdBorderVertical).LineStyle = wdLineStyleNone

objDoc.ActiveWindow.Selection.Tables(1).Cell(1, 1).Width = 250


objDoc.ActiveWindow.Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
objDoc.ActiveWindow.Selection.TypeText "GDA" & vbCrLf & "TANBUL Z DASAN" & vbCrLf & "GM"

objDoc.ActiveWindow.Selection.MoveRight Unit:=wdCell

objDoc.ActiveWindow.Selection.MoveDown Unit:=wdLine, Count:=1

objDoc.ActiveWindow.Selection.TypeParagraph
PS: The table is 1*1 and the text inside the table is aligned center.

Caption Align
On a form in Access 2000, is there a way to center or right align the caption:

Me.caption = "Title of the Application " & Me.OpenArgs

???

Thanks

Align Property ???
On my MDI application I use the align property with multiple pictureboxes. For some reason, when you lay down multiple objects with the align property, they assume position, and you can't alter it during design time or run time. For instance, if you lay down a control with align top, another with align bottom, one with align left, and another with align right, the top and the bottom always assume the ability to stretch all the way across, making the left and right picturebox smaller. I can't figure out anyway to fix this. Can someone help me?

Print Align
hi, how can i set the alignment of text that i print to the form? im using the .print command and it seems that i can only have left aligned text. is there any way to make right aligned text?

also is there a way to make it print text on a new line if it goes over the edge of a form or picture box?

Align Print ?
Hi all, i am making a times table up to multiplies of 12, how do i align them side by side in rows of 12 and columns of 12 using the print header?
For example,

1x1=1 2x1=2 3x1=3
1x2=2 2x2=4 3x2=6
... ... ...

My code is as follow, but i cant seems to get the desired result, i need help.
thx

==================================================
Private Sub Form_Load()
For ctr = 1 To 12
For ctr2 = 1 To 12
ans = ctr * ctr2
Select Case ctr
Case 1
Show
Print ctr & "x" & ctr2 & "=" & ans
Case 2

Print ctr & "x" & ctr2 & "=" & ans
Case 3

Print ctr & "x" & ctr2 & "=" & ans
End Select


Next
Next
End Sub

Align Strings
Hi All,

I would like to align text file contains.By using :

Print#2, line1,line2,line3 command, it's giving me a output file which is look like this:

Mame1 ddd/mmm/yyy output1
MameName2 ddd/mmm/yyy output1

can anyone help me to align that file and sort it :

Mame1------- ddd/mmm/yyy---output1
MameName2 --ddd/mmm/yyy---output1

Thank u for your help

Align Caption API
'Alignment constants
Public Const A_CENTER = &H300&
Public Const A_TOP = &H400&
Public Const A_TOPLEFT = &H500&
Public Const A_TOPRIGHT = &H600&
Public Const A_BOTTOM = &H800&
Public Const A_BOTTOMLEFT = &H900&
Public Const A_BOTTOMRIGHT = &HA00&
Public Const A_LEFT = &H100&
Public Const A_RIGHT = &H200&
Public Const GWL_STYLE& = (-16)
Declare Function GetWindowLong& Lib "user32" Alias "GetWindowLongA" _
(ByVal hwnd As Long, ByVal nIndex As Long)
Declare Function SetWindowLong& Lib "user32" Alias "SetWindowLongA" _
(ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long)

'Insert this code to your form:

Private Sub Command1_Click()
Dim tmpValue&
Dim Align&
Dim ret&
'This will align the caption to top. To align to different direction, change the 'A_TOP'
'below with different alignment constant. You can see all alignment constants above,
'in the module code.
fAlignment& = A_TOP
tmpValue& = GetWindowLong&(Command1.hwnd, GWL_STYLE) And Not BS_RIGHT
ret& = SetWindowLong&(Command1.hwnd, GWL_STYLE, tmpValue& Or fAlignment&)
Command1.Refresh
End Sub

i have an error at BS_RIGHT i make that A_RIGHT but is not working...any help? what i have to change to make it work?

Copyright © 2005-08 www.BigResource.com, All rights reserved