kfitts
Aug 1st, 2001, 08:26 PM
I have a small piece of code written and compiled in VB6 which works just as designed when used on a Win 95 OS. However when it is placed on an nT OR Win 2000 OS, it fails with a Run Time Error 6 - Overflow. I am posting the code that is having the problem here, and I hope someone will be able to tell me what I'm missing. Thanks in advance!
Function CheckForNameBox(fName As String) As Boolean
Dim iii As Long
Dim hMsgWnd As Long
Dim lBtnhWnd As Long
Dim msgText As String
hMsgWnd = FindWindow(vbNullString, "Print to File")
CheckForNameBox = False
'If/When window found, send filename to dialog
If hMsgWnd <> 0 Then
'It gets here on NT/2000, but chokes on SendDlgItemMEssage
iii = SendDlgItemMessage(hMsgWnd, 1152, WM_SETTEXT, 0, fName)
iii = SendMessage(hMsgWnd, WM_SHOWWINDOW, 0, 0)
lBtnhWnd = FindWindowEx(hMsgWnd, 0, "Button", "OK")
iii = SendMessage(lBtnhWnd, BM_CLICK, 0, 0)
CheckForNameBox = True
End If
End Function
Function CheckForNameBox(fName As String) As Boolean
Dim iii As Long
Dim hMsgWnd As Long
Dim lBtnhWnd As Long
Dim msgText As String
hMsgWnd = FindWindow(vbNullString, "Print to File")
CheckForNameBox = False
'If/When window found, send filename to dialog
If hMsgWnd <> 0 Then
'It gets here on NT/2000, but chokes on SendDlgItemMEssage
iii = SendDlgItemMessage(hMsgWnd, 1152, WM_SETTEXT, 0, fName)
iii = SendMessage(hMsgWnd, WM_SHOWWINDOW, 0, 0)
lBtnhWnd = FindWindowEx(hMsgWnd, 0, "Button", "OK")
iii = SendMessage(lBtnhWnd, BM_CLICK, 0, 0)
CheckForNameBox = True
End If
End Function