About This Code
Brief Description:
Dynamically set dialog box position/size w/WIN API
Contributor:
Andrew Jones
Last Modified:
17 Jun 2002
OpenNTF Disclaimer
All of the program code and information presented in the OpenNTF.org Code Bin are provided "as-is", and should be used at your own risk. OpenNTF.org make no express or implied warranty about anything in the Code Bin, and OpenNTF.org will not be responsible or liable for any damage caused by the use or misuse of anything from this site. OpenNTF.org makes no guarantees about anything. Please thoroughly test all of the knowledge and code you find here before you attempt to use them in your production environment.
Code / Description
My client was having a problem with the position of the dialogbox (notesuiworkspace method). There was a field on the dialogbox (a dialogbox field). When the user clicked the "arrow" to bring up the dialogbox, half of the information was hidden because of the top of the screen. So here is some code to adjust the position and, if you need, the size of the dialogbox using WIN API.
Usage / Example
Declarations Section Of Form To Be Loaded In Dialogbox:
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (Byval lpClassName&, Byval lpWindowName$) As Long
Declare Function SetWindowPos Lib "user32" (Byval hwnd As Long, Byval hWndInsertAfter As Long, Byval x As Long, Byval y As Long, Byval cx As
Long,Byval cy As Long, Byval wFlags As Long) As Long
Const HWND_TOPMOST = -1
Const HWND_NOTOPMOST = -2
Const SWP_NOSIZE = &H1
Const SWP_NOMOVE = &H2
Const SWP_NOACTIVATE = &H10
Const SWP_SHOWWINDOW = &H40
'PostRecalc of Dialogbox Form
Sub Postrecalc(Source As Notesuidocument)
Dim myhWnd%
'class name and title of dialog box
'Algorithm - Step 1 --> get window handle
myhWnd = FindWindow(0, "Specify a Material Number and Batch Number")
' Parms 3 and 4 are x and y,
' Parms 5 and 6 are window width and height
'Parm 7 is constant Hex value for what you want to do with active window
'Algorithm - Step 2 --> Set window position by window handle
SetWindowPos myhWnd, -1, 165, 15, 725, 300, SWP_SHOWWINDOW
End Sub