Solved

How to scroll data in an OLE container

Posted on 1998-08-05
13
636 Views
Last Modified: 2013-11-25
hi,
 How to scroll data in an OLE  container. I have word document in an OLE and I want to
scroll it either vertical or horizontal.
 Your help will be a big contributions.
 Thank you.

Eldie
0
Comment
Question by:wave180
  • 7
  • 6
13 Comments
 

Author Comment

by:wave180
Comment Utility
Adjusted points to 45
0
 
LVL 1

Accepted Solution

by:
BlackAndWhite earned 40 total points
Comment Utility
Put the OLE Container inside a 'Picture Box' and set the SizeMode Property of the OLEContainer to 2-AutoSize. Then, add a scroll bar to the right of the picture box (outside it) and scroll the ole container control which is inside the picture box which gives the effect of scrolling.  If the bottom of the OLE Container inside the picture box reaches the bottom of the picture box, stop scrolling. Similarly for the top.

Let me know if you have a problem with this.
0
 

Author Comment

by:wave180
Comment Utility
You have any code that will do scroll the Document inside OLE container using
VScroll bar or HScroll bar.

thanks
0
 
LVL 1

Expert Comment

by:BlackAndWhite
Comment Utility
Not Right now... I remember some Microsoft knowledge base article doing it on a picture control.  It should not take long to code...however if I can find the code or put something together myself I will let you know.
0
 

Author Comment

by:wave180
Comment Utility
BlackAndWhite,
  Thank you very much, and I'll be looking forward to have that code if it's ok,
as soon as possible.
 Thanks again.

Eldie
0
 
LVL 1

Expert Comment

by:BlackAndWhite
Comment Utility
I found the knowledge base article... You are lucky..

Microsoft Knowledge Base
How to Create Scrollable Viewports in Visual Basic
Last reviewed: December 8, 1995
Article ID: Q140878  
The information in this article applies to:
- Professional and Enterprise Editions of Microsoft Visual Basic,

  16-bit only, for Windows, version 4.0


SUMMARY
You can create scrollable viewports in Visual Basic by using standard Basic calls. The viewports can include bitmaps, graphics, or other controls.



MORE INFORMATION
This information is included with the Help file provided with Microsoft Professional Toolkit for Visual Basic version 1.0, Microsoft Visual Basic version 2.0, Microsoft Visual Basic version 3.0, and Microsoft Visual Basic version 4.0.

To create a scrollable picture with clipping, you must have two picture controls. The first picture control is called the stationary parent picture control. Within the parent picture control, you need to create a movable child picture control.

It is the child picture control that will be moved within the parent picture control. Moving the child picture within the parent picture control creates the clipping effect. During run time when you move the child picture, it will be clipped by the boundaries of the parent picture.

To create these two picture controls, do the following:


Choose the picture box control from the Toolbox window in Visual Basic.

Draw a picture on the form. This is the parent picture.

Again choose the picture box control from the Toolbox window.

Draw the second picture on top of and within the boundaries of the first picture control. This is the child picture.

Optional: If you want the viewport to resize when the user changes the form size, then add the following code to the form's resize event:

Private Sub Form_Resize ()
   ' When the form size is changed, the Picture1 dimensions are changed
   ' to match.
   Picture1.Height = form1.Height
   Picture1.Width = form1.Width
   ' Re-Initializes picture postitions & scroll bars.
   Picture1.Move 0, 0, Scalewidth - Vscroll1.Width, scaleheight -
Hscroll1.Height
   Picture2.Move 0, 0
   Hscroll1.Top = Picture1.Height
   Hscroll1.Left = 0
   Hscroll1.Width = Picture1.Width
   Vscroll1.Top = 0
   Vscroll1.Left = Picture1.Width
   Vscroll1.Height = Picture1.Height
   Hscroll1.Max = Picture2.Width - Picture1.Width
   Vscroll1.Max = Picture2.Height - Picture1.Height
   ' Checks to see if scroll bars  are needed
   VScroll1.Visible = (Picture1.Height < Picture2.Height)
   HScroll1.Visible = (Picture1.Width < Picture2.Width)
End Sub

The sample application below shows how to create a scrollable bitmap within a viewport. Perform the sequence above to create a parent/child picture control. Add a horizontal scroll bar and a vertical scroll bar to the form.
Make sure that the path to your bitmap is correct. Several of the properties are set during run time, which could have been set during design time as well.

Moving the thumb of the two scroll bars will move the child picture within the parent picture. The handle (upper-left corner of the picture) to the child picture will be located either at (0,0) of the parent picture or to the left and/or right of the parent picture. Because the clipping region is that of the parent picture, the child picture will appear to move across the parent picture viewport.

Add the following code to the appropriate event procedures:


Private Sub Form_Load ()
   Const PIXEL = 3
   Add the following constant only in Visual Basic 1.0:
   '  Const TRUE = -1
   Const NONE = 0

   ' Set design properties, included here for simplicity.
   Form1.ScaleMode = PIXEL
   Picture1.ScaleMode = PIXEL

   ' AutoSize is set to TRUE so that the boundaries of
   ' Picture2 are expanded to the size of the actual bitmap.
   Picture2.AutoSize = TRUE

   ' Get rid of annoying borders.
   Picture1.BorderStyle = NONE
   Picture2.BorderStyle = NONE

   ' Load the picture that you want to display.
   Picture2.Picture = LoadPicture("c:\win\party.bmp")

   ' Initialize location of both pictures.
   Picture1.Move 0, 0, ScaleWidth - VScroll1.Width,_
   ScaleHeight - HScroll1.Height
   Picture2.Move 0, 0

   ' Position the horizontal scroll bar.
   HScroll1.Top = Picture1.Height
   HScroll1.Left = 0
   HScroll1.Width = Picture1.Width

   ' Position the vertical scroll bar.
   VScroll1.Top = 0
   VScroll1.Left = Picture1.Width
   VScroll1.Height = Picture1.Height

   ' Set the Max value for the scroll bars.
   HScroll1.Max = Picture2.Width - Picture1.Width
   VScroll1.Max = Picture2.Height - Picture1.Height

   ' Determine if child picture will fill up screen.
   ' If so, then there is no need to use scroll bars.

   VScroll1.Visible = (Picture1.Height < Picture2.Height)
   HScroll1.Visible = (Picture1.Width < Picture2.Width)
