Entrydialog Disappears - Help


Recommended Posts

Hi,

I have a small problem that is quickly becoming a major blocking issue.

I have a number of systems that often need to prompt operator for input data. I use system.entrydialog() within my sequences.

I am carefull to ensure I do not have multiple sequences calling blocking UI components simultaneously.

Normally, code works fine but occassionally, maybe once per week on systems running 24/7 and needing input every 20 minutes or so, the system appears to "Lockup".

Actually, the System.EntryDialog() has gone behind the main DaqFactory screen, but system is locked out waiting for response from user.

The EntryDialog appears to be modal (most of the time!!) but not always ontop of other windows (even in same app), so I have to bring it to the fore to proceed with the system. Daqfactory is full screen, and operator has no access to F4 to find dialog box. I am unable to cancel it or make it time out so system is locked until it is rebooted (or engineer plugs in keyboard or remote accesses it and hits F4 to find and clear dialog).

Can you help?

How can I ensure dialog stays on top - or how can I force it to clear programatically?

Rod

Link to comment
Share on other sites

This is actually a Windows 7 issue. I see it all the time when, for example, I go to print a PDF document from QuickBooks. The save as dialog appears behind quickbooks instead of on top.

My recommendation is this: don't use EntryDialog(), but instead create your own popup window out of a standard DAQFactory page. Then you have control over making it appear and disappear from within DAQFactory, you can open it modeless instead of modal (meaning it won't block the main application), and you can check to see if its already open using some flags. Plus you'd have total control over what the dialog looks like.

For that matter, you could make a modal window and just leave it open and have just the edit box appear and disappear. Kind of depends on your application.

Link to comment
Share on other sites

Hi,

Probably not a windows 7 problem as I'm running on Windows XP :-), Sorry, forgot to tell you that bit.

Anyway, I understand - I must admit though I haven't seen it in other applications.

I will build up my own entry screen - I've done it elswhere so shouldn't be a problem.

Rod.

Link to comment
Share on other sites

hmmmm.... brings me back to the problem....

I can do everything I want in a (normal) screen - primarily to intercept keyboard presses so I can process then how I wish,

I really would like to do this in a small window over top of rest of screen where the remainder of the screen that can be seen is still showing live data but buttons etc are disabled. i.e. in a popup modal screen.

Problem is I then have no access to incoming keystrokes.

Is there really no way to get onchar or onkeydown whilst a popup is modal (or modeless)?

Rod.

Link to comment
Share on other sites

Hi Mark,

Ok, I'm sorry to have to say but this problem is calling the continued use of Daqfactory into significant doubt.

All I need to do is to be able to prompt the user for an input where:-

1. That input will effectively be keyboard input but actually be from a scanner of some type,

2. The input needs to be modal (i.e. no other user activity allowed until input is given)

3. Current display (made up of multiple sub pages in the form of page.strCurrentPage="scn1,scn2,scn3.....") continues to update normally.

4. Focus goes to text entry component immediately dialog is displayed

5. Dialog box is dismissed and text entered is returned when <CR> is entered

6. DIALOG ALWAYS APPEARS!!!!

This, with the exception of the point 6 is exactly what the system.EntryDialog does. Unfortunately all to often dialog box does not appear making system unreliable.

This is not a windows 7 problem.

We are running on Windows XP.

Ideally, I would also like to be able to intercept each character (or keystroke) as it is entered.

I can do most of this using a "Normal" page where I can grab keyboard characters, change them as I like, Put them where I like on the screen etc... Problem is even simple questions have to take up whole screen as I see no easy way to make just a small portion of the screen "Live".

Problems I have are:

1. I cannot use system.EntryDialog because it does not always appear "on top"

2. I cannot use page.MyEntryDialog.PopupModal() because I cannot set focus to any component on it and cannot terminate dialog on <CR>

3. I cannot use a normal page and keep "previous" page visible, active, and untouchable.

Any suggestions?

