|
tuqu wrote: But all functions are memebers of class CMyDoc, So i don't think they need to be called through a MyDoc object.
If they are not declared static then they HAVE to be called on an object. That's how C++ works
cdecl has nothing to do with this. That would be helpful if you are perhaps calling the functions
from another language (VB, etc.) or a library built with a different calling convention.
Anyway, since they are all in the same class you should have no problem calling a class member
function pointer from within the functions class.
tuqu wrote: error C2064: term does not evaluate to a function taking 2 arguments.
You've declared pFunc like this:
typedef int (__cdecl CMyDoc::*pFunc)(CString ,CString ,CString ,CString ,BOOL);
but you are calling a pFunc function like this:
fun(aa,bb);
The compiler is expecting you to pass 3 CStrings and a BOOL.
|
|
|
|
|
Mark Salsbery wrote: typedef int (__cdecl CMyDoc::*pFunc)(CString ,CString ,CString ,CString ,BOOL);
i'm sorry for my making a mistake. actualy my function have 5 parameters. in order to make it concise ,i reduced the function to having 2 parameters in the message.
can you give me a example that the function called on an object?
|
|
|
|
|
tuqu wrote: can you give me a example that the function called on an object?
// create a MyDoc object
MyDoc *pMyDoc = new MyDoc();
// call a MyDoc method
pMyDoc->func1(...);
|
|
|
|
|
Thanks a lot.
I changed my code as following:
in MyDoc.h
typedef int ( CMyDoc::*pFunc)(CString ,CString ,CString ,CString ,BOOL);
int func1(int,int);
int func2(int,int);
in MyDoc.cpp
int func1(int,int){...};
int func2(int,int){...};
func3(int aa,int bb,pFunc fun )
{
...
fun(aa,bb);
...
}
func4 ()
{
...
// create a MyDoc object
MyDoc *pMyDoc = new MyDoc();
if i=0
func3(a,b,pMyDoc->func1);
else
func3(a,b,pMyDoc->func2);
}
now i have the following errors:
error C2475: forming a pointer-to-member requires explicit use of the address-of operator ('&') and a qualified name
This error appear in func4.
error C2064: term does not evaluate to a function taking 2 arguments
This error appear in func3.
Are there something wrong with the line of func4 which is "func3(a,b,pMyDoc->func1);" or "func3(a,b,pMyDoc->func2);"?
|
|
|
|
|
You still have your pFunc type defined as a pointer to a function that takes 4 strings and a BOOL
as parameters and returns an int.
Yet, you are trying to call through pointers to functions that take 2 ints as parameters and return
an int. Even if you make them match, you have the problem of passing the implicit "this" pointer.
You are stripping so much out of your code it's difficult to put something together but
I tried anyway. See if any of this helps:
class CMyDoc
{
public:
CMyDoc() {}
static int func1(int,int);
static int func2(int,int);
};
typedef int (*pFunc)(int,int);
int CMyDoc::func1(int,int)
{
return 0;
}
int CMyDoc::func2(int,int)
{
return 0;
}
int func3(int aa,int bb, pFunc fun )
{
return fun(aa,bb);
}
int func4 ()
{
int i = 0;
if (i==0)
return func3(1,2,&CMyDoc::func1);
else
return func3(1,2,&CMyDoc::func2);
}
|
|
|
|
|
oh,it works;
Thank you very much!
At first, i did not notice the key of "static", so i think it doesn't work.
Finally,i noticed it. I modified my code. Then the project is built successfully.
-- modified at 7:14 Thursday 7th December, 2006
|
|
|
|
|
hi..
I have perpared a grid and done its panning, I have set its Mapping mode to MM_ANISOTROPIC and set unit as inches. It scrolls well when I am doing panning and draws a grid accordingly but it shows flickering. I have used double Buffering for it Where Flickering is stoped but the Grid is Constant now. I have set the Mapping mode of the new DC also. In the output its origin is shifted now and the area where grid is shows is also constant
plaease tell me how to correct the code so that it start working with double Buffering also..
|
|
|
|
|
My goal is to use the process to access itself on the hard disk and modify its own physical code content permanently. I have adjusted token privileges to SE_RESTORE_NAME in an attempt to overwrite while bypassing the ACL, but trying to open the file gives me error 32 (The process cannot access the file because it is being used by another process.) in which the process protecting the file is the one trying to mod it. I know this is not a good practice of code and for commercial means and unspecific means it is horrible to use but I need to create code like this specifically. Does anyone have any ideas on how to?
|
|
|
|
|
can u explain it some what clearly
manu
|
|
|
|
|
When you run a process the exe file on the hard drive becomes locked. Usually to unlock a file you kill the process using it(which would be itself), but the process i would have to kill is the one that I need to modify it.
|
|
|
|
|
Maybe start another process to do the modification and end the process to be modified.
When the modification is complete, the modifier process can restart the modified process.
|
|
|
|
|
Good People,
Does "IMPLEMENT_DYNCREATE" (and DECLARE_DYNCREATE) mean that I don't have to use the "new" declaration when creating an object. In other words, do those two macro amount to using the "new" declaration (i.e. using free memory)? Is that what MFC means when it says the classes using those macros are created dynamically?
Thank you,
BP
|
|
|
|
|
BlitzPackage wrote: Does "IMPLEMENT_DYNCREATE" (and DECLARE_DYNCREATE) mean that I don't have to use the "new" declaration when creating an object.
No.
BlitzPackage wrote: Is that what MFC means when it says the classes using those macros are created dynamically?
It means that MFC can create an instance of your class dynamically.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Forgive me for asking, but what does "create an instance of your class dynamically" mean if it does not mean that it allocates it in the same way that "new" allocates it?
|
|
|
|
|
Take a look at the source code for the macro.
It adds members to your class so the MFC framework is able to create an object of your class.
This is important, at least, in MFC Doc/View and CObject serialization.
Without this, MFC would know nothing about your classes so it couldn't create an object of your
class
BTW, MFC will still use new to create the object.
|
|
|
|
|
Workspace is a class created as a child of DockSpace (sub-class of CToolBar).
//DockSpace*p_DockSpace;
UINT u=WS_CHILD|WS_VISIBLE|CBRS_RIGHT;
p_DockSpace->Create(this,RUNTIME_CLASS(Workspace),
(CCreateContext*)(pCS->lpCreateParams), "Workspace",u,AFX_IDW_CONTROLBAR_FIRST+33);
//--------------------------
Question:
how to get the pointer to Workspace in DockSpace?
such as:
void DockSpace::SomePlace()
{
Workspace*pWs=GetItByXYZ();
}
is there a function GetItByXYZ() or something to get the pointer to Workspace created by RUNTIME_CLASS?
|
|
|
|
|
what the hell is the problem with respecting the forum's posting guidelines (5.)[^] ?
you've been using Codeproject for more than 4.5 years now, and still you can't post your code samples within <pre> tags ?
come on, edit your post please
|
|
|
|
|
toxcct wrote:
ou've been using Codeproject for more than 4.5 years now, and still you can't post your code samples within
tags ?
calm down my friend!
<div class='ForumSig'>"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and you </div>
|
|
|
|
|
seriously... why not posting "plain english code" when he's there ?
Chris submited forums guidelines ; we MUST respect them to keep a nice place...
|
|
|
|
|
my post is quite clear, u just go away and do not make so many rubish here.
|
|
|
|
|
includeh10 wrote: how to get the pointer to Workspace in DockSpace?
I would make a Function "Init" in the Dockspace-class, called after Create, that would take a Workspace-pointer and stores it for further use.
But maybe the Parent-Window that is handed down via the Create-calls from CToolBar down to CWnd suffices?
You can get it in PreCreateWindow as the hwndparent-Parameter of the CREATESTRUCT, I think.
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation."
-- Caius Petronius, Roman Consul, 66 A.D.
|
|
|
|
|
Hi,
I would like to know if I can perform various types of digital image processing techiniques using Image processing functions of Intel's IPP libraries. I would like to perform operations like FIR filtering (right from creating using frequency response matrix [meshgrid] and then window it [like disk]) and then do some morphological operations etc. These are pretty much stright forward in Matlab, but I would like to implement the whole program in c++.
Anyone have any idea/suggestion??
thanks,
-Pavan.
|
|
|
|
|
Yes, you can. Intel's Integrated Performance Primitives has a library for signal and image processing. It is implemented using SIMD and supports multi-core processors as well. The library is vast, and contains many types of filters in spatial and freq domain. It also has morphological functions too. In fact, matlab is using IPPI to accelerate some image processing operations.
You can check for the presence of IPP in your matlab by typing the ippl command in the console;
[T b ] = ippl
Matlab 2006a usese version 2.0 of IPP, the latest version is version 5.1 (and 5.2 beta if you want to try out.) http://www.intel.com/software/products/ipp/beta.htm
By the way, programming with IPP requires you to handle all sorts of memory management, alignment etc, unlike the simplicity of Matlab.
Good luck,
|
|
|
|
|
Thanks in advance, fellow coders.
I am creating a dialog based app in MSVC++ 6.0.
[No I AM NOT switching to .NET, or should I say .NOT working, LoL).
Anyway, my dilema is this :
I have 1 main dialog, an AboutBox, and 7 child dialogs.
My functions / code for my child dialog buttons wil not work. The exact same code will work when tested in the main dialog or the AboutBox. The AboutBox is a default modal dialog generated by MFC using DoModal. I have now idea how DoModal works [code please?], but I am going for modeless, preferably anyway.
This is a snippet of code [from my main dialog's .cpp file], used to dispaly one of the modeless dialog boxes :
void CInvenStoryDlg::OnButtonNewitem()
{
CInvenStoryDlg *dlg = new CInvenStoryDlg ();
dlg->Create(IDD_DIALOG_NEWITEM, this);
dlg->ShowWindow(SW_SHOW);
}
As you all can tell, I have one heck of a memory leak going here. I know I should use DetroyWindow() for modeless dialogs, as oppossed to EndDialog() for Modal ones, but where in the world do I actually PUT that code?
I assume in the code for the parent dialog, but I want to be sure.
This is a snippet of code [from one of my child dialog's .cpp file]. The code is supposed to be activated when a certain button is clicked. It should read some text from an EditBox into a CSTring, and then fwrite it to a .TXT file in binary mode.
[There is a reason that it is in binary mode instead of ASCII, but that is not relevant here.]
Anyway, here is the function :
void CDialogNewItem::OnButtonWriteNew()
{
#include <stdio.h>
FILE *stream;
int b;
GetDlgItemText(IDC_EDIT_ITEMNAME, m_newitemname);
b = m_newitemname.GetLength();
MessageBox(m_newitemname);
if( (stream = fopen("filename.txt","wb")) != NULL )
{
fwrite(m_newitemname,1,b,stream);
fclose(stream);
}
else
MessageBox("File could not be opened\n");
}
Yes, yes, I know header includes go up top; this was just for experimental purposes. All will be relocated properly upon final completion ...
As I stated before, the [guts] of this function work fine when used in either the main dialog or on the AboutBox, but not in a child dialog. Is it my dialog box settings?
my dialog Create methods? What??!? I've tried everything.
Anyway, I'd like to see code for functional child dialogs, both Modal and Modeless versions, created and destroyed properly. Please speak in English, people, like a normal human, instead of all of that
micro$oft double-talk ala MSDN flavor :
Hwnd, *pArent, (LPCSTR): Be all you can be in the ARMY, COleInsertDialog::DoModal virtual int DoModal( ); int DoModal( DWORD dwFlags );
Whatever the ##@$% all that garble means. Give me actual code please, and no code for
CAboutDlg dlgAbout;
dlgAbout.DoModal();
I have plenty, but I won't be able to understand it until someone shows me how it works for a custom Dilaog, say, like for mine named IDD_DIALOG_NEWITEM.
Anywho, thankees for all the help, and please, dumb it down a bit, use #includes where needed, and please, please, use comments. A download for a full VC6 project covering this material wouldn't hurt either. Appreciate it peoples ... Happy Codin' ...
-digitalmythology -dm
|
|
|
|
|
digitalmythology wrote: or should I say .NOT working
Actually, .NET would deal with your memory leaks, eventually.
digitalmythology wrote: CInvenStoryDlg *dlg = new CInvenStoryDlg (/*... construction args ... */);dlg->Create(IDD_DIALOG_NEWITEM, this);dlg->ShowWindow(SW_SHOW);
A modeless dialog needs to be a member variable. Otherwise, you've thrown a pointer to the wind, and have no way to do anything with it from there on in.
digitalmythology wrote: (stream = fopen("filename.txt","wb")
You should use C++ to handle files, C is nasty.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|