|
I created an application that contains a dialog box and a menu. This dialog box contains a tab control with two tabs. Each tab contains a dialog box. How can I associate the menu with the dialog boxes on the tab control?
Thanks
Trevy
|
|
|
|
|
Trevy wrote: How can I associate the menu with the dialog boxes on the tab control?
Only Popup windows can have menus.
AFAIK if it's on a tab control then it's not a popup window.
|
|
|
|
|
I have a class A and it has x,y and z integer attributes
I have created a list sequence container which has a type A
list<a*> alist
I want to sort the elements in this list according to y value. How can i do that?
alist.sort() only sorts the elements according to the first attribute defined in the constructor.
|
|
|
|
|
You have a number of options. The first is to define an operator < for your class:
bool operator<(const A &lhs, const A &rhs)
{
return lhs.y < rhs.y;
}
You would make it a friend of class A if it needs access to private members of the class.
Another option is to define a predicate function and pass it to the std::list<...>::sort function. This option would enable you to have multiple sort orders. Example:
class A
{
public:
static bool SortByYPred(const A &lhs, const A &rhs)
{
return lhs.y < rhs.y;
}
};
Now call std::list<...>::sort like this:
alist.sort(&A::SortByYPred);
mehmetned wrote: alist.sort() only sorts the elements according to the first attribute defined in the constructor.
The constructor has nothing to do with sort order.
Steve
|
|
|
|
|
How do we convert from base class object to sub class object in c++?
|
|
|
|
|
A cast will do the trick (pBase is a pointer to the base class).
The fastest way if you're sure it's safe:
static_cast<Dervied*>(pBase);
The safest way (runtime checked):
dynamic_cast<Dervied*>(pBase);
You could use Boost's polymorphic_downcast[^] for a solution that uses dynamic_cast in debug builds and static_cast in release builds.
Steve
|
|
|
|
|
Hi
I Have a MFC dll .. that will be called.. by another progam written in PASCAL,
my dll has a function that has tu return a bitmap, or a pointer to an byte array or something of the bitmap
I Hva e a BITMAPINFO and a BITMAPFILEHEADER i need to put those in a memory buffer and return it.. so if the guy to which i return it wants to dump it to a file.. to be a wealthy .bmp file
cand anyone show how to do it please??
|
|
|
|
|
CFile file;<br />
<br />
if( !file.Open( _T("C:\\Temp.bmp"), CFile::modeWrite|CFile::modeCreate) )<br />
return bRet;<br />
<br />
BITMAPFILEHEADER hdr;
LPBITMAPINFOHEADER lpbi;
<br />
<br />
int nColors = 1 << lpbi->biBitCount;<br />
<br />
hdr.bfType = ((WORD) ('M' << 8) | 'B');
hdr.bfSize = GlobalSize (hDIB) + sizeof( hdr );<br />
hdr.bfReserved1 = 0;<br />
hdr.bfReserved2 = 0;<br />
hdr.bfOffBits = (DWORD) (sizeof( hdr ) + lpbi->biSize +<br />
nColors * sizeof(RGBQUAD));<br />
<br />
file.Write( &hdr, sizeof(hdr) );<br />
<br />
file.Write( lpbi, GlobalSize(hDIB) );<br />
<br />
file.Close();
|
|
|
|
|
thanks for repley
but i dont wanna write it down to a hard drive... i just wanna have it as a full .bmp file but in memory
you see i will proces 14 frames per sec.. so using the HDD will slow me down.. i need to compose those bitmap form the structures in memory , i mean put it in a buffer or something
|
|
|
|
|
so instead of writing it to hard drive, pass the buffer (pointer) to the recipient.
|
|
|
|
|
what buufer... u are using.,, File.Write method for writing header and then info
but i want to return a pointer to a buufer witch contains both header and info one after another..
where is the buffer of CFile??
|
|
|
|
|
hi,
i hav to implement a sliger for the GUI of my project in VC++
can u help me in its implementation plaese....
|
|
|
|
|
Have you seen this? Trackbar Control Reference[^]
"Great job, team. Head back to base for debriefing and cocktails."
(Spottswoode "Team America")
|
|
|
|
|
Use:
HWND hwndTrack = CreateWindowEx(..., TRACKBAR_CLASS, ...);
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Newbie question.
If an application has an SDK for C++, does it matter which version of VC++ I use to create an app using that SDK (as long as I am not using CLR in VS2005)? I am under the impression that it doesn't because it is still C++. On the other hand, I have heard there are some differences between the compilers, so I am not sure.
Thanks for your help with this simple (-minded) question
Brad
The secret to creativity is knowing how to hide your sources. - Albert Einstein
|
|
|
|
|
Yes it matters, to a point. The SDK may use features of C++ not available in earlier versions of VC++. In addition the link libraries have will have problems if not targeted to the version of C++ you are using. If the SDK ships with source code and make files, this isn't a big problem thought.
(I've had it go both ways; code from VC++ 2005 that chokes with VC++ 6.0 and 6.0/2003 code that chokes with 2005.)
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
BRShroyer wrote: On the other hand, I have heard there are some differences between the compilers, so I am not sure.
There are. VS2k5 is more stricter following c++ ISO standards. Which was biggest compain about VS6.0 . So you might find some code compiling. under previous version but not with VS2K5.
Refer this article by Stanley B. Lippman[^].
|
|
|
|
|
Hi there,
I am developing a map displaying system (similar to GPS) using GDI and unmanaged C++. I need to rotate the entire map (768x768) 12.5 times per second continuously. I am using SetWorldTransform() for rotation, but it seems to consume too much CPU (35-40% of dual 3.2GHz with 2GB RAM). Are there any other options that I can improve the performance?
Thanks.
Best,
Jun
|
|
|
|
|
Maybe the GDI it's not the best option. Have a look to DirectX or OpenGL.
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.
|
|
|
|
|
Hmmm - the following code using GDI+ in a window uses 3%-5% cpu on a dual Xeon 3.2GHz machine:
Gdiplus::Bitmap SrcBitmap(L"C:\\test768768.bmp", FALSE);
Graphics DstGraphics(*this);
REAL angle = 0.0f;
for (int i = 0; i < 125; ++i)
{
DstGraphics.ResetTransform();
DstGraphics.RotateTransform(angle);
DstGraphics.TranslateTransform(450.0f, 450.0f, MatrixOrderAppend);
DstGraphics.DrawImage(&SrcBitmap, -384, -384, SrcBitmap.GetWidth(), SrcBitmap.GetHeight());
angle += 10.0f;
if (angle >= 360.0f)
angle -= 360.0f;
::Sleep(70);
}
"Great job, team. Head back to base for debriefing and cocktails."
(Spottswoode "Team America")
|
|
|
|
|
Mark Salsbery wrote: dual Xeon 3.2GHz machine
Good hardware!
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 like it alot although the SATA bus sits unused
"Great job, team. Head back to base for debriefing and cocktails."
(Spottswoode "Team America")
|
|
|
|
|
Thanks for posting, Mark.
Yes, GDI+ would be a better alternative. My problem is that I have to use GDI, not GDI+. I am using a third-party API library to load special image formats. That libray was GDI-based. I thought about mixing GDI/GDI+, but hesitated to do so thus far.
Best,
Jun
|
|
|
|
|
Once the image is loaded, what format is it in?
Those CPU usage numbers seem a tad high for 12.5fps, even using straight GDI.
"Great job, team. Head back to base for debriefing and cocktails."
(Spottswoode "Team America")
|
|
|
|
|
As an example, even this totally un-optimized GDI code uses about 18% CPU (GDI+ only used to
load the bitmap - it's converted to a HBITMAP) ...
Gdiplus::Color clr(0xF0,0xF0,0xF0);
HBITMAP bmp;
if (Gdiplus::Ok == SrcBitmap.GetHBITMAP(clr, &bmp))
{
HDC hDestDC = ::GetDC(*this);
HDC hMemDC = ::CreateCompatibleDC(hDestDC);
::SetGraphicsMode(hDestDC, GM_ADVANCED);
HGDIOBJ hOldBitmap = ::SelectObject(hMemDC, (HGDIOBJ)bmp);
REAL angle = 0.0f;
for (int i = 0; i < 125; ++i)
{
static REAL pi = 3.1415926535f;
REAL angleradians = (angle * pi) / 180.0f;
REAL anglesin = ::sin(angleradians);
REAL anglecos = ::cos(angleradians);
XFORM XForm;
XForm.eM11 = anglecos;
XForm.eM12 = anglesin;
XForm.eM21 = -anglesin;
XForm.eM22 = anglecos;
XForm.eDx = 450.0f;
XForm.eDy = 450.0f;
::SetWorldTransform(hDestDC, &XForm);
::BitBlt(hDestDC, -384, -384, SrcBitmap.GetWidth(), SrcBitmap.GetHeight(), hMemDC, 0, 0, SRCCOPY);
angle += 5.0f;
if (angle >= 360.0f)
angle -= 360.0f;
::Sleep(20);
}
::SelectObject(hMemDC, hOldBitmap);
::DeleteDC(hMemDC);
::ReleaseDC(*this, hDestDC);
::DeleteObject((HGDIOBJ)bmp);
}
-- modified at 11:03 Thursday 8th March, 2007
"Great job, team. Head back to base for debriefing and cocktails."
(Spottswoode "Team America")
|
|
|
|