Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using FindWindow to close Dialog Box

Status
Not open for further replies.

Phailak

Programmer
Apr 10, 2001
142
CA
Hail,

What I need to do is the following:
When a user clicks a button, an excel sheet is sent through a fax driver in order to fax the info to the proper person. Everything works fine but the user has to manually enter the fax number in a dialog type window (issued from fax driver). Through some rough code, I manage to automate the task by looking for the window with FindWindow API and SendMessage for the faxnumber and so forth. My problem is I put FindWindow in a timer control (sort of a loop process) that looks for the window and once that it finds it, triggers appropriate code. Sometimes it works, other times it doesn't. Oh yeah and the timer only starts once the project is in EXE mode. When I debug with F8, I cannot go further in the code with F8 until the dialog box is closed. I have a feeling the answer is real simple, but I'm stomped.

Phailak
 
I'm afraid I may not be much help except that I tried to use FindWindow at one time (a while ago) and was pretty preplexed by the results I was getting.

I ended up using the little routine shown here, however, the instance I used it in the window I was looking for would definately be the topmost/active window.

As you probably know, GetActiveWindowText, GetForegroundWindow, GetWindowTextLength and GetWindowText are all API's you'll have to declare.

I used this with no trouble in much the same situation you seem to have, a timer to look for 5 or 6 different windows coming and going.

Good luck!!


Function GetActiveWindowText$(ghwnd&)
'passes back the active window text and it's handle back ghwnd&
ghwnd& = GetForegroundWindow() 'get the topmost window
winlen& = GetWindowTextLength(ghwnd&)
wintxt$ = String(winlen&, " ")
z% = GetWindowText(ghwnd&, wintxt$, 255)
GetActiveWindowText$ = wintxt$
End Function

 
Hail,

Thanx for the suggestion, that's a great idea, I actually have them declared already, imagine I used tehm but never thought of it that way. I'll give it a try probably tomorrow, thanx again

Phailak
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top