|
whats stopping you ? you dont expect US to write it for you do you ?
There's plenty of examples here and on google that deal with such things - how about you do some research, play with some code, and come back and ask specific questions
oh, and please read the note at the top of the forum - this one :- http://www.codeproject.com/script/Forums/View.aspx?fid=1647&msg=2371639[^]
Your question also 'smells like' homework - we dont do people's homework for them - most of us got where we are by solid work and application, not by cheating, so we tend to look a bit disdainfully on this sort of thing - we will help you learn, but you have to do some research and apply yourself a bit first.
'G'
|
|
|
|
|
hi everyone...
am having a system tray icon.
if i right click the icon i have to get four option.
1.about
2.minimise
3.maximise
4.exit
upto here is over...
now the problem is if i clicked minimise that should be unvisible... like if i click maximise that should be unvisible...
can help anyone?
please tell somewhat brief... because am the beginner...
thanks in advance...
|
|
|
|
|
You can use ShowWindow with SW_HIDE and SW_SHOW
|
|
|
|
|
Hi all,
I have a template function inside a class a shown below. But while compiling I am getting an error "error C2893: Failed to specialize function template 'void __thiscall Test::someFunction(T)' With the following template arguments: 'int' ". Anybody knows whats wrong with the code?
class Test<br />
{<br />
public:<br />
template<class T> void someFunction( T obj );<br />
};<br />
<br />
template<class T> void Test::someFunction( T obj )<br />
{<br />
<br />
}<br />
<br />
int main(int argc, char* argv[])<br />
{ <br />
int n = 0;<br />
Test obj;<br />
obj.someFunction( n );
return 0;<br />
}
Also if I wrote the implementation of the template function inside the class itself, then there is no error. Like..
class Test<br />
{<br />
public:<br />
template<class T> void someFunction( T obj )
{<br />
<br />
}<br />
};
|
|
|
|
|
It should be:
template <class T>
class Test
{
void function(T);
};
Maxwell Chen
modified on Friday, December 28, 2007 4:42:31 AM
|
|
|
|
|
No no thats not possible. I only need to call the function with different types.
I think the problem is with the vc6. In vc8, it is working fine.
|
|
|
|
|
Naveen,
It's a bug of Microsoft Visual C++ (6.0) compiler. There's no workaround available.
They have corrected it in the newer versions.
Please check KB article[^]
-Sarath.
"Great hopes make everything great possible" - Benjamin Franklin
|
|
|
|
|
Oh I misunderstood your question. Sorry!
Maxwell Chen
|
|
|
|
|
Hi Naveen ,
You are right the code given by you is working on VC7 and onwards
But if you want to make it possible on VC6 then please refere the code given below and make the changes accordingly. Hope this will help you.
template<class T><br />
class Test<br />
{<br />
public:<br />
void someFunction( T obj );<br />
};<br />
<br />
template<class T> <br />
void Test<T>::someFunction( T obj )<br />
{<br />
<br />
}<br />
<br />
int main(int argc, char* argv[])<br />
{ <br />
int n = 0;<br />
Test<int> obj;<br />
obj.someFunction( n );
return 0;<br />
}
The secret of life is not enjoyment
but education through experience.
- Swami Vivekananda.
|
|
|
|
|
Hi Mahesh ,
The problem with your sugeestion is that, I cannot call the obj.someFunction() with both int and long at the same time like..
int n = 0;<br />
long l = 0;<br />
obj.someFunction( n ); <br />
obj.someFunction( l );
|
|
|
|
|
I think that Naveen wants (member) function templates of a class, not class templates .
If it is a class template, the argument type is fixed when the class object is declared. So we can not invoke member functions with different input types (something like function overloading).
Maxwell Chen
|
|
|
|
|
HI Naveen and MaxWell
I am really sorry ..It was my misunderstanding.
later I worked for wht Naveen exactly want, on VC6
But it was not working then i googled,
I found the Following link
http://forums.devx.com/archive/index.php/t-82949.html[^]
The secret of life is not enjoyment
but education through experience.
- Swami Vivekananda.
|
|
|
|
|
To tell the truth, I have been 7 years not coding template stuffs.
I just tried hard to recall everything about templates (both member function template and class template), and tried with VC++2008. It works well finally.
Maxwell Chen
|
|
|
|
|
How to resize bitmap which in CStatic
<code>
CStatic* myStatic;
myStatic = new CStatic();
myStatic->Create(_T("my static"), WS_CHILD|WS_VISIBLE|SS_BITMAP|SS_CENTERIMAGE, CRect(50,80, 150, 150), this);
myStatic->SetBitmap(LoadBitmap(AfxGetApp()->m_hInstance,MAKEINTRESOURCE(IDB_BITMAP_default)));
</code>
these code set bitmap in CStatic control, but the picture is not whole displaied, because its area more than CRect(50,80, 150, 150),
how to resize the bitmap area that to dispaly full onto the CStatic control?
thanks!
|
|
|
|
|
This control[^] does all the dirty work.
This article[^] shows what you can do with the static control. Not settng the SS_CENTERIMAGE or SS_REALSIZEIMAGE style supposedly makes the image fit the static control.
Note that the actual size of the static control in pixels, and even its aspect ratio depends on the dialog font, so it may be different when moving to another PC.
|
|
|
|
|
|
I define a class CArray2D,inside it I imeplement a "proxy" class CArray1D, so that if I create a object of CArray2D like CArray2D array(2,3), I can output the its element like cout<<array[0][0].
But when I run it, I met with serials of strange questions like error address.
Can anyone tell me why?
Many thanks
The code is as follows
class CArray2D
{
public:
void Print()
{
CArray1D *pHead = pArray1D;
for(int i=0; i<size2D; i++)
{
cout<<"[ "<<i<<" }";
pHead->Print1D();
pHead = pHead+i*sizeof(CArray1D);
cout<<endl;
}
}
CArray2D(int n2DWidth, int n1DWidth):size2D(n2DWidth)
{
pArray1D = new CArray1D[size2D];
};
~CArray2D()
{
delete[] pArray1D;
};
class CArray1D
{
public:
CArray1D(int n1DWidth=3):size1D(n1DWidth)
{
pArray = new int[size1D];
for(int i=0; i<size1D; i++)
{
*(pArray+i*sizeof(int)) = 0;
}
};
~CArray1D()
{
delete[] pArray;
};
const int& operator[](int nIndex) const
{
return *(pArray+nIndex*sizeof(int));
}
int& operator[](int nIndex)
{
return *(pArray+nIndex*sizeof(int));
}
void Print1D()
{
for(int i=0; i<size1D; i++)
{
cout<<"["<<i<<"]="<<*(pArray+i*sizeof(int))<<" ";
}
}
private:
int size1D;
int *pArray;
};
const CArray1D& operator[](int nIndex) const
{
return *(pArray1D+nIndex*sizeof(CArray1D));
};
CArray1D& operator[](int nIndex)
{
return *(pArray1D+nIndex*sizeof(CArray1D));
};
public:
int size2D;
CArray1D *pArray1D;
};
int main()
{
CArray2D array(2,3);
array.Print();
array[0][0] = 3;
array.Print();
cout<<array[0][0]<<endl;
return 0;
}
}
Tomorrow is another day
|
|
|
|
|
Hi,
I'm doing a CPU-intensive program right now (C++ WinAPI, no MFC but I could use it if I had to) that uses some graphics, frequently calling a FillRect function to clear its back-buffered HDC to white. Is there a more efficient way to do this? Maybe by using bitwise operators somehow?
Thanks!
KR
|
|
|
|
|
You could use a DIB section for the back buffer's bitmap and write the
bits directly to memory in a loop.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Ok I'll try that, thanks!
KR
|
|
|
|
|
Using BitBlt API with WHITENESS isn't better?
|
|
|
|
|
BitBlt with WHITENESS seems to be the fastest way to do it that I've tried. I guess I might be able to get it a little faster using a straight memcpy but I think BitBlt basically is a memcpy already so I doubt it'll help much.
KR
|
|
|
|
|
Through BitBlt we can avoid the risk of bugs, since we dont need to handle the DC bitmap directly.
|
|
|
|
|
RECT r = {...};
SetBkColor(dc, your_white);
ExtTextOut(dc, r.left, r.top, ETO_OPAQUE, &r, NULL, 0, NULL);
[EDIT]
Not saying it's faster, just another way.
At one point i believe it was the prefered way (don't recall why).
[/EDIT]
...cmk
The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying.
- John Carmack
|
|
|
|
|
That way seems to be faster than FillRect, but copying directly to memory with BitBlt is slightly faster. Thanks!
KR
|
|
|
|