|
When you put it as a member in the header file, it gets instantiated as soon as the class is instantiated. You don't need to reference it to cause it to be called.
Therefore, you need to call the constructor in the header file, like so:
CArray<cstring,cstring> AA();
|
|
|
|
|
i tried but the same error, i also tried the initialization list but the same.
Ali Usam AlCherchefchi
|
|
|
|
|
"TYPE" needs to overload the '=' operator to work because when an item is added to the collection (CArray) a new instance of "TYPE" is created and the 'source' is copied into the new instance.
So for this to work you need to create a new class and overload the '=' operator to copy all data members.
BTW why don't you use CStringArray?
|
|
|
|
|
you mean to drive a class from "TYPE" and overload the '=' operator?? the CString already have one, or you mean to drive from the CArray and overload the '='??? i think this will work but not necessary, if the code will use the '=' operator each time i add an item this will be a big performance problem as the array may be long, 1000 or 10000, not sure yet.
now i think the problem is the class could not construct the array, but adding it in the constructor did not help!!!!
Ali Usam AlCherchefchi
|
|
|
|
|
No I don't mean that.
The error message you get is related to the '=' operator. Probably the class you declare the CArray in already has one? Or at least you are using '=' somewhere in your code for an instance of that class. You need to copy the AA member in the '=' operator definition yourself. E.g. AA.Copy( source.AA ); the CArray template does not have an '=' operator.
|
|
|
|
|
hiiii
thank you all for the help, now it is working really great.
but let me make things clear so if someone had the same problem can see where the error, cause the message you get from the compiler is not even close from the problem.
let say you have a class:
class BB
{
public
BB();
virtual ~BB();
CArray<cstring> AA; // or even a CAtringArray
BB &operator=(const BB &otherBB) // without this operator you cant add a CArray or CStringArray
}
Snorri wrote: Probably the class you declare the CArray in already has one? Or at least you are using '=' somewhere in your code for an instance of that class
when i read that i new the problem, it is in my class, see no class has no operator'=' (that if you used it in the program), so if you dont define one, the compiler will, and it will do it by calling each member's '=' operator, and if the operator is not existed then it stops and gives an error, evry one knows that but the error explanation dont even mentions it, and when i searched i didnot find an answer, so one can be drifted away. thanks all again
regards
Ali Usam AlCherchefchi
|
|
|
|
|
Hi everyone
I want to learn programming about process but my search was not successful on the net because they are on the Java of course codeproject has some articles about process and threads but I want to learn it of basis so do you know any good book or source?
Thanks
|
|
|
|
|
|
|
hi every one
i have one ocx that build it in mfc6.
i useed it in all Developers at 32 bits windows.
but when i drag control on the form in x64, crash the application.
i rebuile it in x64 and test it again but it didnt work.
pls help me.
how i can create x64 support ocx in visual c++ 6?
|
|
|
|
|
Did you set MachineX64 (/MACHINE:X64) and other parameters for your project?
|
|
|
|
|
Hi
Try setting a ocx project in VC9 for x86 and then see which options it sets for it.
maybe it helps
Goodluck
www.logicsims.ir
|
|
|
|
|
Hi my dear master
i will test it
with special thanks
Goodluck & Goodbye
modified on Sunday, December 7, 2008 2:12 AM
|
|
|
|
|
|
it's a chatting tool
and i use spy++ get the RichEdit20A handle from the dialog
but i can't use the handle to get the text
maybe it shields WM_GETTEXT msg
how can i get the text in another way??
|
|
|
|
|
Accessing data of another process isn't that simple...that's one of the main points of protected mode. What do you want to do that involves using spy++ and getting text from a control in another process?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
|
|
|
|
|
i want to carry out the auto reply function
so i have to get the chatting text from the dialog
and then analyse it and reply automatically
it's hard
i know
do more and you will learn more
thanks for reply
|
|
|
|
|
Most IM programs support plugins, maybe it would be easier to write one if the one you want to target there does so? Anyhows, docs say that WM_GETTEXT works over process boundaries for some controls, and for some it doesn't, so i guess for rich edit it doesn't work. You could try a trick but it's not too safe and reliable. You could allocate shared memory, lock it, post WM_GETTEXT to the control passing the address of the shared memory block, wait a while (sadly you can't really know if the rich edit control has processed that message yet or not) and then you should have the text in the memory block. However, this can lead to crashes and asynch problems. You could try for example filling the buffer with 1s, and then after you sent the message keep checking for a 0 character, assuming that you have allocated a big enough buffer, when the 0 is there then the rich edit has probably finished copying its text into the buffer (since 0 should be the last character of the text and we assume it is copying the text from its start to its end). Combining that with maybe some timeouting...
Or on a different aproach, you could inject a DLL into the process that hooks itself to the rich edit control and could for example when the control gets WM_SETTEXT copy the text into some shared buffer and notify your process of the change.
This all is just ideas, don't know if any of it could ever work.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
|
|
|
|
|
Thanks for your advise
I'll have a try
|
|
|
|
|
Here, if i wanna modify a register key which need administrator priority, how to do it?
if use normal function RegOpenKeyEx and RegSetValueEx with a KEY_ALL_ACCESS will get a error that the access is denied.
Any ideas?
Regards.
|
|
|
|
|
Did you try using AdjustTokenPrivileges[^] to enable SE_TAKE_OWNERSHIP_NAME privilege and then open the registry key with WRITE_OWNER access?
Best Wishes,
-David Delaune
|
|
|
|
|
oh, im haven't yet. In fact, i know little about the security privileges of windows internals.
And, would you like to give me a flow of resolve such task using AdjustTokenPrivilege function?
|
|
|
|
|
Well, your making me lose my beauty sleep. And believe me I need it. Perhaps you should read this:
Enabling and Disabling Privileges in C++[^]
Just copy and paste that Microsoft example code into your project. You would use it like this:
BOOL GetYourPermission()
{
HANDLE token = 0;
if(TRUE == OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &token))
{
return SetPrivilege(token, SE_TAKE_OWNERSHIP_NAME, TRUE);
}
return FALSE;
}
Btw, I hope your logged in under the Administrator account.
Best Wishes,
-David Delaune
|
|
|
|
|
Thanks. I will have a try.
|
|
|
|
|
I have tried like following code:
int ret = GetYourPrivilege();
HKEY key;
DWORD err = RegCreateKeyEx(HKEY_LOCAL_MACHINE,_T("SYSTEM\\CurrentControlSet\\Enum\\Root\\MYKEY"),
0,NULL,0,KEY_ALL_ACCESS,NULL,&key,NULL);
it still get failed with an error code:ERROR_ACCESS_DENIED
what's wrong? I do logined with admin account.
|
|
|
|