Click here to Skip to main content
15,923,909 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: how i browse using textbox to listbox Pin
Christian Graus8-Oct-07 1:13
protectorChristian Graus8-Oct-07 1:13 
Questionhow to use scroll bar in pictur box Pin
Piyush Vardhan Singh7-Oct-07 23:48
Piyush Vardhan Singh7-Oct-07 23:48 
AnswerRe: how to use scroll bar in pictur box Pin
Christian Graus8-Oct-07 0:26
protectorChristian Graus8-Oct-07 0:26 
AnswerRe: how to use scroll bar in pictur box Pin
Abhijit Jana8-Oct-07 0:27
professionalAbhijit Jana8-Oct-07 0:27 
GeneralRe: how to use scroll bar in pictur box Pin
Piyush Vardhan Singh8-Oct-07 0:31
Piyush Vardhan Singh8-Oct-07 0:31 
GeneralRe: how to use scroll bar in pictur box Pin
Abhijit Jana8-Oct-07 1:49
professionalAbhijit Jana8-Oct-07 1:49 
GeneralRe: how to use scroll bar in pictur box Pin
Dave Kreskowiak8-Oct-07 4:43
mveDave Kreskowiak8-Oct-07 4:43 
AnswerRe: how to use scroll bar in pictur box Pin
JamesS[C1]8-Oct-07 8:54
JamesS[C1]8-Oct-07 8:54 
Hello Piyush,

I hope the following code helps:

Private bWindowIsResizable As Boolean

Private Const WM_NCLBUTTONDOWN = &HA1
Private Const HTBOTTOMRIGHT = 17


Private Declare Function SendMessage Lib "user32" _
Alias "SendMessageA" _
(ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As Any) As Long

Private Declare Function ReleaseCapture Lib "user32" () As Long



Private Sub Form_Load()

HScroll1.Height = 255
VScroll1.Width = 255

'set flag indicating a resizable window
bWindowIsResizable = (Me.BorderStyle = vbSizable) Or _
(Me.BorderStyle = vbSizableToolWindow)

'set up the picture box used to fill
'the corner between the H and V scroll
'bars, and if the window is sizable
'print a 'gripper' image to the control
With Picture3

.AutoRedraw = True
.AutoSize = True
.ForeColor = &H80000015
.BackColor = Me.BackColor
.BorderStyle = 0
.ZOrder 0

'if sizable windows print the gripper image
If bWindowIsResizable Then
.Font.Size = 11
.Font.Name = "Marlett"
.Font.Bold = False
Picture3.CurrentX = 10
Picture3.CurrentY = 10
Picture3.Print "o"
End If
End With

With Picture1
.BorderStyle = 0
.Move 0, 0
.Cls
End With

With Picture2 'inner (cyan) picture box
'as we're loading an image, expand pix2
'to the size of the loaded graphic
.AutoSize = True
.BorderStyle = 0
.Move 0, 0
.Cls

'obviously, change this to a valid image on your system
.Picture = LoadPicture("c:\windows\xp5layout.jpg")
End With

With HScroll1
.Max = (Picture2.ScaleWidth - Picture1.ScaleWidth)
.LargeChange = .Max \ 10
.SmallChange = .Max \ 25
.Enabled = (Picture1.ScaleWidth <= Picture2.ScaleWidth)
.ZOrder 0
End With

With VScroll1
.Max = (Picture2.ScaleHeight - Picture1.ScaleHeight)
.LargeChange = .Max \ 10
.SmallChange = .Max \ 25
.Enabled = (Picture1.ScaleHeight <= Picture2.ScaleHeight)
.ZOrder 0
End With

Picture3.ZOrder 0

End Sub


Private Sub Form_Resize()

'Picture1 is the *outer* pix box (the red viewport)
'Picture2 is the inner pix box (the cyan container to scroll within the viewport)

'don't attempt resizing if minimized!
If Me.WindowState <> vbMinimized Then

'this prevents an error if
'the form is sized too small
If (Me.ScaleHeight > HScroll1.Height) And _
(Me.ScaleWidth > VScroll1.Width) Then

Picture1.Move 0, 0, Me.ScaleWidth - VScroll1.Width, _
Me.ScaleHeight - HScroll1.Height

With HScroll1
.Left = 0
.Top = Picture1.Height
.Width = Picture1.Width
.ZOrder 0
.Enabled = (Picture1.ScaleWidth < Picture2.ScaleWidth)

