VB4 Question: Having trouble changing .ScrollBars property 
Author Message
 VB4 Question: Having trouble changing .ScrollBars property

If that doesn't want to work, have to textboxes.  One with wordwrap
the other without.  When you toggle between them just hide/show the
appropriate boxes.  Of course you'll need to save the .SelStart,
SelChange and the .Text properties as you're switching between
textboxes.  It's a workaround; what can I say :->

George


Quote:
>I'm trying to write a simple text editor.  What I want to be able to do is to
>switch back and forth from wordwrap mode.  I have been trying to do this by:
>    text1.ScrollBars = 3 (or 2)

>Any suggestions?  Is there a better way to do this?

===============================================================================
 George R. Torralba              xxxxxxxxxxxx                  Batang Cebu!!!
 Seattle, Washington             206.241.2801              MIME mail accepted
===============================================================================


Mon, 22 Jun 1998 03:00:00 GMT  
 VB4 Question: Having trouble changing .ScrollBars property

Again, why not have two textboxes each with the appropriate scrollbar
properties.  You can then just switch between them when needed.  That
shouldn't be too hard to implement should it?

George


Quote:

>>> I'm trying to write a simple text editor.  What I want to be able to do is to
>>> switch back and forth from wordwrap mode.  I have been trying to do this by:
>>>         text1.ScrollBars = 3 (or 2)

>>You can't change the text box scrollbars property at runtime.  It's read-only.
>Do you have any other ideas on how to do this?

===============================================================================
 George R. Torralba              xxxxxxxxxxxx                  Batang Cebu!!!
 Seattle, Washington             206.241.2801              MIME mail accepted
===============================================================================


Tue, 23 Jun 1998 03:00:00 GMT  
 VB4 Question: Having trouble changing .ScrollBars property
I'm trying to write a simple text editor.  What I want to be able to do is to
switch back and forth from wordwrap mode.  I have been trying to do this by:

        text1.ScrollBars = 3 (or 2)


Any suggestions?  Is there a better way to do this?



Wed, 24 Jun 1998 03:00:00 GMT  
 VB4 Question: Having trouble changing .ScrollBars property

Quote:

> I'm trying to write a simple text editor.  What I want to be able to do is to
> switch back and forth from wordwrap mode.  I have been trying to do this by:

>         text1.ScrollBars = 3 (or 2)


> Any suggestions?  Is there a better way to do this?

You can't change the text box scrollbars property at runtime.  It's read-only.


Wed, 24 Jun 1998 03:00:00 GMT  
 VB4 Question: Having trouble changing .ScrollBars property

Quote:
>> I'm trying to write a simple text editor.  What I want to be able to do is to
>> switch back and forth from wordwrap mode.  I have been trying to do this by:
>>         text1.ScrollBars = 3 (or 2)

>You can't change the text box scrollbars property at runtime.  It's read-only.

Do you have any other ideas on how to do this?


Thu, 25 Jun 1998 03:00:00 GMT  
 VB4 Question: Having trouble changing .ScrollBars property

O'Hara) says:
Quote:



>> I'm trying to write a simple text editor.  What I want to be able to do
is to
>> switch back and forth from wordwrap mode.  I have been trying to do this
by:

>>         text1.ScrollBars = 3 (or 2)

>> The program halts and gives a message about function returns  

>> Any suggestions?  Is there a better way to do this?

>You can't change the text box scrollbars property at runtime.  It's

read-only.

Yeah, a dumb Windows design fault, actually. Not a VB limitation but
actually imposed by Windows. However, you can get around it, albeit somewhat
awkwardly, with two text boxes, one set with and one set without scrollbars,
and switch them around at runtime as necessary.



Fri, 26 Jun 1998 03:00:00 GMT  
 VB4 Question: Having trouble changing .ScrollBars property

Quote:

>If that doesn't want to work, have to textboxes.  One with wordwrap
>the other without.  When you toggle between them just hide/show the
>appropriate boxes.  Of course you'll need to save the .SelStart,
>SelChange and the .Text properties as you're switching between
>textboxes.  It's a workaround; what can I say :->

>George

Thanks!  Your solution worked like a charm!

Dan



