HTML table data issue in MFC application - mfc

I created MFC application based on HTML that using class CDHtmlDialog for rendering of HTML, now I want to get table (row, column) data on_click.
Thanks

Messaging in CDHtmlDialog is handled by DHTML Event Maps.
Insert a hyperlink in html file text Handle messages as follows:
class CMyDHtmlDialog : public CDHtmlDialog
{
DECLARE_DHTML_EVENT_MAP()
HRESULT on_event(IHTMLElement*);
...
};
BEGIN_DHTML_EVENT_MAP(CMyDHtmlDialog)
DHTML_EVENT_ONCLICK(L"event_id", on_event_id)
END_DHTML_EVENT_MAP()
HRESULT CMyDHtmlDialog::on_event_id(IHTMLElement*)
{
//MessageBox...
return S_OK;
}

Related

Sitecore custom ribbon button not working

I have created a custom ribbon button following the steps mentioned in http://jondjones.com/how-to-add-a-custom-sitecore-button-to-the-editor-ribbon/
I can see the button appearing in sitecore:
Custom button
Command does not get triggered when clicked on the button.
Below is my code:
using System;
using Sitecore.Shell.Applications.Dialogs.ProgressBoxes;
using Sitecore.Shell.Framework.Commands;
namespace SitecoreVsPoc.Commands
{
public class TranslateContent : Command
{
private static readonly object Monitor = new object();
public override void Execute(CommandContext context)
{
if (context == null)
return;
try
{
ProgressBox.Execute("Arjun", "Title", "Applications/32x32/refresh.png", Refresh);
}
catch (Exception ex)
{
Sitecore.Diagnostics.Log.Error("Error!", ex, this);
}
}
public void Refresh(params object[] parameters)
{
// Do Stuff
}
}
}
Below is the command I have registered in commands.config:
<command name="contenteditor:translatecontent" type="SitecoreVsPoc.Commands.TranslateContent,SitecoreVsPoc" />
Note: I am using Sitecore 8.2 initial release.
Can someone suggest a solution for this?
In Sitecore 8 it was changed the way you add Ribbon button. As far I see your link is from Sitecore 7 or 6.
To create the new button item for the Experience Editor ribbon:
In the Core database, open the Content Editor and navigate to /sitecore/content/Applications/WebEdit/Ribbons/WebEdit/Page Editor/Edit.
Create a new item based on the relevant ribbon control template, for example, the Small Button template. The templates are located at /sitecore/templates/System/Ribbon/.
For the new item, add the following information:
In the Header field, enter the display name of the button.
In the ID field, enter a unique identifier for the item. For example, you can include the ribbon group name in the ID.
In the Icon field, enter the path to the relevant icon. Depending on the button you create, adjust the icon size accordingly.
Open Sitecore Rocks and add the relevant control rendering, for example SmallButton, to the layout of the button item you created.
Enter a unique ID for the rendering.
For other SPEAK controls, you can point to another item in the Data Source field and specify the configuration in this other item.
Important
More informations you can find here: https://doc.sitecore.net/sitecore_experience_platform/content_authoring/the_editing_tools/the_experience_editor/customize_the_experience_editor_ribbon
http://reyrahadian.com/2015/04/15/sitecore-8-adding-edit-meta-data-button-in-experience-editor/
Before it was very simple, you didn't need to add new code:
https://blog.istern.dk/2012/05/21/running-sitecore-field-editor-from-a-command/

How can I get notified when the property page changes in view class

I have a property sheet (CPropertySheet derived class) and its pages (CPropertyPage derived class) in CView derived view class. I need to get notice at CView derived class when the property page changes.
In my case, handling the PSN_SETACTIVE notification will not work.
The problem is by changing the page I need to update the data in the page from one resource. If that resource is not active then I need to close the view and restart the view again.
CPropertySheet does not receive information about tab changes.
PSN_SETACTIVE and PSN_KILLACTIVE is sent to CPropertyPage instead. You have to handle these messages in each PropertyPage when tab is selected/un-selected.
In MFC you can handle this as follows:
class CMyPropertyPage: public CPropertyPage
{
BOOL OnSetActive();
BOOL OnKillActive();
...
};
BOOL CMyPropertyPage:OnSetActive()
{
BOOL res = CPropertyPage::OnSetActive();
TRACE("CMyPropertyPage tab selected\n");
return res;
}
BOOL CMyPropertyPage:OnKillActive()
{
BOOL res = CPropertyPage::OnKillActive();
TRACE("CMyPropertyPage tab unselected\n");
return res;
}
See also:
WinAPI property sheet
CPropertyPage::OnSetActive
To send notification to CMyView, you will have to find the handle to your target and pass the message.