Will next version provide an answer? Beta versions are all well and good for non production use (btw, many thanks for the Sequence Dump feature - I use it many times every day) but this requirement is for the production systems that have the serious problem right now - How soon could solution be available?

Rod.

Link to comment
Share on other sites

OK, please don't get offended by this, but I like to be honest:

I'm assuming you are using a scanner with a keyboard wedge. Keyboard wedges are kind of 1990's technology. They were created back in the days when there weren't a lot of software options and people wanted their scanners to feed into programs like excel and databases that had no other way to input data. Now, even if you are using those products, there are so many software tools that can push the data into them, that the wedge isn't really needed. Wedges are incredibly challenging to use predictably for the reasons you specified. They require the cursor to be in an exact place, which in windows is pretty difficult. Probably every few days I get cases where I think I'm typing in one place, but some background application has popped up and taken over the cursor.

For this reason, I strongly recommend you dump the keyboard wedge scanner and buy a serial based unit. RS232/485 preferred, USB with Virtual Comm driver if you must. With DAQFactory you can take the input from one of these scanners in the background and do what ever you want very predictably. You could popup a custom screen that says "Scan Now", then waits until the scanner triggers, then displays the value, pauses 5 seconds, then closes. Or whatever you wanted. There's no kludging something together to get it to work. Its all very precise.

Now for your problems:

system.EntryDialog: this is a windows library call to popup the window. It is completely outside DAQFactory control and totally handled by windows. Other than the situation I described in newer windows (and then only in other applications), I have not heard of this problem before, so there is most likely some issue with your system.

However, there may be ways around it by loading up some low level system calls. First you need the one that will find a window:

extern("user32.dll", "long FindWindowA(long,string)", "FindWin", "stdcall")

This is the "by caption" version. In another post I flipped the long and string parameters to get the by className version, which works well if the window caption might change. In your case, in the current release of DAQFactory, the entry dialog has no caption. So, I've recompiled it so you can pass a caption as the last parameter to entryDialog(), then you can find it by that caption. I'm going to email you directly with a link to the file. It is the release version of DAQFactory with only that change, so is production ready:

system.entryDialog("Enter something", "", "", "", "", "my win")

I'm assuming you use defaults for the range etc.

private hwnd = FindWin(0, "my win")

If it returns 0, it couldn't find it. Otherwise, its a windows handle that can be used in any other windows function that takes a handle. Fortunately there is one just for you:

extern("user32.dll", "long BringWindowToTop(long)", "bwtt", "stdcall")

This function just takes a handle for a window and brings it to the top. So:

bwtt(hwnd)

Since I don't know exactly why the popup is coming up behind, nor can I reproduce it, I can't completely guarantee it, but it should do the job. Personally, I would popup the window and then in the next line of script, start a sequence that delays maybe 0.5 to 1 second, then finds the window and calls BringWindowToTop on it. If the window is already at the top, it won't do anything.

Link to comment
Share on other sites

Hi Matt,

Thanks for your suggestions... Yet again I add a little information that I should have included earlier as it does change how the problem appears...

I too am unable to recreate the problem, but unfortunately I have seen the results of it too many times: In one instance I have placed a button on the normal screen that logs a message, waits a little while, and then tries to show the entrydialog again. This should, of course, be inaccessible whist the Entry dialog is doing its modal thing, but it is not and I get lots of logs and unhappy operators (but only one "lost" dialog).

This shows that not only is the dialog hidden behind the normal daqfactory window, but is also not "modal".

Regarding the use of Keyboard wedge...

We use Barcode scanners and OCR scanners, both of which connect as a Keyboard wedge. I can see how using a seperate serial interface, with a new Daqfactory device, could do the job very well, but very few modern PC's have multiple serial ports on them (if any) though they do all have USB ports. Particularly with the OCR pen the device is provided with a driver package that only presents its data as keyboard input. This has the advantage that if a code fails to scan the operator can easily enter the code manually on the keyboard.

