|
Dalfxxx wrote: Could you elaborate a bit on your comment:
"Assuming you've made your painting thread safe"?
I meant if you are calling your painting method(s) directly from multiple threads then any GDI
calls there need to be synchronized. A critical section works fine
If you're relying on WM_PAINT (which is the case if you use InvalidateRect() to mark the window
for repainting) then you should be ok. All of those messages will go through your UI thread.
Mark
"Great job, team. Head back to base for debriefing and cocktails."
(Spottswoode "Team America")
|
|
|
|
|
Hi, I got a question about Named pipe question on WIndows wondering anyone can help me.
I am doing some studies for Named Pipe and I want to try to make two processes on Windows talk to each othe. From MSDN I saw this example
http://msdn2.microsoft.com/en-us/library/aa365588.aspx
With minor changes I got it (server and client)working on XP using VS 2005 Express.
My questions are,
1. The named pipe is defined by :
LPTSTR lpszPipename = TEXT("\\\\.\\pipe\\mynamedpipe");
Since named pipe is part of the file system, how can I actually see the file. I think in UNIX, you can actually use "ls " to see the pipe file, can I do that in Windows?
2. I am new to this, but if named pipe is part of the file system, what happens if the server crashes? the file will still be left out there? worst, power failure?
Thanks for you help
|
|
|
|
|
mhp130 wrote: Since named pipe is part of the file system, how can I actually see the file. I think in UNIX, you can actually use "ls " to see the pipe file, can I do that in Windows?
I don't believe it's part of the file system. Named pipes are used for interprocess
communication. Thanks to "opaque" handles, the common ReadFilexx/WriteFilexx APIs can be used
for pipe communication (as well as sockets). Anyway, the name doesn't specify a file.
It's used to uniquely identify a pipe by combining a server/machine name with a unique name.
mhp130 wrote: what happens if the server crashes?
You'd probably get a broken pipe (or other) error on the next read/write operation.
I suppose if we were meant to see the data between endpoints they would have called them
perforated pipes
Mark
"Great job, team. Head back to base for debriefing and cocktails."
(Spottswoode "Team America")
|
|
|
|
|
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")
|
|
|
|