-
OK, I'm using this API function in Access97 to give me a standard File Open dialog box. However, when the dialog box appears, it is placed close to the top left hand corner of the screen.
Being as aesthetically anal as I am, how can I centre this dialog box in the middle of my screen
Thanks in advance...
-
In case you missed it, teh function is GetOpenFileName Lib "comdlg32.dll"
-
You're in luck I'm building a windowhandler class :)
Code:
'Here are some types and api calls:
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetWindowRect Lib "user32" (ByVal hWnd As Long, lpRect As RECT) As Long
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
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
First find the handle of the window:
Code:
FindWin = FindWindow("Class", "Caption")
Then move it with this:
Code:
Public Function Move(WinhWnd As Long, x As Long, y As Long, Optional width As Long, Optional height As Long)
Dim win As RECT
GetWindowRect WinhWnd, win
If width = 0 Then width = win.Right - win.Left
If height = 0 Then height = win.Bottom - win.Top
MoveWindow WinhWnd, x, y, width, height, 1
End Function
Let me know if you need something!
-
How do you deal with threading? The File Open Dialog box does not exist until you call the GetOpenFilename Function.
And no code is run until the program receives the response from the Function. Am I missing something?
I am currently using the Common Dialog API to get several filenames from the user. I want to save the changes
that the user makes to the file display (ie List view or Detail view and Sort by column), but I can't modify the dialog
box because I can't run any code while it exists.
Any help would be appreciated.
Kevin