|
Thank You!
This was just the help I needed to find the error! Which by the way was due to an attempt to do resizable windows and not understanding what I was doing I copied some code from CodeProject and now I can't find this article anymore. So maybe the author got the same error and revoked the article.
Anyway, thanks to your pointers I manage to make my application bug-free(.???.) AND resizable!
Mike Eriksson
Sonork 100.21825
|
|
|
|
|
Pleased to be able to help, and pleased to get your grateful reply.
Cheers!
The opinions expressed in this communication do not necessarily represent those of the author (especially if you find them impolite, discourteous or inflammatory).
|
|
|
|
|
It looks like an invalid window handle. Are you trying to draw something on the View before it has been properly created?
Michael
"Time and tide melts the snowman."
-- The Doctor (Doctor Who: Time and the Rani
|
|
|
|
|
In the following:
char* tempBuffer = NULL;
std::vector <char*> nBuffer;
int nRetNewDB;
CFileDialog fileDlg1(TRUE, ".*", NULL, OFN_EXPLORER|OFN_ALLOWMULTISELECT, "All Files(*.*)|*.*||",NULL);
nRetNewDB = fileDlg1.DoModal();
if (nRetNewDB == IDOK)
{
POSITION Pos;
Pos = fileDlg1.GetStartPosition();
while (Pos != NULL)
{
CString sPathName = fileDlg1.GetNextPathName(Pos);
int nSize = ReadPMAFile(sPathName, tempBuffer);
if(nSize !=0)
{
tempBuffer = new char[nSize+1];
ReadPMAFile(sPathName, tempBuffer);
nBuffer.push_back(tempBuffer);
}
}
}
I am getting compile errors regarding 'new':
c:\program files\microsoft visual studio\vc98\include\new(35) : error C2061: syntax error : identifier 'THIS_FILE'
c:\program files\microsoft visual studio\vc98\include\new(35) : error C2091: function returns function
c:\program files\microsoft visual studio\vc98\include\new(35) : error C2809: 'operator new' has no formal parameters
help! I've used 'new' a thousand times but somethings gone wrong here.....
Thanks,
ns
|
|
|
|
|
Are u using namespace std??
And i see that ur vector isnt given a type, why??
Deal with the first error first:
identifier 'THIS_FILE'
And generaly u gotta move some header include before or after
#define THIS_FILE
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
the vector does have a type: char* but CP did something to the angled brackets...
I dont have anything fancy in my includes:
#include "stdafx.h"
#include "FreadTest.h"
#include "FreadTestDoc.h"
#include "FreadTestView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#include <vector>
Oh gosh! I had to move the #include vector to above the #ifdef stuff. Now its compiling. Thanks for the juggling hint. Its bizarre!
Thanks,
ns
|
|
|
|
|
Had that and fixed it that way, i guess its mainly that vector needs to see THIS_FILE [] = __FILE__; so better let him have it!
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Hello!
I'm overriding OnActivateView function in my CFormView derived class, and it is in that function that i'm creating and displaying some objects, the number of objects depends on a database query. In order to resize my form, i must have its CRect parameters.
Inside OnActivateView i do : GetClientRect(&myRect);, but all the size parameters (left, top, right, bottom) are equal to 0.
Maybe i'm wrong but i understand that these values should only be available when OnActivateView is finished.
My question: Is there an onverride for CFormView that is called after OnActivateView and where CRect parameters are available?
Thank you in advance
|
|
|
|
|
Why dont u do all this work in OnDraw??
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Well, i'm a beginner and, I want to execute the following piece of code just after OnActivateView. I am not sure about OnDraw(). I tried placing the code in OnDraw() but I got a flickering screen.
CRect myRect;
CSize mySize;
GetClientRect(&myRect);
if (myRect.bottom<=y) //y is the vertical position of my last object
{
myRect.bottom+=200;
MoveWindow(&myRect, TRUE);
mySize=myRect.Size();
SetScrollSizes(MM_TEXT, mySize);
GetParentFrame()->RecalcLayout();
}
What am I doing wrong?
Thanks for your trouble.
|
|
|
|
|
u are flickering i guess cos
MoveWindow( LPCRECT lpRect, BOOL bRepaint = TRUE );
This means that ur sending a WM_PAINT message froom within the OnDraw, try changing it to FALSE
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
I tried that, with and without GetParentFrame()->RecalcLayout();
And in none of those ways i got satisfactory results.
I'm doing like :
void CStocks::OnDraw(CDC* /*pDC*/)
{
CRect myRect;
CSize mySize;
GetClientRect(&myRect);
if (myRect.bottom<=m_iLastY)
{
myRect.bottom+=500;
MoveWindow(&myRect, FALSE);
mySize=myRect.Size();
SetScrollSizes(MM_TEXT, mySize);
//GetParentFrame()->RecalcLayout();
}
}
After OnActivateView is finished, i have the final value for m_iLastY, and then iwant to use it to resize, is there an alternative to OnDraw?
Am i doing something wrong?
Thank again
|
|
|
|
|
Check void ResizeParentToFit( BOOL bShrinkOnly = TRUE ); guess it could help u
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Thanks again Papa!
But i don't think i must use OnDraw, i just want to find a way of calling some code after OnActivateView is finished.
Is that possivel?...I even thougth on using timers...
Thanks
|
|
|
|
|
First I dont see a flag or anything telling CFile::Read that its reading binary data, and not text. I read a binary file into a char*a: I need to know, knowing the length of the cFile object thats been opened, what size to make a:
say nSize (from GetLength) is n. Then do I say
a = new char[n+1];
or
a = new char[n];
When I read text data in, I have to put a[n] = 0 ; to null terminate it. DO i do the same in case of a binary file?
Thanks,
ns
|
|
|
|
|
ur binary file already contains NULL chars in it, so why add one??
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
From the SDK: 'FILECORE.CPP'
BOOL CFile::Open(LPCTSTR lpszFileName, UINT nOpenFlags,
CFileException* pException)
{
ASSERT_VALID(this);
ASSERT(AfxIsValidString(lpszFileName));
ASSERT(pException == NULL ||
AfxIsValidAddress(pException, sizeof(CFileException)));
ASSERT((nOpenFlags & typeText) == 0); // text mode not supported
// CFile objects are always binary and CreateFile does not need flag
nOpenFlags &= ~(UINT)typeBinary;
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Okay. That helps a lot.
Thanks,
ns
|
|
|
|
|
Does anyone have any info on the Excel file format? I have large datasets Ineed to output to Excel, but when using ODBC or the CSpreadSheet class (I think this uses ODBC also), my sql statements get too big for a CString... Anyway, is there a better/faster way for Excel IO? Any input is appreciated (as always).
Nitron
_________________________________________--
message sent on 100% recycled electrons.
|
|
|
|
|
Searched CP before posting ?
Excel generator[^]
sometimes it helps to look at the IL generated code
a MS guy on develop.com "answering" .NET issues
|
|
|
|
|
StephaneRodriguez wrote:
Searched CP before posting ?
Um...
Thanks Stephane
Nitron
_________________________________________--
message sent on 100% recycled electrons.
|
|
|
|
|
Have you looked at DTS at all? It can output to Excel without you having to write a bunch of code. You can load DTS packages in your EXE and run them from there, since DTS is really just a collection of COM objects.
If that is too much of a burden, or your data doesn't already exist in some other database for easy export, then take a look at the MSDN sample COMEXCEL. It shows how to use the Excel.Application.8 COM object, which gives you direct access to Excel and all its glory. Okay, maybe not all, but a bunch of stuff. You can create new workbooks, spreadsheets, data ranges, etc. and you can write out all of your data. Just note in this case, you'd need to have Excel installed on the same machine where your code will run.
Ty
"The significant problems we face cannot be solved at the same level of thinking we were at when we created them." -Albert Einstein
|
|
|
|
|
According to MSDN for CString GetPAthNAme() :
If m_ofn.Flags has the OFN_ALLOWMULTISELECT flag set, this string contains a sequence of null-teminated strings, with the first string being the directory path of the file group selected, followed by the names of all files selected by the user.
Now if I assign the result of calling GetPathName(), the CString I assign it to only reads in upto the first null. So how to I get a hold of the complete list of files returned by getPAthNAme()?
CString a = dlg1.GetPAthName(); and its multiselect....
Thanks,
ns
|
|
|
|
|
Use GetStartPosition() and GetNextPathName() to iterate thru the list of names.
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Read about:
GetStartPosition and GetNextPathName
hint: u get a position from the first, u put it into the other!
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|