'if the form has been resized to
'display the entire pixbox,
'disable the scrollbars
If .Enabled Then
.Max = (Picture2.ScaleWidth - Picture1.ScaleWidth)
End If
End With

With VScroll1
.Left = Picture1.Width
.Top = 0
.Height = Picture1.Height
.ZOrder 0
.Enabled = (Picture1.ScaleHeight < Picture2.ScaleHeight)

If .Enabled Then
.Max = (Picture2.ScaleHeight - Picture1.ScaleHeight)
End If

End With

'position the fake sizing grip
Picture3.Move VScroll1.Left, HScroll1.Top

End If '(Me.ScaleHeight > HScroll1.Height) And ...

End If 'Me.WindowState

End Sub


Private Sub Form_Unload(Cancel As Integer)
Set Form1 = Nothing
End Sub


Private Sub Picture3_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)

'if a sizable window..
If bWindowIsResizable Then

'..fake a resize grabber action
If Button = vbLeftButton Then
ReleaseCapture
SendMessage Me.hwnd, WM_NCLBUTTONDOWN, HTBOTTOMRIGHT, ByVal 0&
End If

End If

End Sub


Private Sub Picture3_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)


'if a sizable window..
If bWindowIsResizable Then

'..users expect a sizing arrow
Picture3.MousePointer = vbSizeNWSE

End If

End Sub


Private Sub VScroll1_Change()
Picture2.Top = -VScroll1.Value
End Sub


Private Sub VScroll1_Scroll()
Picture2.Top = -VScroll1.Value
End Sub


Private Sub HScroll1_Change()
Picture2.Left = -HScroll1.Value
End Sub


Private Sub HScroll1_Scroll()
Picture2.Left = -HScroll1.Value
End Sub

Have a nice day.

Regards,
James

James Smith
www.componentone.com

QuestionHardDisk Serial no Pin
nitin37-Oct-07 22:22
nitin37-Oct-07 22:22 
AnswerRe: HardDisk Serial no Pin
Abhijit Jana7-Oct-07 22:39
professionalAbhijit Jana7-Oct-07 22:39 
GeneralRe: HardDisk Serial no Pin
nitin38-Oct-07 0:27
nitin38-Oct-07 0:27 
GeneralRe: HardDisk Serial no Pin
Abhijit Jana8-Oct-07 0:29
professionalAbhijit Jana8-Oct-07 0:29 
Questionhow to clear an array? Pin
moomoooomoo7-Oct-07 22:17
moomoooomoo7-Oct-07 22:17 
AnswerRe: how to clear an array? Pin
Christian Graus7-Oct-07 22:35
protectorChristian Graus7-Oct-07 22:35 
Questioncompilation error Pin
Ahamed Azeem7-Oct-07 21:38
Ahamed Azeem7-Oct-07 21:38 
AnswerRe: compilation error Pin
Abhijit Jana7-Oct-07 22:13
professionalAbhijit Jana7-Oct-07 22:13 
GeneralRe: compilation error Pin
Ahamed Azeem7-Oct-07 22:32
Ahamed Azeem7-Oct-07 22:32 
AnswerRe: compilation error Pin
Dave Kreskowiak8-Oct-07 4:40
mveDave Kreskowiak8-Oct-07 4:40 
AnswerRe: updating a table in sql server from excel sheet using VB.NET Pin
DanB19838-Oct-07 4:32
DanB19838-Oct-07 4:32 
GeneralRe: updating a table in sql server from excel sheet using VB.NET Pin
DanB19838-Oct-07 9:58
DanB19838-Oct-07 9:58 
GeneralRe: updating a table in sql server from excel sheet using VB.NET Pin
DanB19838-Oct-07 22:38
DanB19838-Oct-07 22:38 
GeneralRe: updating a table in sql server from excel sheet using VB.NET Pin
zamzoum9-Oct-07 0:42
zamzoum9-Oct-07 0:42 
QuestionHow to Autonum with database.... [modified] Pin
xxxheeroxxx7-Oct-07 20:51
xxxheeroxxx7-Oct-07 20:51 
AnswerRe: problem about Autonum with database.... Pin
Abhijit Jana7-Oct-07 20:59
professionalAbhijit Jana7-Oct-07 20:59 
AnswerRe: problem about Autonum with database.... Pin
Dave Kreskowiak8-Oct-07 4:37
mveDave Kreskowiak8-Oct-07 4:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.