Sat, 27 Jun 1998 03:00:00 GMT  
 VB4 Question: Having trouble changing .ScrollBars property

Quote:



> > I'm trying to write a simple text editor.  What I want to be able to do is to
> > switch back and forth from wordwrap mode.  I have been trying to do this by:

> >         text1.ScrollBars = 3 (or 2)


> > Any suggestions?  Is there a better way to do this?

> You can't change the text box scrollbars property at runtime.  It's read-only.

Here is a form that does what you want.  It actually has a text box
inside a panel and when the number of lines is less than the height
of the text box, the panel is shrunk to hide the vertical scroll bars
that are always there.  Equally, when there are more lines, the panel
is resized to show the scroll bars.  Create a project and cut and paste
this form and run it to see how it works.  There is an SDK call to
programatically scroll the text box and one to determine the number of
lines in it.
Hope this helps,

Steve

VERSION 2.00
Begin Form frmTest
   BackColor       =   &H00C0C0C0&
   Caption         =   "Form1"
   ClientHeight    =   2895
   ClientLeft      =   1425
   ClientTop       =   2595
   ClientWidth     =   4140
   Height          =   3255
   Left            =   1365
   LinkTopic       =   "Form1"
   ScaleHeight     =   2895
   ScaleWidth      =   4140
   Top             =   2295
   Width           =   4260
   Begin SSPanel pnlPanel
      BackColor       =   &H00C0C0C0&
      BevelInner      =   1  'Inset
      BevelOuter      =   0  'None
      BorderWidth     =   0
      Font3D          =   0  'None
      Height          =   2235
      Left            =   120
      TabIndex        =   0
      Top             =   420
      Width           =   3855
      Begin TextBox txtText
         BorderStyle     =   0  'None
         Height          =   1995
         Left            =   120
         MultiLine       =   -1  'True
         ScrollBars      =   2  'Vertical
         TabIndex        =   1
         Top             =   60
         Width           =   3555
      End
   End
   Begin Label lblLines
      Height          =   255
      Left            =   3000
      TabIndex        =   2
      Top             =   60
      Width           =   855
   End
End
Option Explicit

Declare Function SendDlgItemMessage Lib "User" (ByVal hdlg As Integer, ByVal
nIDDlgItem As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, lParam
As Any) As Long
Declare Function SendMessage Lib "User" (ByVal hWnd As Integer, ByVal wMsg As
Integer, ByVal wParam As Integer, lParam As Any) As Long

Const WM_USER = &H400
Const EM_GETLINECOUNT = WM_USER + 10
Const EM_LINESCROLL = WM_USER + 6

Sub Form_Load ()

    '
    ' Size the text box to fit the panel
    '
    txtText.Move 30, 30, pnlPanel.Width - 30, pnlPanel.Height - 30
    pnlPanel.Width = txtText.Width + txtText.Left - 200

End Sub

Sub txtText_Change ()

Dim lLines&

    '
    ' Get the number of lines in the text box
    '
    lLines = SendMessage(txtText.hWnd, EM_GETLINECOUNT, 0, 0)
    lblLines.Caption = Format(lLines)

    '
    ' Determine if the scrollbars should be shown
    '
    If lLines > 10 Then
        ' Yes
        pnlPanel.Width = txtText.Width + (txtText.Left * 2)
    Else
        ' No - hide the scrollbar and scroll box to top
        pnlPanel.Width = txtText.Width + txtText.Left - 200
        lLines = SendMessage(txtText.hWnd, EM_LINESCROLL, 0, -1)
    End If

End Sub



Sat, 27 Jun 1998 03:00:00 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. Having trouble changing the focus...

2. Questions I am Having Trouble With

3. Changing scrollbars property real-time

4. question about default property/having problems with For Each loop

5. Newbie having trouble with VBA Code in Access

6. Having Trouble populating an array from table values

7. getting reference path errors, having trouble fixing.

8. Having trouble programatically switching between fax and pdf report output

9. Having Trouble w/Data Validation Code (Acc97)

10. Having trouble with the TransferDatabase method

11. Still having trouble....

12. Having trouble sending multiple emails using outlook object

 

 
Powered by phpBB® Forum Software