GFCreateUpDownControl/Mfrm.frm
VERSION 5.00
Begin VB.Form Mfrm
Caption = "Form1"
ClientHeight = 3195
ClientLeft = 60
ClientTop = 345
ClientWidth = 4695
LinkTopic = "Form1"
ScaleHeight = 3195
ScaleWidth = 4695
StartUpPosition = 3 'Windows‑Standard
Begin VB.TextBox Text1
Height = 315
Left = 660
TabIndex = 0
Text = "Text1"
Top = 1320
Width = 3135
End
End
Attribute VB_Name = "Mfrm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
'(c)2001, 2004 by Louis.
'
'Downloaded from www.louis‑coder.com.
'Creates an Up‑Down Control using Windows API.
'
'GFCreateUpDownControl
'source: http://homepage1.nifty.com/MADIA/API/CreateUpDownControl.htm (06‑01‑2001)
Private Declare Function CreateUpDownControl Lib "COMCTL32.DLL" (ByVal dwStyle As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal hParent As Long, ByVal nID As Long, ByVal hInst As Long, ByVal hBuddy As Long, ByVal nUpper As Long, ByVal nLower As Long, ByVal nPos As Long) As Long
Private Declare Function DestroyWindow Lib "user32" (ByVal hwnd As Long) As Long
'GFCreateUpDownControl
Private Const WS_CHILD = &H40000000
Private Const WS_VISIBLE = &H10000000
'GFCreateUpDownControl
Private Const CTL_RIGHT = &H4 'place and size control at right side of buddy window
Private Const CTL_LEFT = &H8 'place and size control at left side of buddy window
Private Const CTL_VIBILE = &H2 'auto‑assign value to buddy window
'DEBUG
Dim UpDownControlhWnd As Long
Private Sub Form_Load()
'on error resume next
Call GFCreateUpDownControl(Mfrm, Text1, 0, 100, 50, UpDownControlhWnd)
End Sub
Private Function GFCreateUpDownControl(ByRef ParentWindow As Form, ByRef BuddyControl As Object, ByVal ValueMin As Long, ByVal ValueMax As Long, ByVal ValueCurrent As Long, ByRef UpDownControlHandle As Long) As Boolean
'on error resume next 'returns True if control has been created, False if not
'NOTE: use this function to place an UpDownControl besides a Text Box.
UpDownControlHandle = CreateUpDownControl(WS_CHILD + WS_VISIBLE + CTL_VIBILE + CTL_RIGHT, _
0, 0, 0, 0, _
ParentWindow.hwnd, 0, App.hInstance, BuddyControl.hwnd, ValueMax, ValueMin, ValueCurrent)
If Not (UpDownControlHandle = 0) Then
GFCreateUpDownControl = True
Else
GFCreateUpDownControl = False
End If
End Function
Private Sub Form_Unload(Cancel As Integer)
'on error resume next
'NOTE: copy the following line to target project, too.
Call DestroyWindow(UpDownControlhWnd)
End Sub
[END OF FILE]