Updating toolbar button state MFC - visual-c++

I have a dialog in MFC application, which is having menu-bar. Now I have created a toolbar in that dialog using the same command ID which is in the menu-bar.
I use to update the menu-item's state and makes it enable/disable as per some check in ON_UPDATE_COMMAND_UI, When I clicks on the menu. But for toolbar I didn't gets these calls to update it's state, If it should be enabled/disabled.
Moreover I didn't have any notification when the test fails and I to disable the item.
Is there some alternative for doing this?
Thanks
call to ON_UPDATE_COMMAND_UI is only coming when I click on the toolbar button.

Use MFC in a dialog can be frustrating.
I suggest you disable the toolbar button directly when changing state to the variable that will enable / disable the menu:
void CtestDlg::OnBnClickedButton_DisableSomeControls()
{
command_menu_1 = !command_menu_1;
m_ToolBar.GetToolBarCtrl().EnableButton(ID_COMMAND_TEST, command_menu_1);
}
is not very elegant, but it works!

Related

How to create a pop up in hybris backoffice?

I am trying to create a popup message in the Backoffice PCM. In particular, from within the editor area of a product. From the editor a user can click on the assortment view or compare view buttons on the side toolbar to change screens (redirect).
I want to give the user a popup to inform them that any changes will be lost.
Any ideas on how to accomplish this?
I have tried to create my own widget and wiring my custom widget to the ootb pcmbackoffice-toolbar but have not been successful.
It's possible to display a simple popup via the ZK framework (the framework used by Backoffice). From the backoffice code you can open a popup like this:
import org.zkoss.zul.Messagebox;
public void someMethod() {
// do some actions...
Messagebox.show("Some Messagetext", "Info", Messagebox.OK, Messagebox.INFO);
}

Create a generic popup panel

I have added a Global Button with the following code.
public override void Initialize()
{
if (!String.IsNullOrEmpty(Base.PrimaryView))
{
Type primaryViewItemType = Base.Views[Base.PrimaryView].Cache.GetItemType();
PXAction action = PXNamedAction.AddAction(Base, primaryViewItemType, "SubmitTicket", "Submit Ticket", TestClick);
}
}
public IEnumerable TestClick(PXAdapter adapter)
{
throw new PXException("Button clicked from graph" + Base.GetType().Name);
}
And it renders the button like this in each of the pages.
Now, I would like to display a popup panel, on button's click. I know I can create a popup panel on screen section. But, is there some way that I can have a general popup panel created in one place and can be displayed on each of the pages on the button's click?
Thank you.
As #HB_ACUMATICA mentioned there is no good easy way.
Providing another alternative to his post, you can create a graph and use it as a reusable popup by calling:
throw new PXPopupRedirectException(graph, string.Empty, true)
One thing I ran into was a sizing issue on the popup...
Changing the height/width when calling another graph as an in-page popup using PXPopupRedirectException
If you do copy and paste the PXSmartPanel you can create re-usable business logic by implementing the reusable business logic pattern found in this help as a starting point:
Reusing Business Logic
If I understand correctly you want to share the same PXSmartPanel control in different pages without having to copy/paste it in every screen.
In Acumatica Framework this is achieve by custom container controls like 'PXUploadDialog' which derives functionality from other controls like 'PXSmartPanel'. This is the control that is used when you attach files in all screen.
Unfortunately there seems to be no documentation on how to achieve this.
The closest I found is this SO question which is essentially unanswered:
Create custom User Control for Acumatica
Considering this, you may want to copy/paste the same smart panel in all screen.
To ease copying you can use the 'Edit ASPX' feature, make sure you backup the project before.
Edit ASPX to get to the code:
Copy paste your smart panel in the page and click 'GENERATE CUSTOMIZATION SCRIPT' to package the changes in the project:

Foundation 6 off-canvas disable close if user click on a link

How and where I need to set the data-close-on-click params in my off-canvas to avoid the menu to close when user click on a link inside the menu?
Using jquery:
$('#yourDatePickerID').click(function(e)
e.stopPropagation();
e.preventDefault();
});
Depending on which date picker you are using this may or may not work. It may even not allow you to open the calendar image. If it doesn't work I suggest you look into what event for your date picker is fired when the ok button is clicked. Attach this code to that event instead of the click event and try again.

Dynamic CRM 2011. Hide/show tabs using radio buttons issue

I have this code that hides tabs and shows tabs in CRM 2011. By default all tabs are hidden, but when the client has the product purchased (yes selected), the tab is showen.
The issue I am having is when I click yes and save & close. Then reopen the account, the tab is hidden, but the option is still yes.
The code is:
function showTab(tabNumber, optionField, optionValue) {
if (Xrm.Page.getAttribute(optionField).getValue() == optionValue) {
Xrm.Page.ui.tabs.get(tabNumber).setVisible(true);
}
else {
Xrm.Page.ui.tabs.get(tabNumber).setVisible(false);
}
}
The option I have is:
2,"new_server",'1'
I got the code from this place:
Show a Tab Dynamics CRM 2011
I am still working on this.
You need to register this function on both the form's OnLoad event and the field's OnChange event. It sounds, from your description, that it is registered and working for the OnChange event but the OnLoad event.
You currently have the function registered on the onChange event for the radio button control.
Additionally, you need to register an onLoad event for the form.
Create a new web resource.
Open Form Properties.
Add form to available resources.
Add event handler onLoad, and call your webresource.
In the web resource you can just have a call to your showTab function.
When you open the form for customization, look at the top ribbon of the form. You will see Form Properties icon right next to Preview. Click on Form Properties and then add the JavaScript web resource in the Form Library.
Choose Event: OnLoad from the drop down and then click add under the Event Handler.
Choose the web resource of your choice, add the function name being used in your code (showTab).
This will add the function to your Onload event of the form.

How to identify a button click in coded UI Customised code

In UIMAP.CS file in both the Recorded method and assertion method, I am not able to identify the button click.
Is there any way I can get hold of the button click event?
I am able to get hold the button in to a UITESTCONTROL variable but the options I was able to see are "exists", "enabled","name" etc...
I tried checking it with assertions too when I dragged the cross hair on to the clicked button , assertions are generated only for checking the existence,correctness of text and name but not the events occured on it..
Please help in this regard..
Please make sure that the Control/Object on which you want to use the Click operation is a button and not any Web Element or control which does not support the Click operation.
Once verified, you can do the following:
Record a New Session and while recording click on that button, stop your recording.
Open the UIMap.cs and navigate to that button control. The intellitrace would show you all the available options for that control.
Thanks
Nikhil

Resources