MFC CDateTimeCtrl SetTime Issue - visual-c++

I have a CDateTimeCtrl in my code for time which is initialized by current time and is enabled/disabled and time setting is done by click of a tree control.
Now, when I click an item of tree control, first the dateTime control is enabled and a time is set according to data present in my tree control (Say 14:25:17).
Then, when I click on another item of tree control, time is set in the time control (Say 14:26:30).
Now, when I click again on previous tree item, although my SetTime function is called with correct time value (which is 14:25:17) but time which is set and displayed in the control is not updated (it still is 14:26:30).
The GetTime also returns 14:26:30 value.
The code I am using to set the time is:
UINT64_T newSTime = info.m_uiStartTime / 1000; // Time I receive from tree control (in msecs)
CTime start_time(newSTime);
m_StartTime.SetTime(&start_time);
I have tried SetRedraw, Invalidate, UpdateData but nothing is working.
Hope you guys can suggest something.

Related

Setting Input Value with a Variable at set interval

I have an HTML input text box and I am trying to use Javascript to display a live clock inside this text box (ie. use a script to update the current time every second, and insert this current time into the value=""
To do this, I have a javascript function startTime() running to grab the current time in 00:00:00 format. Then I'm using another function setInputValue() to make the results of function startTime() as the "value" of the input text box
This works and displays the current time inside the text box, as expected.
Since this only displays the time that the scripts were loaded, I need a setInterval() to make it update every second. Unfortunately, adding var t = setInterval(startTime, 1000); does not do it. I've also tried setInterval(setInputValue, 1000); and that does not change the time each second, either.
I'm pasting my code here on this link: https://www.w3schools.com/code/tryit.asp?filename=G1B141Z87FCF
Edit to add: While there are probably easier methods than making the end result the value of an input text box, I am having to do it this way because this "live time" will be displayed as an overlay on a video stream. The only way I have access to editing the text of this video overlay is by changing the "value" of the text box. It all works to display the time, it's just not changing each second unless I manually refresh the script.
Thank you for any help you could provide.

How can I force read updates in all Smart Panel fields before reading it after a user updates and closes it?

I have a smart panel where I preset a default value for a field within it. If the user changes the value of that field, when the popup is closed, the value remains the old, preset value. I've had this happen in two separate instances: one regarding setting a time and one regarding selectors. The fields are set to commit changes = true. Is there any way to force the code to grab the new value set by the user instead of keeping the value set before displaying the smart panel popup?
Example:
Smart panel has a view called Option. OptionA will be set to something before the popup is executed. After the popup is closed by the user, even if the user changed the selector's value, the code will see the originally set value to OptionA set programmatically before the popup was executed.
Option.Current.AOption = 10;
if (Option.AskExt(true) == WebDialogResult.OK)
{
//This will display the original value
Document.Ask(Option.Current.OptionA, MessageButtons.OK)
}
Initial popup:
User changed:
Popup after closing and executing Document.Ask():

View data being cached/failing to refresh

I have a tabbed panel containing different sections of a form. In one section, users are given the ability to add a child document to the currently open document. In a second section, they are given a listbox, where the options are dynamically generated (via #DbLookup) by looking at a view of all the child documents, filtered by the current document's ID. This functionality all works correctly, however, there is a problem with the dynamic listbox options.
When a user adds a new child document, then switches to the next tab, the listbox is not updated with this new document. If they save/re-edit the main document or refresh the page, it makes no different, the user must load another XPage before going back to the original in order for the listbox to update. I have tried to resolve this by doing full updates of the page, using session.evaluate and "NoCache" in the #DBLookup call, or calling database.getView("My view").refresh(), but without luck.
There is also a similar problem where I have a repeat control which uses a view of child documents (again filtered by main document ID) as a datasource. When a user adds a child document using a button, it partially refreshes the repeat - but doesn't show the new child document until the page is refreshed again (or you leave the page and return).
Is there something crucial I am missing with regards to the JSF lifecycle/the way that view data is cached?
As first measure I would add another formula item to the listbox which simply returns the current time (#Now() should work). That way you can check if the listbox options are refreshed on the update in the first place.
If the options are refreshed fine it's indeed clear that the #DbLookup does some caching, although I'm not aware of any default caching logic.
At least for a test I would change the code to use a NotesView object instead of the #DbLookup, something like this:
var nview = database.getView("someview");
var nc = nview.getAllEntriesByKey(currentDocument.getDocument().getUniversalID(), true);
var a = [];
var ve = nc.getFirstEntry();
while (ve) {
a.push(ve.getColumnValues().elementAt(0)); // value of first column
ve = nc.getNextEntry(ve);
}
return a;
(I wrote the code from memory, there may be syntax errors).
Since the code only works with view entries it should be equally fast than the #DbLookup. And you could even do a nview.refresh() if needed.

Coded ui objects in UIMap

I have a question regarding coded ui UIMap.
Every time I record an action on the same application, coded ui generates a new object for the same window in the application.
It looks like:
UIAdminWindow
UIAdminWindow1
UIAdminWindow2
and so on...
every window class holds different buttons, even though it's the same window.
Thus it's very hard to keep code maintenance.
What i would like is that every time i perform actions and records on a window, even if not at the same time, the already generated class for this window, will be updated with the new controls.
any suggestions to why it happens?
Thanks a lot!
You can clean up your UIMaps by doing two things:
Use the UIMap Toolbox (from codeplex) to move controls within the UIMap so they are all under one control tree.
When you have duplicate UI controls, go to the properties for the action that references the duplicate control and change the UI Control property to point to the original control in the UIMap.
The duplicate trees should now be unreferenced and you can delete it from your map, keeping things clean.
And yes, it's a pain to do, but it's worth it for maintainability.
In UIMap.uitest you can change the action name and the control name for better maintenance.
For example: you can set UIAdminWindow as FirstAcessWindow or other name that will express comfortably the control or the action.
What I can guess is that there is some randomly generated content or element identification data such as class or title that may be causing it. This may be caused by different username for example. Also you can update the element from UI map element tree.

Automatically open document when only one document is listed in repeat control

I have a repeat control for a domino view which displays the results from a search field.
As you type more characters into the search field the number of items in the list is reduced. If/When the the list only contains a single item I would like to open item automatically, without having to click the link.
Any ideas are appreciated.
Edit: after some very interesting responses, here are some screenshots
I have 3 elements on the page, a searchbar, a repeat control and a form:
When I start typing in the search bar, the repeat is refreshed with every keystroke:
the list is reduced, typing the next character ...
again the list is reduced, only 2 left, typing again....
Only one left, now it would be time to open the document in the form ..... without clicking the link.
I've tried several events on the page, but it seems that I could not find the one that will allow me to "select" the document and display the data in the form.
It seems that it's not as simple as I thought
Since you want to open the link automatically I don't know if I would try to base it on the getRowCount() of the repeat itself. You don't want to even get that far right? you just want to go to the single document.
I would put a function in beforePageLoad event maybe. Not totally sure which event but I'd try that first. Use SSJS and do a lookup that would basically return a collection of what the repeat would show. If the collection count = 1 then get your destination from that entry and do your redirection from there.
That what I would try at least. Interesting scenario!
Now that I see the screenshots this might be easier then you think and I have already implemented something similar on an internal application that I have built. It does rely on the fact that each entry in the list is 100% unique.
First of all you will need to bind the search field to a scoped variable and the onchange/onkeypress event will need to perform a partial refresh of a panel that contains both the list and the document portion of the page.
For the list the link on each item should set the value of the same scoped variable used in the search box and clicking the link should be set to run a partial refresh of the document area.
For the document area you will need two panels, the first panel will only display if there is no matching document and the second panel will only display if there is a matching document, you can do this in the rendered section by writing some ssjs that grabs a handle to the db/view and does a dblookup and returns either true or false if the document exists depending on panel your dealing with.
With this setup, when somebody clicks a link or fills out the searchbox the scoped variable will contain a value, the document panels will then check to see if this is a unique value in the view in the db and update themselves to either display the 'no document' panel or the 'document' panel accordingly.
You could add a evaluation script to the entry of your repeat control which checks the size of your repeat control using the method getRowCount() from the component. If this is 1 you could execute a context.redirectToPage("yourpage.xsp?id=yourid",true) this forces the current page to send a redirect request back to the browser and therefore redirects you to the correct page.
All you need to know is which xpage you need to open and which parameters you should use. But these could be retrieved from the content you are iterating over.

Resources