Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
"SHDocVw.WebBrowser" with "wait"
This is a bit difficult to explain as it concerns a large project, so I extracted the important parts to try to explain my question.
I have in a "SHDocVw.WebBrowser" control and a button that does the following:
1. navigate to a folder path
2. focus on an specific folder using a subfunction

Part I: is how the "SHDocVw.WebBrowser" is set up
Part II: The code under the button that FIRST navigates to a "folder" then executes a subfunction
Part III: contents of the subfunction

The actual question regards, Part II.
If I use a "wait 2" (wait 2 seconds) then the dialog first waits 2 seconds then navigates to the "folder" and thus I run into an error
subfunction (described at Part III) get's executed to soon.
However if I use the code specified at Part II with just "wait" only, the code works perfect!.
* QUESTION: Is it allowed to use just "wait" below in Part II or do I need to use "opt waitmsg"?
* QUESTION: If the "wait" below in Part II is not correct then how do I use opt waitmsg?

   EDIT: If found this to be working, dont't know if it is actually correct (maybe 300 is to much but would result in max 3 seconds)?

  rep(300) opt waitmsg 1; 0.01; if(!we1.Busy) break

In the help it states:
Copy      Help
timeS 0 or omutted: Just process messages that possibly are waiting in thread's message queue, regardless of opt waitmsg.
Note: If the thread has windows/dialogs or uses COM events or some Windows API functions that use Windows messages, you should avoid wait commands in it. Or use small time (<0.1). By default, messages are not processed while waiting, and your thread may temporarily hang. To process messages while waiting, use opt waitmsg.

Note: Don't use Windows API wait functions, because then QM cannot properly end the thread on user request. QM then terminates thread, which causes a big memory leak and possibly more bad things. Also, opt waitmsg is not applied.

PART I , very briefly describes how the 'SHDocVw.WebBrowser' is setup
Copy      Help
str dd:
3 ActiveX 0x54030000 0x0 5 36 194 190 "SHDocVw.WebBrowser"

#sub DlgProc:
SHDocVw.WebBrowser- we1
Shell32.ShellFolderView- fv1
Shell32.FolderItem- fi1
we1._getcontrol(id(3 hDlg))
we1._setevents("sub.we1") ;;need DocumentComplete event

PART II (button code)
Copy      Help

PART III contents of the subfunction
"sub.focus_on"  subfunction contains code very similair to (
Copy      Help
int lv=child("" "SysListView32" hDlg)
SetFocus lv
Acc a.Find(lv "LISTITEM" "VM" "" 0x1015)
SendMessage lv LVM_ENSUREVISIBLE a.elem-1 0

Messages In This Thread
"SHDocVw.WebBrowser" with "wait" - by r0n - 12-31-2019, 06:40 AM
RE: "SHDocVw.WebBrowser" with "wait" - by r0n - 12-31-2019, 07:47 PM

Forum Jump:

Users browsing this thread: 1 Guest(s)