|
It's a good idea...
I want a perfect way... not a easy
|
|
|
|
|
Anyway glad if I could help. It would be great to see final result when you do it. If you have time please send me an e-mail with brief description of yours solution!
Hope to hear from you.
Bye
|
|
|
|
|
Hello everyone,
I searched all of my VC folder files, but can not find where and how _ATL_SIMPLEMAPENTRY is defined. Any ideas?
thanks in advance,
George
|
|
|
|
|
atlbase.h
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Thanks CPallini,
Windows native search tool does not work this time.
For this statement,
#define _ATL_SIMPLEMAPENTRY ((ATL::_ATL_CREATORARGFUNC*)1)
I think it means a function pointer of type CREATORARGFUNC is located address 0x00000001?
I think ((ATL::_ATL_CREATORARGFUNC)1) should be enough, since _ATL_CREATORARGFUNC itself is defined to function pointer type. Why add an additional * here?
regards,
George
|
|
|
|
|
George_George wrote: I think ((ATL::_ATL_CREATORARGFUNC)1) should be enough, since _ATL_CREATORARGFUNC itself is defined to function pointer type. Why add an additional * here
pointer to pointer
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You/codeProject$$>
|
|
|
|
|
Thanks ThatsAlok,
From the ATL definition, _ATL_CREATORARGFUNC is a function type, other than function poniter type, right?
typedef HRESULT (WINAPI _ATL_CREATORARGFUNC)(void* pv, REFIID riid,
LPVOID* ppv, DWORD_PTR dw);
I can not think why it defines a function type, other than function pointer type. To use the function type variable, we always need to use the function pointer form of it, right? So, why not just define a function pointer type? Could we use function type directly?
regards,
George
|
|
|
|
|
The above is typedef , i.e. an alias for a type representing a function having the given prototype. Nothing to do with pointers.
To make things a bit clearer:
typedef int (MYFUN) (int x);
int square(int x) {return x*x;}
void main()
{
MYFUN p = square;
MYFUN *p = square;
}
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Thanks CPallini,
I have tried your sample, and it is correct. I found when we define a function type, we always use its pointer form/type (e.g. in your sample, using type MYFUNC*, other than type MYFUNC*).
So, why not use function pointer type other than function type directly?
regards,
George
|
|
|
|
|
George_George wrote: I have tried your sample, and it is correct. I found when we define a function type, we always use its pointer form/type (e.g. in your sample, using type MYFUNC*, other than type MYFUNC*).
This is up to you (i.e. the designer).
Usually Ms code specifies when a the typedef relates to a pointer (e.g. PTHREAD_START_ROUTINE).
George_George wrote: So, why not use function pointer type other than function type directly?
Ask ATL development team. Ms has a lot of different teams, each one with his 'little standard' inside company general guidelines, I suppose.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Thanks CPallini,
Can you show me a sample of how to use function type directly, other than define a function type, but using pointer to function type please?
I can not imagine a case.
regards,
George
|
|
|
|
|
George_George wrote: how to use function type directly, other than define a function type, but using pointer to function type
How to unroll you sentence?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Thanks CPallini,
What I mean is, suppose you define a function type tfunc, you always use type tfunc*, right? For example, in your sample code.
Could you show me how to use tfunc directly, other than using tfunc* type? Please.
regards,
George
|
|
|
|
|
class MyFunObject
{
MYFUN * fun;
public:
MyFunObject(MYFUN f){fun = &f;}
int Invoke( int i ){ return (*fun)(i);}
};
int main()
{
MyFunObject mfo(square);
printf("%d\n",mfo.Invoke(4));
getchar();
return 0;
}
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Thanks
You still use the pointer type when making the final call.
return (*fun)(i);}
where fun is a type of pointer,
MYFUN * fun;
So, I think there is no case to use function type directly, without using its pointer type form.
regards,
George
|
|
|
|
|
Sometimes code don't need to directly execute functions to be useful, IMyFunContainer , for instance, specializes the IMyContainer interface to MYFUN type.
typedef int (MYFUN) (int x);
template <class T>
class IMyContainer
{
public:
virtual int add(T t)=0;
virtual void remove(T t)=0;
};
class IMyFunContainer : public IMyContainer <MYFUN>
{
virtual int Invoke(int iIndex, int arg)=0;
};
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Thanks CPallini,
But to use the function in the container, we have to use T* or MYFUN* type, other than T or MYFUNC, right?
regards,
George
|
|
|
|
|
Yes.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Thanks CPallini,
Question answered.
regards,
George
|
|
|
|
|
Nope. simply pointer to function, since George hypothesys about _ATL_CREATORARGFUNC nature was wrong.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
I have a CString object and I want to know if it ends with a \ (backslash)
But I can't write if (csText == "\") because the "\" gives an error...
|
|
|
|
|
I thing the best method to identify the last character in CString is:
if(csText.Right(1)=="\\") dosomething();
Please note the double \ between " because \ is so called escape character.
|
|
|
|
|
you are using escape character. To compare backslash you have to add extra backslash(\\).
so try this...
if (csText == "\\")
Mukesh Kumar
Software Engineer
|
|
|
|
|
Well, while you do need to escape the backslash by using \\ instead of \ , your test checks the entire string, not the end of the string.
You can use a variety of methods to test the last character of the string - operator[] , ReverseFind(...) , etc.
int iLength = csText.GetLength();
if( iLength != 0 )
{
if( csText[ iLength - 1 ] == '\\' )
{
}
} Peace!
-=- James Please rate this message - let me know if I helped or not!<hr></hr> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
Since you have a CString, you could use the ReverseFind method:
if(csText.ReverseFind(_T("\\") == csText.GetLength() - 1) This checks to see if the 0-based index of the \ character is the last character.
Hope that helps.
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|