|
|
Title | Position a popup form below a TextBox |
Description | This example shows how to position a popup form below a TextBox in Visual Basic 6. |
Keywords | popup, position, ClientToScreen, ShowWindow, SetWindowPos |
Categories | API, Controls, Software Engineering |
|
|
When the program's main form loads, the code uses the SetWindowPos API function to make the popup form a topmost window.
|
|
' Make the popup form topmost.
Private Sub Form_Load()
SetWindowPos frmPopup.hwnd, _
HWND_TOPMOST, 0, 0, 0, 0, _
SWP_NOMOVE + SWP_NOSIZE
End Sub
|
|
When you click the Show Popup button, the program uses the ClientToScreen API function to find the TextBox's position in screen coordinates. It moves the popup form there and uses the ShowWindow API function to display the form without giving it the focus.
|
|
Private Sub cmdShowPopup_Click()
Dim pt As POINTAPI
pt.X = 0
pt.Y = ScaleY(Text1.Height, ScaleMode, vbPixels)
ClientToScreen Text1.hwnd, pt
frmPopup.Move _
ScaleX(pt.X, vbPixels, vbTwips), _
ScaleX(pt.Y, vbPixels, vbTwips)
ShowWindow frmPopup.hwnd, SW_SHOWNOACTIVATE
End Sub
|
|
|
|
|
|