|
-
Jun 1st, 2000, 02:20 AM
#1
Thread Starter
Lively Member
I have a program, I'll call it 'SS'. SS stores its information in a database. I'm developing an administration program to create databases for SS to use. I need to let the user choose where the database should be stored. Because the database server has to store the database, and not the local machine, I can't use a typical browse-for-folder dialog, since they work off the users's machine. I have a TreeView control and am perfectly able to populate it with the server's directory sturcture. However, tree views can be fairly big - so I'd really like to be able to make it appear at the click of a button, much like the list box part of a CBS_DROPDOWN/CBS_DROPDOWNLIST combo box.
My question is, how does the combo box accomplish this feat? After some simple observations, you'll see that the combo box is able to draw its list area OUTSIDE of its owner's window area - quite a feat, given that Windows doesn't generally let applications do such things.
Another thing is that clicking outside the list area will close the list back up. I tried using the LostFocus event, but that only works if the user clicks another control. If the user clicks the form, or a windowless 'control' (i.e. Line, Shape, Label, Image), nothing happens.
- Steve
Real programmers use COPY CON PROGRAM.EXE
-
Jun 1st, 2000, 02:25 AM
#2
Frenzied Member
-
Jun 1st, 2000, 02:38 AM
#3
Thread Starter
Lively Member
Okay...so how do I go about doing this myself? What are this windows' styles? What is its parent window? etc. etc.
- Steve
Real programmers use COPY CON PROGRAM.EXE
-
Jun 1st, 2000, 03:26 AM
#4
Frenzied Member
hmm, you probably want to add a form to your usercontroll and make it appearwith height = 0 and make the height bigger gradually.
-
Jun 1st, 2000, 03:53 AM
#5
Thread Starter
Lively Member
usercontrol? I'm not using a usercontrol. Usercontrols are restricted to their parents' client area, so if I made a usercontrol and made it bigger, the bottom and right sides would just be cut off. I need it to be 'over' everything else.
- Steve
Real programmers use COPY CON PROGRAM.EXE
-
Jun 1st, 2000, 07:55 PM
#6
Frenzied Member
right, I've got a very simple example for you, in a usercontrol project, have a command button to the right of your control, change the background colour so you can see it and add this code.
Code:
Option Explicit
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Dim frmDropDown As New Form1
Private Sub Command1_Click()
Dim apiControlRect As RECT
Dim apiButtonRect As RECT
GetWindowRect UserControl.hwnd, apiControlRect
GetWindowRect Command1.hwnd, apiButtonRect
frmDropDown.DropDown apiControlRect.Left, _
apiControlRect.Bottom, _
apiButtonRect.Left - apiControlRect.Left, _
(apiControlRect.Bottom - apiControlRect.Top) * 5
End Sub
now add a form to your usercontrol project, set the borderstyle to 0 and change the backcolour, add a commandbutton near the top left and add this code
Code:
Option Explicit
Const DROPDOWNTIME = 2
Private Declare Function MoveWindow Lib "user32" (ByVal hwnd As Long, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long) As Long
Public Function DropDown(X As Long, Y As Long, Width As Long, Height As Long)
Dim sngStart As Single
Dim lngCurrentHeight As Long
MoveWindow Me.hwnd, X, Y, Width, 0, True
Me.Visible = True
sngStart = Timer
Do While Timer < sngStart + DROPDOWNTIME
MoveWindow Me.hwnd, _
X, Y, _
Width, _
Height * (Timer - sngStart) / DROPDOWNTIME, _
True
DoEvents
Loop
MoveWindow Me.hwnd, X, Y, Width, Height, True
End Function
Private Sub Command1_Click()
Me.Hide
End Sub
then go to the file menu...AddProject and add a standard exe, right click project2 in your project explorer and select set as start up
add the controll to the form of this new project so you can see the command button and run the code.
-
Jun 1st, 2000, 08:39 PM
#7
Thread Starter
Lively Member
Cool, thanks...but how do I make it disappear when it loses focus?
- Steve
Real programmers use COPY CON PROGRAM.EXE
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|