Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

On frmDocument--resizing 1

Status
Not open for further replies.

wujen

Programmer
Aug 21, 2001
79
US
Hey all,

I wondering how to make 2 text box be resizable thru a middle strip area

here is the code:

option explicit
private sub form_load()
form_resize

private sub form_resize()
on error resume next
rtftext.move 0,0,me.scalewidth/2.me.scaleheight
rtftranslate.move rtftext.width +30, 0, me.scalewidth/2, _ me.scaleheight

that +30 area(or it can be larger) to be able to move so if that the user wishes to have more of one side visible/usable then that would be available.

Any thoughts how to do that ?

thanks

Aaron
 
Are you looking for something that changes the width of your two objects when the user performs some mouse action in the area between them?

Wil Mead
wmead@optonline.net

 
Wil,

Yes I am....how would I do this.

Aaron
 
Here is code from a quick and dirty example.
I made a simple form with 2 picture boxes (instead of text boxes, sorry) side by side. This is by no means perfect, but it gives you data for triggering your resize event. On the mousedown, if the cursor is where you want it, you can change the mousepointer to the eastwestarrow. Also, this is written for right-left alignment of boxes, but is easily adaptable for up-down (use y instead of x). Refine the resize event to keep your boxes on the form and have a minimum width too (border conditions).

Option Explicit

Const BUFFER = 200 'keep a constant distance between boxes

Private oldx As Long
Private newx As Long
Private deltax As Long
Private DoResize As Boolean

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If X > (Picture1.Left + Picture1.Width) And X < Picture2.Left Then
oldx = X
DoResize = True
End If
End Sub

Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If DoResize = True Then
newx = X
deltax = newx - oldx
If deltax <> 0 Then
ResizePictureBoxes
End If
End If

oldx = 0
newx = 0
deltax = 0
DoResize = False

End Sub

Private Sub ResizePictureBoxes()
Picture1.Width = newx - Picture1.Left
Picture2.Left = Picture1.Left + Picture1.Width + BUFFER
End Sub

scarfhead
 
scarfhead,

I tried your code and inserted the text boxes instead and the midbar will not move to the left or the right. It resizes the width and height of the form no problem.

So what would I have to do for that to occur?

Aaron
 
midbar is a line or something between the boxes, yes?

in Resize
midbar.left = newx 'moves midbar to newx location

Oh yeah, code bug up above. I added in the setting everything to zero business after I tested it. Take that out because it screws up newx when you try to use it in Resize. (i.e., remove newx=0, oldx=0, deltax=0 from the code).

Sorry 'bout that.
'zat help?

scarfhead
 
scarfhead,

adding midbar coding in the resize and it just does nothing at all.(it is colored different to show where it is --and it disappears)

Aaron
 
hi mr.wujen,

The solution to ur problem comes with VB itself.
Start new project and start Application wizard.
When you are prompted to select MDI,SDI or explorer style
choose explorer.

click the finish button.

look into the code.The program uses two lists,a treeview and a listview.there are two images between the lists doing what you have asked for.copy the code,make necessary changes,replace lists with text boxes and that does what you want.

reply if you dont find it.

Rajendra
sairajendra@hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top