|
I'm c# programmer and I'm familiar with declaring methods inside a class body. Now c++ says that I should put in the body just prototypes and declare methods somewhere else using :: scope operator.
My question is: what happen if I declare a method inside a class anyway? I read somewhere that it would make it 'inline', I mean the compiler would copy it everywhere it is called instead of putting actual 'call' command... What you c++ guys say on this?
Greetings - Gajatko
Portable.NET is part of DotGNU, a project to build a complete Free Software replacement for .NET - a system that truly belongs to the developers.
|
|
|
|
|
gajatko wrote: My question is: what happen if I declare a method inside a class anyway? I read somewhere that it would make it 'inline',
True.
gajatko wrote: ...the compiler would copy it everywhere it is called instead of putting actual 'call' command... What you c++ guys say on this?
You should only request inline for small functions. Even so, the compiler is free to ignore your request.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi,
i wanna assign a bitmap for a button. like in VB.
Could Some One tell how could i do that?
Thank you
"The Ultimate Limit Is Only Your Imagination."
|
|
|
|
|
You load your image with CImage class and then use of SetBitmap.
CImage m;
m.Load("C:\\1.jpg");
m_Button.SetBitmap(m_.detach());
|
|
|
|
|
should i change the CButon to CBitmapButon or it works even with the CButon Class ??
thank you
"The Ultimate Limit Is Only Your Imagination."
|
|
|
|
|
another thing.
it tells me that the CImage is not defined. or sth like that .
"The Ultimate Limit Is Only Your Imagination."
|
|
|
|
|
No you dont need to use of CBitmapButton you must set bitmap to true for button on the property window and for CImage did you include AtlImage.h on your project?
|
|
|
|
|
hai friends.
how to capture the enter key event of an edit control?
for example, user will type some data in the edit control and hits enter key.
then i have to do some validations and auto correct it.
iam able to get the enter event in the pretranslate message.
but i want the nid here.
though comparing pMsg->hwnd will do, it is not applicable for my dialog because, there are as many as 200 controls with me.
any ideas please?
thank you.
|
|
|
|
|
Hello Chandu,
You can identify whether the handle is that of an edit control by getting the class name. Please go throught the code below.
TCHAR strClassName[255];<br />
CString csEditBoxClassName( _T("Edit")); <br />
<br />
::GetClassName( pMsg->hwnd, strClassName, 255 );<br />
<br />
if( 0 == csEditBoxClassName.CompareNoCase( strClassName ))<br />
{<br />
}
I can give you one more hint. Since you have 200 controls, i guess you have created those controls dynamically by providing a range of control ids. If thats the case, you can use the resource id to identify whether its an edit control. For getting the resource id from handle,
UINT nResourceId = GetWindowLong( pMsg->hwnd, GWL_ID );
If you still have problems or if this is not what you needs, let me know.
Regards,
Jijo.
________________________________
Yesterday is history,
Tomorrow is a mystery,
But today is a present.
|
|
|
|
|
Somehow I have managed to create a bug that is driving me crazy!
I have a list of items that i show in a grid in a MDI window. The grid is drawn with MoveTo() LineTo() functions. When the list is empty only the grid lines are supposed to be shown with no data. But when the list(a collection in the Document) is empty the grid lines are not drawn. When I put a breakpoit in OnDraw() the grid drawing functions are called, but nothing shows up. Once I add an item to the list the grid lines are drawn all right. It seems to be something wrong with CDC* pDC, but I can't find out what. And I can't see why a poulated list or empty list should make a difference.
Haakon S.
|
|
|
|
|
Post the relevant code.
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.
|
|
|
|
|
void CTomhaxView::OnDraw(CDC* pDC)<br />
{<br />
pDC->MoveTo(100, 100);<br />
pDC->LineTo(200, 200);<br />
<br />
return;<br />
.<br />
.<br />
}
What can I say? This line is not drawn. When I put breakpoints the functions are called, OnPaint() is called, OnPrepareDC() is called, etc. Obviously, somewhere along the chain of funtions I have managed to interupt the setup process. Once I have added an item to my list, the above test line is drawn.
How can I check the pen that is used by the pDC?
Damn it 
|
|
|
|
|
Sorry, think I have found it. Seems I have missed a required call to CalcScroll(). Thanks anyway
Haakon S.
|
|
|
|
|
How to use TerminateThread() function in program.
iam used like this but the thread is not stopped.
<br />
CWinThread* m_pNuThread;<br />
void CThrdDlg::OnButton2() <br />
{<br />
CString string;<br />
m_NuStart.GetWindowText(string);<br />
<br />
<br />
<br />
if(string =="START")<br />
{ <br />
m_pNuThread = AfxBeginThread(NuThread, this);<br />
m_NuStart.SetWindowText("STOP");<br />
}<br />
else<br />
{ <br />
<br />
TerminateThread(m_pNuThread, 0);<br />
m_NuStart.SetWindowText("START");<br />
<br />
}<br />
<br />
<br />
}<br />
<br />
<br />
UINT NuThread(LPVOID lParam)<br />
{ <br />
CThrdDlg *dlg = (CThrdDlg*)lParam;<br />
CString str;<br />
for(int i=0;i<=100;i++)<br />
{<br />
str.Format("%d",i);<br />
dlg->m_NuEBox.SetWindowText(str);<br />
Sleep(200);<br />
if(i == 100)<br />
i=0;<br />
}<br />
return 0;<br />
}<br />
kp.Vuppala
|
|
|
|
|
krishna Vuppala wrote: How to use TerminateThread() function in program.
iam used like this but the thread is not stopped.
Thread is not stopped because you're doing a mistake on passing the first argument to TerminateThread function. It must be the thread HANDLE and not the pointer to che CWinThread class .
Hence you have to use:
TerminateThread(m_pNuThread->m_hThread, 0);
BTW: as stated by the documentation you should avoid to use TerminateThread (it must be only the last resort), there are other ways to stop smoothly a thread, for instance setting and (added) flag in your thread loop control condition, i.e.:
UINT NuThread(LPVOID lParam)
{
for(int i=0; i <= 100 && bKeepRunning;i++)
}
Hence you can simply set bKeepRunning=false outside the thread to gracefully stop it.
Hope that helps.
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.
|
|
|
|
|
Mr.CPallini sir ,
iam very Thankful to you..iam using 2 buttons in a Dailog with two threads.it works well.
now iam willing two generate two buttons with Single thread.is there any idea pls share with me sir...
kp.Vuppala
|
|
|
|
|
Sorry I really cannot understand your requirements, please explain better.
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.
|
|
|
|
|
I think I could decode his question.
Mr.CPallini sir ,
He has two buttons on the dialog and when he clicks each button it makes a thread they work very well now he wants that either buttons makes a single thread is it possible and if yes do you have any idea?
(what do you think it was a good decode;))
|
|
|
|
|
Hello everyone,
I am wondering what is the practical usage of unary_function? Could anyone list some practical benefits?
My question is, a class like
class Foo : public std::unary_function<class A, class B>
is always the same (could use similar implementation) to
template <class A, class B> class Foo
So we could always use the alternative approach to replace unary_function.
thanks in advance,
George
|
|
|
|
|
George_George wrote: I am wondering what is the practical usage of unary_function?
For istance, Microsoft has one [^].
George_George wrote: class Foo : public std::unary_function<class a,="" class="" b="">
is always the same (could use similar implementation) to
template <class a,="" class="" b=""> class Foo
No isn't the same. You must adhere to the interface while inheriting. (That's not the case of template <class A, class B> class Foo ).
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.
|
|
|
|
|
first, sorry my english is a little^^;
i type a cod about binary search.
first, i make Video class.
and i want video class to save some andy txt file.
this is my code.
i think ,
there is some problem at write method.
but i don't know why it is happened....
please give me your advice~
#include<iostream>
#include <string>
#include <fstream>
using namespace std;
class Video
{
private:
char *name;
int number;
public:
// ifstream fin;
// ofstream fout;
Video()
{
name = new char[30];
strcpy(name , "nothing");
number = 0;
}
Video(char *imsi_name, int imsi_number)
{
name = new char[strlen(imsi_name)+1];
strcpy(name, imsi_name);
number = imsi_number;
}
int Get_number()
{
return number;
}
char *Get_name()
{
return name;
}
void Set_number(int k)
{
number = k;
}
void Set_name(char *imsi)
{
delete[] name;
name = new char[strlen(imsi)+1];
strcpy(name, imsi);
}
};
void main()
{
Video *v[100];
Video *v4[10];
Video v3;
int i; //point index
ifstream fin;
ofstream fout;
fout.open("c:\\video3.txt", ios_base::out | ios_base::app | ios_base::binary);
fin.open("c:\\video3.txt", ios_base::in | ios_base::binary);
v[0] = new Video("kk1", 1200);
v[1] = new Video("kk2", 2200);
v[2] = new Video("kk3", 3200);
// cout << sizeof(Video) << endl;
// cout << sizeof(kk) << endl;
// cout << sizeof(kb) << endl;
//cout << v.Get_number() << " " << v.Get_name() << endl;
//cout << "size of v" << sizeof(v) << endl;
for(i = 0; i < 3; i++)
{
fout.write( (char*)v[i], sizeof(v3) );
i++;
}
fout.close();
// while(fin.read( (char*)&v3, sizeof(v3) ))
//
// {
// cout << v3.Get_name() << " : " << v3.Get_number() << endl;
//
// }
//cout << "size of v4: " << sizeof(v4[0]) << endl;
i = 0;
while(fin.read( (char*)v4[i], sizeof(v3) ) )
{
cout << v4[i]->Get_name() << " : " << v4[i]->Get_number() << endl;
i++;
}
}//main
Thank you!!
|
|
|
|
|
What do you want to do with write and what is happening instead?
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.
|
|
|
|
|
i put this value into video.txt file.
but those value can't be display and i think that value especially
*name don't save into video file.
how about complie with your computer?
sorry, my explanin is not good~
v[0] = new Video("kk1", 1200);
v[1] = new Video("kk2", 2200);
v[2] = new Video("kk3", 3200);
hi
i am from korea.
My english is a little.
anyway, nice to meet you~~
and give me your advice anytime~
|
|
|
|
|
You have to explicitely write the string inside the file. You can do it also with a method of your class.
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.
|
|
|
|
|
sorry, i can't understand what you mean...
May i request you to fix my source? or can you give me the method to fix?
thank you for taking care my question.
hi
i am from korea.
My english is a little.
anyway, nice to meet you~~
and give me your advice anytime~
|
|
|
|