|
rupert_durans wrote: he made a structure of the class and pass it on to the thread so that the member viriable can be used by the thread
What do you mean by making a structure of the class ? Why not simply pass the address of the class instance (the this pointer) to the thread ?
|
|
|
|
|
yup,
i asked him again and you are right, you may or may not create struct as long as it points to the class instance.
i need to learn more... i want to be like you guys... i'm just a begginer
|
|
|
|
|
Ok but why do you want to do such a thing ? What is the advantage of wrapping your class into a structure just to pass it to your thread ? Pass it directly, it's much cleaner. Why adding complexity where this is not required ?
|
|
|
|
|
hehehe, soweee, i'm just a newbie, i just saw it on my friend's code...
now i know that it can be direct,
can you please give me example on how to declare a pointer to the class instance?
i need to learn more... i want to be like you guys... i'm just a begginer
|
|
|
|
|
rupert_durans wrote: can you please give me example on how to declare a pointer to the class instance
You don't really 'create a pointer to the class instance'. What you have in fact is an instance of your class:
CMyClass Inst;
Here, Inst is an instance of CMyClass. The address of this class is obtained with the & operator:
CMyClass* pPointer = &Inst;
If you pass this address as a parameter to your thread function, you'll be able to access its member:
void MyThreadFunc(LPVOID pParam)
{
CMyClass* pClass = (CMyClass*)pParam;
pClass->MemberFun();
}
You can also start your thread inside a member function of your class, then simply pass the this parameter:
void CMyClass:SomeFunction()
{
_beginthread(MyThreadFun,0,this);
}
|
|
|
|
|
thank you
i need to learn more... i want to be like you guys... i'm just a begginer
|
|
|
|
|
Cedric Moonen wrote: You don't really 'create a pointer to the class instance'. What you have in fact is an instance of your class:
CMyClass Inst;
Here, Inst is an instance of CMyClass. The address of this class is obtained with the & operator:
CMyClass* pPointer = &Inst;
Hi Cédric,
Isn't "Inst" an instance of the class and "pPointer" a pointer to an instance of the class?
Mark
|
|
|
|
|
is it like this one for example?
CMyFileSpyDlg* _this;
i need to learn more... i want to be like you guys... i'm just a begginer
|
|
|
|
|
can you also answer my question above?
HOw to pause a spawned process?
i need to learn more... i want to be like you guys... i'm just a begginer
|
|
|
|
|
Hi ,
I want to force my Edit box to get unicode characters.
Because I am using Arabic/Persian characters and I want to get codes
from EditBoxes and It is diffrent to get Ascii or unicode.
please help me.
thanks.
Every new thing you learn,Gives you a new personality.
|
|
|
|
|
compile your app with UNICODE,_UNICODE preprocessor definitions
Greets,
Davy
|
|
|
|
|
dSolariuM wrote: Because I am using Arabic/Persian characters and I want to get codes
from EditBoxes and It is diffrent to get Ascii or unicode.
make you project unicode enabled, you can change it in Project properties or using _UNICODE macro in stdafx
"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
|
|
|
|
|
Hi, everyone
We occurs a problem that our pogram occupies a very high CPU Usage even if with no any operation on it.
And we really want to know what leads to the HIGH CPU USAGE? I have searched a lot of topic about this. But...
I just consider the large amount of user objects occupies the CPU. But if the large amount of user objects will cause the high CPU Usage?
(NOTE:Our project has a large amount of user object of 8597.)
THANKS.
//////////////////////////////
|
|
|
|
|
willbin wrote: And we really want to know what leads to the HIGH CPU USAGE?
When your code does stuff, that's all.
willbin wrote: I just consider the large amount of user objects occupies the CPU.
No - why would it ? They occupy memory. The CPU is occupied if stuff is being done, not if stuff is in memory.
Does your project have many threads ? If not, then something must be seriously wrong if your CPU maxes out when you're not doing anything. Otherwise, you have active threads, you need to work out why and if you can change that.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Christian Graus wrote: Otherwise, you have active threads
yes.There is a timer event in the project. I removed the timer, the CPU Usage is reduced.
THANKS Christian.
//////////////////////////////
|
|
|
|
|
Hi all,
Anyone experienced with MS RTC Client API?
I came accross the following issue:
Developed a server APP where each client is initialized with InitializeEx(RTCIF_DISABLE_MEDIA). Then I connect with office communicator using account A on the same backend LCS instance.
When I send a message from A (office communicator) to any account B connected with my APP, office comm complains "The following message could not be sent...".
MSDN says I sould answer to incoming sessions of type APPLICATION with pSession->AnswerWithSessionDescription();
I used code like this:
<br />
HRESULT OnRTCSessionStateChangeEvent(IRTCSessionStateChangeEvent2* pEvent)<br />
{<br />
RTC_SESSION_TYPE enType;<br />
RTC_SESSION_STATE enState;<br />
<br />
IRTCSession2* pSession;<br />
pEvent->get_Session(&pSession);<br />
<br />
pSession->get_State(&enState);<br />
pSession->get_Type(&enType);<br />
<br />
if (enType == RTCST_APPLICATION && enState == RTCSS_INCOMING)<br />
{<br />
BSTR type, desc;<br />
pSession->GetRemoteSessionDescription(&type,&desc);<br />
pSession->AnswerWithSessionDescription(type,desc);<br />
SysFreeString(type);<br />
SysFreeString(desc);<br />
}<br />
if (enState == RTCSS_CONNECTED)<br />
{<br />
}<br />
else<br />
{<br />
pSession->Release();<br />
}<br />
}<br />
Some more thoughts:
1) With the above code I cannot use pSession->SendMessage(NULL, myMsg, 0). It fails with error code INVALID SESSION STATE. I am interested only in IM kind of communication, not in media exchange
2) How can I detect more info about an incoming session. The desc variable above only contains some SDP data, nothing about who (WHAT APPLICATION) originated the request
Any help wpuld be appreciated. Thanks
Cristi
Discover beauty in whatever you're doing
|
|
|
|
|
I have an application displaying an activex component which is in vc++. The component contains some tooltips which need to be printed. The tooltips are created using the CWindow class which takes in the class name in the ctor as TOOLTIPS_CLASS. Is it possible to print the tooltips?
|
|
|
|
|
|
Hi,
how to identify dbf version dbase II,dbase III,dbase IV. before open the database using CDaoDatabase member Open(). Any one help me out.
Thanks In Advance!
Have A Nice Day!
Murali.M
|
|
|
|
|
Here's a description for what the dBASE II file format looks like: http://www.clicketyclick.dk/databases/xbase/format/db2_dbf.html#DBII[^]
The first field in the header is the version field. For dBASE II it's apparently a 2. I'm willing to bet money that the field is 3 for dBASE III, and 4 for dBASE IV. You can always verify this by examining files you have.
Basically, all you have to do is to read the first byte of the file, and inspect its value!
--
Verletzen zerfetzen zersetzen zerstören
Doch es darf nicht mir gehören
Ich muss zerstören
|
|
|
|
|
Dear All,
I am working with Registry entries. i am calling this fn RegEnumValue inside while loop until it retuns ERROR_NO_MORE_ITEMS. Index value is incermented in each iteration. still ..
here the function RegEnumValue is returning the same valuename record again and again.
Help me that how to read all valuename records?
thanks.
|
|
|
|
|
Can you post code, what you have tried?
|
|
|
|
|
Here it is .,
do{
Err=RegEnumValue(Root1,Cnt++,ValName,&nCnt,NULL,NULL,Buffer,&BufferSize);
if(MemberVariable==ValName){
RegSetValueEx(Root1,ValName,0,REG_SZ,(BYTE*)&MemberValue,MemberValue.GetLength());
}
nCnt=10;
}while(Err!=ERROR_NO_MORE_ITEMS);
|
|
|
|
|
Sakthiu wrote: Err=RegEnumValue(Root1,Cnt++,ValName,&nCnt,NULL,NULL,Buffer,&BufferSize);
modify it to,
Err=RegEnumValue(Root1,Cnt,ValName,&nCnt,NULL,NULL,Buffer,&BufferSize);
Cnt++;
|
|
|
|
|
I would advise you to use two loops. MSDN states that the registry should not be modified while enumerating values. Although your code works now, microsoft may release a patch/update that will prevent it from working later.
Use the first loop to build an array of the keys to be modified, and use the second loop to go through this array updating your values.
|
|
|
|