Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to scroll data in an OLE container

Posted on 1998-08-05
13
Medium Priority
?
675 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 6
13 Comments
 

Author Comment

by:wave180
ID: 1468044
Adjusted points to 45
0
 
LVL 1

Accepted Solution

by:
BlackAndWhite earned 120 total points
ID: 1468045
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
ID: 1468046
You have any code that will do scroll the Document inside OLE container using
VScroll bar or HScroll bar.

thanks
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 1

Expert Comment

by:BlackAndWhite
ID: 1468047
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
ID: 1468048
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
ID: 1468049
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
 
LVL 1

Expert Comment

by:BlackAndWhite
ID: 1468050
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
ID: 1468051
Let me know if you still have problems..


0
 

Author Comment

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

Expert Comment

by:BlackAndWhite
ID: 1468053
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
ID: 1468054
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
ID: 1468055
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
ID: 1468056
BlackAndWhite,
  Thanks for your support and i'll just send you email if i have another questions.

Eldie.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

721 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