Changing the title of the MessageBox for DDX_Text()

The message box which is displayed when validation has the title same as that of the project.
I searched MSDN and in google for changing the title of the message box for DDX_Text().
Below is the code snippet form
void CPower_Module::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Text(pDX, IDC_POWER_TXT_IGNITION_OFF_DELAY, delayOffWhenIgnitionIsOff);
}
When the user tries to delete the data in the text box, he will be shown a message Box as
with the application name as the title.
How do I change the title of the message box keeping the functionality same?
Internally AfxMessageBox is called. This function always uses the application title as a title for the message box. The value is stored in CWinApp::m_pszAppname. It is just a LPCTSTR.
Just create a class like this.
class CChangeAppTitle
{
public:
CChangeAppTitle(LPCTSTR pszNewTitle)
: m_strTitle(pszNewTitle)
, m_pszOldTitle(AfxGetApp()->m_pszAppTitle)
{
AfxGetApp()->m_pszAppTitle = m_strTitle;
}
~CChangeAppTitle()
{
AfxGetApp()->m_pszAppTitle = m_pszOldTitle;
}
private:
CString m_strTitle;
LPCTSTR m_pszOldTitle;
};
In DoDataExchange or before you call UpdateData just activate the class:
{
CChangeAppTitle appTitle(_T("my app title");
UpdateData();
...
Be aware that all message boxes that my be initiated by a timer, while this dialog is open, will show the new app title. Also a COM automation that is activated during this class is active will also return the changed app title.
Just Set Your Caption in MessageBox Parameter.
CString v1_sMessageToDisplay;
v1_sMessageToDisplay.Format(_T("Saved Successfully to C:/IniGui/"));
MessageBox(v1_sMessageToDisplay, _T("Your Caption"), MB_ICONINFORMATION);

MDI MFC VC++ how to switch views within mainframe

I am making MDI application , and without using splitter my document has multiple views. Now i want to change the document view from the MainFrame of an application...
here it is what i am doing , i have outlookbar with some menu buttons, when user will click those buttons then i will show CFormView inside the document as a child instead of popup dialog. Now i dont know how to change the view from MainFrame where the menu handler has been written.
Kindly suggest any tip if you know any...there are more than 5 different views and 4 of them are CFormView.
MainFrame ->MenuhandlerFunction (Menu Clicks)
MenuHandlerFunction -> Open New Document with New View Based on CFormView
(total 5 different CFormView and their handlers inside MainFrame Written)
I'm not very sure how you select which view to display, but here is some code to iterate through the views of the current document in your MainFrame:
EDIT: modified code for MDI
CMDIChildWnd *pChild = (CMDIChildWnd*)GetActiveFrame(); // EDIT: added line
CDocument *pDoc = pChild->GetActiveDocument(); // EDIT: added pChild->
POSITION pos = pDoc->GetFirstViewPosition();
while (pos != NULL)
{ CView* pView = GetNextView(pos);
// if this is the view you want to activate
// pChild->SetActiveView(pView); // EDIT: added pChild->
}

CHtmlView class and focus

I have an SDI application written in MFC. The frame is divided into 1 row and 2 columns using a splitter window. Below are details of Row and Column (R0C0 means Row#0 and Col#0)
R0C0 view is a CFormView with multiple input controls like text box, combo box etc.
R0C1 view is a CHtmlView that contains HTML content relavant to the control that has input focus in the R0C0
I am able to update the HTML content and also invoke Javascript functions through my MFC code.
Problem:
When user clicks on the R0C1, continaing CHtmlView, the focus is now on the html page. I wish to allow the user to tab out of R0C1 using the key board and return back to R0C0. Can you help with this please? The user can obviously click on the R0C0 view using mouse but we have a user who needs to use Keyboard for using this functionality.
Let me know if the question is not descriptive enough and I'll simplify it further.
Appreciate your time.
Thanks,
Byte
Try to overload CHtmlView::OnTranslateAccelerator. I have successfully used this trick to disable refresh with F5 key. Derive your own class from CHtmlView and overload
virtual HRESULT OnTranslateAccelerator(LPMSG lpMsg, const GUID* pguidCmdGroup, DWORD nCmdID);
like this:
HRESULT CMyHtmlView::OnTranslateAccelerator(LPMSG lpMsg, const GUID* pguidCmdGroup, DWORD nCmdID)
{
if(lpMsg->message == WM_KEYDOWN && GetAsyncKeyState(VK_TAB) != 0 )
{
// change focus
return S_OK;
}
return CHtmlView::OnTranslateAccelerator( lpMsg, pguidCmdGroup, nCmdID);
}