End Sub

Private Sub HScroll1_Change ()
  ' Picture2.Left is set to the negative of the value because
  ' as you scroll the scroll bar to the right, the display
  ' should move to the Left, showing more of the right
  ' of the display, and vice-versa when scrolling to the
  ' left.

   Picture2.Left = -HScroll1.Value

End Sub

Private Sub VScroll1_Change ()
  ' Picture2.Top is set to the negative of the value because
  ' as you scroll the scroll bar down, the display
  ' should move up, showing more of the bottom
  ' of the display, and vice-versa when scrolling up.

  Picture2.Top = -VScroll1.Value

End Sub
 



0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 1

Expert Comment

by:BlackAndWhite
Comment Utility
Better still ...How about this...

Hope this really helps!.....


Microsoft Knowledge Base
How to Scroll an Embedded Word 6 Document in VB OLE
Last reviewed: May 17, 1996
Article ID: Q147804  
The information in this article applies to:
Standard, Professional, and Enterprise Editions of the Microsoft Visual Basic Programming System, version 4.0, for Windows
Microsoft Word for Windows, version 6.0


SUMMARY
Word for Windows version 6.0 does not supply scroll bars that allow an activated document embedded in the Visual Basic OLE container control to be scrolled through. This article describes how to provide buttons that allow the user to scroll through an embedded Word for Windows version 6.0 document that has been activated for visual editing.

To scroll through the window, you must call a Word Basic method such as VLine. However, if you call the method from within a scroll-bar event, the code does not work. The problem is that when the scroll bar receives the focus, the Word document object in the OLE control is deactivated. If you try to activate the Word Document object in the scroll-bar event, the insertion point moves to the beginning of the document, causing you to lose the current position in the document. This problem happens with any control that can receive the focus.



MORE INFORMATION
To work around the problem, use a control that cannot receive the focus (for example, the image-control or the spin button). You can use the image control to simulate a button. When you click it, the focus remains on the OLE container control, and therefore the Word document object stays activated. This allows you to call a Word Basic method such as VLine to allow you to scroll through the window in the click event of the image control.



Example

Start Visual Basic; Form1 is created by default.

Add an OLE container control to Form1 (Ole1 is the default name for the control).

The insert object dialog box should appear after you draw the OLE container control on the form. Choose Create from the File option, and choose an existing Word .DOC file that is more than a page in length. The "Link" and "Display As Icon" check boxes should not be selected. Choose the OK button when you are done; the document should now be embedded in the OLE container control.

Add a spin button to Form1 (SpinButton1 is the default name of the control).

Place the following code in the spin-down event:

      Sub SpinButton1_SpinDown ()
         If Ole1.AppIsRunning Then
            Ole1.Object.Application.WordBasic.VLine 1
         Else
            Ole1.Action = 7 'Activate
         End If
      End Sub


Place the following code in the spin-up event.

      Sub SpinButton1_SpinUp ()
         If Ole1.AppIsRunning Then
            Ole1.Object.Application.WordBasic.VLine -1
         Else
            Ole1.Action = 7 'Activate
         End If
      End Sub


Save the project.

Run the application.

Double-click the OLE control to activate the Word .DOC object for visual editing.

10.Press the spin button to scroll up and down the document.


Notes
You can speed up the scrolling by changing the delay property on the spin button. You can also change the number of lines that the VLine method scrolls through.
Some other controls that do not receive the focus are the shape, line, frame, 3D frame, 3D panel, and label controls.
 


--------------------------------------------------------------------------------

Additional reference words: vb4win scrollbar
KBCategory: kbole kbprg kbcode
KBSubcategory: IAPOLE


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: May 17, 1996
)1997 Microsoft Corporation. All rights reserved. Legal Notices.
 


0
 
LVL 1

Expert Comment

by:BlackAndWhite
Comment Utility
Let me know if you still have problems..


0
 

Author Comment

by:wave180
Comment Utility
thank you very much, its such a great help
0
 
LVL 1

Expert Comment

by:BlackAndWhite
Comment Utility
You are welcome.  I look at the knowledge base first to see if there is a solution for my problem and if I cant find it there I look at other sources.  

So you didnt increase the points!!! Just kidding.
0
 

Author Comment

by:wave180
Comment Utility
BlackAndWhite,
  I intend to increase your points, but how should i do it, im just a new user here.
Of course, you deserve higher points. its a satisfactory answer,
thanks.

eldie.
0
 
LVL 1

Expert Comment

by:BlackAndWhite
Comment Utility
I myself am new...moreover I was just kidding.  You intention to give me points is as good as giving it.. Thank you. Let me know anytime if I can be of any help to you.

Janaks@iccinet.com
0
 

Author Comment

by:wave180
Comment Utility
BlackAndWhite,
  Thanks for your support and i'll just send you email if i have another questions.

Eldie.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now