|
That's what the code does, reads the version resource from a binary (it doesn't have to be a DLL, you can pass the filename of your EXE). Just change the "ProductVersion" part in the VerQueryValue() call to the field you want to read.
--Mike--
Latest blog entry: *drool* (Alyson) [May 10]
Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber
"You have Erica on the brain" - Jon Sagara to me
|
|
|
|
|
Is this a valid check to see if a file has been opened?
ofstream NodeOrig;
NodeOrig.open("NodeOrig.txt", ios::out);
if ( !NodeOrig.is_open() )
throw "Could not open original node data file.\n";
|
|
|
|
|
If you are sure the target file path is correct and the file not corrupted, then Yes.
~RaGE();
|
|
|
|
|
Maybe this is a bit more robust?
ofstream NodeOrig;
NodeOrig.open("NodeOrig.txt", ios::out);
if ( NodeOrig.fail() )
throw "Could not open original node data file.\n";
or maybe I should be checking flags?
Eg:
if(FileStream.rdstate() == ios::eofbit)
cout << "End of file!\n";
if(FileStream.rdstate() == ios::badbit)
cout << "Fatal I/O error!\n";
if(FileStream.rdstate() == ios::failbit)
cout << "Non-fatal I/O error!\n";
if(FileStream.rdstate() == ios::goodbit)
cout << "No errors!\n";
|
|
|
|
|
Maybe just?
if(FileStream.fail())
{
throw ...
}
|
|
|
|
|
the problem is : where should i put the lines of drawing ? in OnPaint() only? what else should i do ?
i wish to draw the titlebar of one SDI program. but i met some problems.
here is how i do it as following:
i add lines in the CMainFrame::OnPaint() :
<br />
CFrameWnd::OnPaint();<br />
<br />
if (IsIconic()) return;<br />
<br />
RECT stRect1;<br />
<br />
::GetWindowRect(m_hWnd, &stRect1);<br />
<br />
CRgn m_rgn0;<br />
m_rgn0.CreateRectRgn(0,8,stRect1.right-stRect1.left,stRect1.bottom- stRect1.top);<br />
<br />
SetWindowRgn(m_rgn0,1);<br />
<br />
<br />
RECT stRect;<br />
<br />
CRect rect;<br />
<br />
<br />
CDC *pDC;<br />
pDC = GetWindowDC();<br />
<br />
<br />
<br />
<br />
::GetWindowRect(m_hWnd, &stRect);<br />
<br />
<br />
<br />
rect.SetRect(0,0,stRect.right - stRect.left,stRect.bottom - stRect.top);<br />
<br />
HDC hDC = ::GetWindowDC(m_hWnd);<br />
<br />
HPEN hPen;<br />
hPen = CreatePen(PS_INSIDEFRAME, 1* GetSystemMetrics(SM_CXBORDER), <br />
RGB(123, 200, 243));<br />
<br />
CPen pen;<br />
<br />
pen.CreatePen(PS_INSIDEFRAME, 1* GetSystemMetrics(SM_CXBORDER), <br />
RGB(123, 220, 233));<br />
<br />
<br />
pDC->SelectObject(&pen);<br />
<br />
<br />
<br />
<br />
<br />
HPEN hOldPen = (HPEN)SelectObject(hDC, hPen);<br />
HBRUSH hOldBrush = (HBRUSH)SelectObject(hDC, GetStockObject(NULL_BRUSH));<br />
<br />
stRect.bottom = stRect.bottom-stRect.top;<br />
stRect.right = stRect.right-stRect.left;<br />
<br />
int btm = stRect.bottom;<br />
<br />
CRgn m_rgn6,m_rgn5,m_rgn7;<br />
<br />
m_rgn6.CreateRectRgn(0,0,4,stRect.bottom);<br />
m_rgn5.CreateRectRgn(stRect.right -4,0,stRect.right,stRect.bottom);<br />
m_rgn7.CreateRectRgn(0,stRect.bottom-4,stRect.right,stRect.bottom);<br />
<br />
stRect.left = 0 ;<br />
stRect.top = 0 ;<br />
stRect.bottom = 29;<br />
<br />
<br />
<br />
m_rgn2.CreateRectRgn(stRect.left,stRect.top,stRect.right,stRect.bottom);<br />
<br />
m_rgn2.CombineRgn(&m_rgn2,&m_rgn,RGN_DIFF);<br />
m_rgn2.CombineRgn(&m_rgn2,&m_rgn6,RGN_OR);<br />
m_rgn2.CombineRgn(&m_rgn2,&m_rgn5,RGN_OR);<br />
m_rgn2.CombineRgn(&m_rgn2,&m_rgn7,RGN_OR);<br />
<br />
SelectClipRgn(hDC,HRGN(m_rgn2));<br />
<br />
<br />
CBrush brush;<br />
<br />
brush.CreateSolidBrush(RGB(255,255,255));<br />
<br />
<br />
<br />
<br />
FillRgn(hDC,HRGN(m_rgn2),HBRUSH(brush));<br />
<br />
brush.CreateStockObject(NULL_BRUSH);<br />
<br />
int i = 0;<br />
<br />
for (i; i < btm;i)<br />
{<br />
MoveToEx(hDC,0,i,NULL);<br />
LineTo(hDC,stRect.right,i); <br />
i += 2;<br />
}<br />
<br />
hPen = CreatePen(PS_INSIDEFRAME, 2* GetSystemMetrics(SM_CXBORDER), <br />
RGB(33, 120, 120));<br />
<br />
SelectObject(hDC, hPen);<br />
<br />
MoveToEx(hDC,2,28,NULL);<br />
LineTo(hDC,stRect.right-2,28);<br />
<br />
<br />
MoveToEx(hDC,3,28,NULL);<br />
LineTo(hDC,3,btm-3);<br />
<br />
MoveToEx(hDC,stRect.right-3,28,NULL);<br />
LineTo(hDC,stRect.right-3,btm-3);<br />
<br />
MoveToEx(hDC,3,btm-4,NULL);<br />
LineTo(hDC,stRect.right-3,btm-4);<br />
<br />
<br />
MoveToEx(hDC,0,0,NULL);<br />
LineTo(hDC,0,btm);<br />
<br />
MoveToEx(hDC,stRect.right,0,NULL);<br />
LineTo(hDC,stRect.right,btm);<br />
<br />
<br />
::ReleaseDC(m_hWnd,hDC);<br />
<br />
SelectObject(hDC, hOldPen);<br />
SelectObject(hDC, hOldBrush);<br />
<br />
DeleteObject(hPen);<br />
DeleteObject(hDC);
it works well at most times, but when the window lost focus or reactiviate, it doesn't redraw. when u drag this window, it doesn't redraw after it moves from top-outside area back, either.
Jiang
|
|
|
|
|
|
Try also the invalidate in OnEraseBackground() only, this should catch the three previous cases.
~RaGE();
|
|
|
|
|
Try to Invalidate() your window titlebar rect in OnActivate() , OnKillFocus() and OnMoving()
~RaGE();
|
|
|
|
|
OnPaint() is used to paint the client area. The title bar is a non-client area. Look up (search) WM_NCPAINT or OnNcPaint(). You could also try searching for "owner drawn title bar" here or on the www.
Trust in the code Luke. Yea right!
|
|
|
|
|
I am designing a software to collect and organize web pages catched from internet and the drafts created user himself. In my first model, i store them in file system. But there are so many little gif/jpg that will waste disk space and not easy to manage. I hope there is a way to pack them into a single file or database.
The first thing into my mind is a zip file, but i dont know whether it is efficient enough for delete and insert frequently.
The second one is a ole docfile, it is said to be a file with directory structure inside. But i have very limit knowledge about it, hope somebody can tell me whether it is fit for my usage.
The third one is some object databases, i know zope is a good one, but it is build on python. Hope you can introduce some good c/c++ object database for me.
Thank you!
|
|
|
|
|
I know something about docfile. A DOCFile is literally a file-system inside a file. There's 2 classes to know about:
* IStorage -- acts like a directory
* IStream -- acts like a file.
(1) Create a DOCFILE with a method like: StgCreateDocfile(). This allocates your root IStorage object.
(2) Create an IStream for each file you want stored. Use IStorage::CreateStream().
if you want to create a directory within the file, then use IStorage::CreateStorage().
Make sure to call the Release() method on each object. Since this is COM, you cannot delete the objects you request. You must release() them and hope they clean themselves up.
DOCFILE's do not self compact themselves. To do compaction of the file, I think you have to just create a new docfile, and use IStorage::CopyTo to copy to the new one.
It's been about 5 years since I've done this, but I assume nothing here has changed.
-p
|
|
|
|
|
I have a problem mapping the WM_NCHITTEST message.
In my App I have derived a class from CStatic in order
to develop some specific functionalities (I also need
to know when the mouse is on my CStatic control and where
it is).
So I'd like to map WM_NCHITTEST message into my derived
class using the afx_msg UINT OnNcHitTest(CPoint point)
method.
I've associated an instance of my class to a CStatic control being part of the main window and using the Spy++
application I have seen that WM_NCHITTEST message is sent
to my control but OnNcHitTest method is not called !!!
Where is the problem ?
Thanks a lot !!!
|
|
|
|
|
You have to use SetCapture() first.
~RaGE();
|
|
|
|
|
But... if I use SetCapture all buttons in the main window
doesn't works !!! Is it true ? I've seen this...
|
|
|
|
|
Yes, that's true. I think you should better use afx_msg void OnNcMouseMove( UINT nHitTest, CPoint point ); and afx_msg void OnNcLButtonDown( UINT nHitTest, CPoint point ); which, as for them, do not require capture of the mouse.
~RaGE();
|
|
|
|
|
Hi All,
I'm having a bit of trouble adding derived objects of CObject to a CObArray object. I get the following error:
error C2243: 'type cast' : conversion from 'DoobyObj *__w64 ' to 'CObject *' exists, but is inaccessible
This is just a test for a later prject (hence the stupid class name). I need the DoobyObj class to inherit from CObject class so that I can serialize the CObArray object.
The error occurs on the Add line:
void SerObject::addDoobyObject(DoobyObj dO)
{
obaObjects.Add(&dO); //CObArray
resetIndex();
}
Here is the definition of DoobyObj:
class DoobyObj : CObject
{
public:
DECLARE_SERIAL( DoobyObj )
DoobyObj();
void Serialize(CArchive& archive );
CString dooby;
};
Can anyone solve my problem??
Thanks,
Donal
|
|
|
|
|
Are you compiling for 64-bit Windows, by any chance? I'm not sure MFC works with 64-bit Windows yet... It might, but that may be the reason
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
No, just windows 2K.
Do I need to setup some type of conversion method in my CObject derived calss?
|
|
|
|
|
Sorry for the delay. I haven't been able to access CP for almost two weeks
I should have picked up this before...
You are inheriting CObject as private, which implicitly makes any CObject methods private. This means that CArray can not access the implicit CObject* conversion because it is private.
Instead of
class DoobyObj : CObject
use
class DoobyObj : public CObject
This should fix the problem
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
Hello everybody,
I hope you can help me with my problem.
At this moment I am developping a project in DirectSound. I need to play a wave file. Because of future enhancements the wave file is played with DirectSound.
I use 3D buffers and the extended waveformat. All initialisation goes well, but when I try to lock the buffer the error DSERR_PRIOLEVELNEEDED is returned. I checked the SetCooperativeLevel function and that returns DS_OK.
The code I use for those two functions look like this:
<br />
MainhWnd = GetSafeHwnd();<br />
hr = m_pDS->SetCooperativeLevel(MainhWnd, DSSCL_NORMAL);<br />
<br />
....<br />
<br />
VOID* pbData = NULL;<br />
VOID* pbData2 = NULL;<br />
DWORD dwLength;<br />
DWORD dwLength2;<br />
int lPos=0;<br />
DWORD m_dwBufferBytes;<br />
<br />
hr= m_pDSBuffer->Lock(lPos, m_dwBufferBytes, &pbData, &dwLength, &pbData2, &dwLength2, 0);<br />
Does anyone know what the problem is, or how I can solve this.
Thanks in advance,
Miepmuts
|
|
|
|
|
Already tried with a higher level within SetCooperativeLevel ?
~RaGE();
|
|
|
|
|
Yes I tried to change the Cooperative Level to DSSCL_PRIORITY in combination with the SetFormat function. But that gives the same result, also another window handle doesn't change a thing.
|
|
|
|
|
I suppose DSBLOCK_ENTIREBUFFER is equal to 0, since you are giving 0 as last parameter of your function. If not, then this will attempt to lock a buffer which can have any size, since m_dwBufferBytes is not initialised, causing the lock to fail randomly.
~RaGE();
|
|
|
|
|
It's not a random error but every time the same one: DSERR_PRIOLEVELNEEDED
Even when I fill in those two variables the function returns the same error.
It is a very strange error. I asked someone at my work, and even he didn't see a solution.
|
|
|
|
|