However, that is not the problem here... the source of the data - be it real keyboard, virtual keyboard, or wedge input, is irrelevant.. they all go through the illusive System.EntryDialog.

I'm not familiar with the "System.EntryDialog" windows library call - I can find no reference to it in the Platform SDK and a web search only turns up references to Java, Pearl and PHP EntryDialogs which I suspect are not the ones you use?

Do you use the HWND_TOPMOST for its placement when it is created? If so, then indeed it must be a windows problem that it occasionally disappears.Or do you use the CreateDialog() or DialogBox() Windows function - again, if you use the DialogBox() API call then again it must be a (pretty unusual) Windows bug.

I will try the new version tomorrow and let you know... As a very minimum I like the Idea of being able to set the dialog Caption :-)

Rod.

Link to comment
Share on other sites

The call isn't called System.EntryDialog() in windows. In windows it is simply a Modal Dialog, implemented through MFC as a CDialog. The MFC CDialog class handles the display of the dialog when we call its DoModal() function.

It's possible the issue relates to you trying to fire off the dialog from a secondary thread. I can't really say. What I do know is that the windows calls I referenced work from any application. In fact, to test, I started one copy of DAQFactory and had it display the EntryDialog(), then in another instance of DAQFactory I did the FindWindow() and BringWindowToTop() calls, so these should work from secondary threads. Give it a try and tell us how it works for you.

Link to comment
Share on other sites

  • 1 month later...

Hi Matt, I haven't implemented this yet as, for the last two months now, the problem hasn't reoccured and I don't want to load new versions unless it is absolutely neccessary as we are in a critical stage for acceptence of the systems.

However, the problem has re-occurred this morning though in a slightly different manner.

Same problem that a dialog, which should be modal, is dissapearing behind the main Daqfactory window. This time it is not a System.EntryDialog but a Daqfactory screen that is initiated with a "page.UnwindReelPagecurrent.PopupModal(NoClose)".

Customer reported that a part of the system had stopped working - the part that required that particular modal dialog. Other aspects of the system continued to work well. In fact, the dialog was on screen, but hidden behind the main screen.

If I have to put the "FindWindow" call etc after every call for a modal dialog (system or daqfactory screen) I will, but it would not be an ideal solution.

I have had a similar difficulties to this in C++ programs I have written and ended up having to write considerable extra logic to marshal the calls for modal dialogs to the main UI thread, where I was able to easily create standard modal dialogs. One program I have written has been in use now for more than 18 years and is now installed at thousands of sites without any sign of this problem.

Rod.

Link to comment
Share on other sites

  • 1 year later...
As you can probably guess by the time taken to respond to your last question this has not been my highest priority problem, though still very real.

 

As a direct response to your question... No, I can't create a simple document that demonstrates it. Even in a non simple document I can't predict with an accuracy of better than +/- a couple of months when the problem will occur.

 

However, I'm having to revisit it as I still get problems with UI lock ups.

When "lock up" occurs (as reported by operators as system "Freezing") system is still running - sequences ticking over nicely logging data, updating components on screen, but there is no response to users inputs.

 

I'd like to make all my dialogues page.xxx.popupmodal(), but I have the problem mentioned last June - i.e. I need to handle keys as they are pressed and, have the system respond when the <Return> key is pressed.

 

I know as Onchar doesn't work in a popup I can use OnKeyDown, but unfortunately whilst that gives me a code for most keys on the keyboard it does not give anything for the <RETURN> key. So when operator enters data and, naturally, presses <Return> nothing happens. I'd have to tell them to press another button on screen to enter the data. Unfortunately that is not acceptable. 

 

I think I can live with compoment.xxx.SetFocus not working but I can't see a workaround <Return> not happening.

 

Is there any (easy) way to get <CR>  in a popup modal dialog?

 

Rod.

 

p.s. this is mostly on Windows XP. Some systems are running under Windows 7, but with a much reduced program that has very little (if any) user data entry.
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.