How do I do this? If you could please kindly include the code for message map and the function itself, that would be greatly appreciated.
EDIT:
More specifically I am wondering how OnFileSave() links to OnSaveDocument(LPCSTR lpszPathName)
How does OnFileSave get lpszPathName?
You don't need to do anything special to override OnSaveDocument(...) it's already a virtual function in CDocument, so your derived class can just declare virtual BOOL OnSaveDocument(LPCTSTR lpszPathName); in it's header, then implement it in the document. Nothing is needed in the message map. OnSaveDocument will be called by the framework as part of OnFileSave which is a handler in the base class for ID_FILE_SAVE. The lpszPathName refers to m_strPathName when called by OnFileSafe, which is set when opening a file or by calling SetPathName. If it's empty when saving, the user is prompted for a file name.
CDocument::OnFileSave is the message handler for the Save menu command. To handle it yourself put this in your document class message map:
ON_COMMAND(ID_FILE_SAVE, OnFileSave)
and add your function:
void CYOURDOCUMENT::OnFileSave()
{
CDocument::OnFileSave();
}
To see everything it does put a breakpoint in your function and start single-stepping.
Related
I have a servicereference with a method I need to use in a test.
The servicereference class is defined as:
public class MyServiceReference : Clientbase<IMyServiceReference>, IMyServiceReference
{
public MyServiceReference()
{
}
..... methods is then defined
}
From my testmethod I have tried both
private MyServiceReference myServiceReferenceFake = A.Fake<MyServiceReference>();
// And
private MyServiceReference myServiceReference = new MyServiceReference();
For both of these is crashes in the constructor with the message:
System.InvalidOperationException: Could not find default endpoint element that references contract.
All I need is to have a callto definition from a method in that class.
How can this be solved?
I've no experience with Clientbase, which I assume to be a System.ServiceModel.ClientBase<TChannel>,but I can make some general comments.
Since you tried first to fake a MyServiceReference, I'll assume that you're not testing that class, and you want to use it as a collaborator for the system under test. In that case, your best bet is to try faking IMyServiceReference. interfaces are very easy to fake, since they don't bring along any behaviour or baggage like faking a class does.
If you feel you really need to fake a MyServiceReference, then we have to contend with the fact that FakeItEasy will eventually call MyServiceReference(), which will call ClientBase<IMyServiceReference>(), whose documentation says
Initializes a new instance of the ClientBase<TChannel> class using the default target endpoint from the application configuration file.
Based on the error you reported, I assume that the application configuration file is not found or does not include the configuration required to create a MyServiceReference. The fact that you get the same error when you just try to instantiate a MyServiceReference directly strengthens my belief.
So I think your paths forward are either to try faking IMyServiceReference or to provide the configuration that ClientBase<IMyServiceReference> needs.
So, there's a problem - I need to transplant "Categories Block" module to "displayTopColumn" hook (yep, designer put categories list near (on?) slider). But, by default, there is no possibilities to do this. I don't like that awful Prestashop restrictions, so maybe there is solution for this problem - remove those restrictions?
Thanks.
Removing those restrictions would not resolve anything for a simple reason: if you could hook the module blockcategories to displayTopColumn, this module would not know what to display in this hook because there is no hookDisplayTopColumn() function in it.
However, you can modify the module, and add a function to manage this hook.
To do so, open the file blockcategories.php and add the following:
public function hookDisplayTopColumn($params)
{
// Your code
}
If you want to display here the same content as in the hookLeftColumn hook, you can simply do this:
public function hookDisplayTopColumn($params)
{
return $this->hookLeftColumn($params);
}
You can also create your own function and template by copying, pasting and modifying the code you can find in the function hookLeftColumn() or in the function hookFooter().
So, I am working on a class called DMFWriteExportData and trying to get it run in Batch.
I am at a point where I need to figure out a way to get rid of fieldControl and the reason being it does not let me Run the class on the server and throws an error because it is not supposed to be running on server? (not sure)
Error: "The method Dialog Control.control cannot be called from the server; use methods on the Dialog Field class instead."
-
public Object dialog()
{
DialogRunbase dialog = new DialogRunbase("#DMF372", this);
FormStringControl control;
dialogExecution = dialog.addFieldValue(extendedTypeStr(dMFExecutionId), executionId);
control = dialogExecution.fieldControl();
control.mandatory(true);
control.displayLength(24);
control.registerOverrideMethod(methodstr(FormStringControl, lookup), methodstr(DMFWriteExecutionParameters, executionIdLookup), this);
control.registerOverrideMethod(methodstr(FormStringControl, modified), methodstr(DMFWriteExecutionParameters, executionIdModified), this);
dialogdescription=dialog.addFieldValue(extendedTypeStr(description),DMFExecution::find(executionId).Description);
dialogdescription.enabled(false);
return dialog;
}
I am wondering:
If it is actually true that this class cannot be set to server
when using control.registerOverrideMethod
If yes, what would be the ideal solution to overcome this situation,
is there any way I can create custom lookups? I see there is method
called registerOverrideMethod in the DialogField class.
Any help would be appreciated.
Thanks,
Khosla
The reason why you cannot (and should) run the code above in batch is because it uses dialog controls that only exist on the client side. You should never run this kind of code on server. Please check runon property of your class and set it to called from.
However, I assume you are using RunBaseBatch. If you are on AX 2012, you should use the SysOperation framework instead.
When using RunBaseBatch, all code is on the same class. This way, you are mixing client side code (main method, dialog method etc) with the code that should run on server (run method). For this reason you should set the "runon" property of the class to CalledFrom, not Server.
You can solve this by using SysOperation which applies the Model View Controller (MVC) pattern that neatly sepperates the two.
For an introduction to SysOperation, check my blog here:
AX2012: SysOperation introduction
My application is built in MFC.After the application executes I need to open the help file provided with exe.
But as I press F1 application gives an error message saying the file cannot be found. This happens because no such file of that name exist.
One would think how about changing the name of help file itself? well that cannot be done I have to change the path as well.
I need to know how does the function of F1 button work and where can I find the same?
I am using VC++ 6.0 (I know its very old, but I am stuck with it).
Thank you.
To show your specific help file, you have to overwrite CWinApp::OnHelp. The path to the standard help file is stored in CWinApp::m_pszHelpFilePath. In this example, I use my own m_path variable.
void CMyApp::OnHelp()
{
::HtmlHelp(((CMainFrame*)AfxGetMainWnd())->m_hWnd,m_path,HH_DISPLAY_TOPIC,NULL);
}
If I remember correctly, by default it's handled by CWinApp::OnHelp() so take a look at your override of the application class first, you may find the ON_COMMAND handler there.
I had an class that extends CWinApp, so overwriting the OnHelp function worked this way:
In the header:
class MyApp : public CWinApp
{
public:
afx_msg void OnHelp();
}
In the cpp file:
BEGIN_MESSAGE_MAP(MyApp, CWinApp)
ON_COMMAND(ID_HELP, MyApp::OnHelp)
END_MESSAGE_MAP()
void MyApp::OnHelp()
{
// your own help function
}
I am using the alarm clock code that I found and trying to customize it.
But I get this error : "com.android.internal.R cannot be resolved to a variable "
for code:
getListView().setItemsCanFocus(true);
// Grab the content view so we can modify it.
FrameLayout content = (FrameLayout) getWindow().getDecorView()
.findViewById(com.android.internal.R.id.content);
I am not sure what this piece of code is doing ( so that I could change it)
Can you please help me resolve this by some alternative piece of code?
The solution is simple.
Just replace: com.android.internal.R.id.content with android.R.id.content
You can directly use R.id.content, you need to have a view by that name in layout.
In your gen->R.java file there should be an int named content which corresponds to a view which should be declared in your res->layout folder. This int would be created automatically by Android.