|
write the file into a sequence of numbered sub-files (i would include a file header of my own design that kept the name of the file sequence and the sequence number safe inside)
the sub-file size would depend on how you have to read it back in but i would consider maybe 20mb to 50mb blocks ... its still going to be a real bore for the folks waiting to load even a portion of the overall file but its better than waiting for the whole thing to arrive in memory
you do of course have a machine with vast amounts of ram and virtual memory i assume or loading in is a real no-no
---
"every year we invent better idiot proof systems and every year they invent better idiots"
|
|
|
|
|
When I execute program under debugger I receive message:
HEAP[aaa.exe]: Invalid Address specified to RtlFreeHeap( 1c50000, 1608938 )
But visual problems with pointers doesn't exist.
Can you advice me something.
|
|
|
|
|
in my experience this usually means you have allocated some memory blocks and either over or underwritten the allocated space ... check you don't exceed the amount of memory you allocated
---
"every year we invent better idiot proof systems and every year they invent better idiots"
|
|
|
|
|
You may want to verify mixed libraries in your linkage - debug and release builds. The memory allocated in debug builds has some additional space that does not exist in release mode (see for ex, help _calloc_dbg in MSDN). The solution then is to link only the same builds of your libs (either debug or release).
|
|
|
|
|
I have developed a regular DLL which contains dialog
resource, having ActiveX control along with other windows controls. I
have exported a function which calls DoModal function on that dialog.
But when I call this function in another application ( using explict
linking - LoadLibrary..) it does not display the dialog box and returns
-1 . It works fine when there is no ActiveX control.
Please let me know the solution for
Capizzi Filippo
|
|
|
|
|
I enumerate the encoders registered on my computer(such as:Cinepak Codec by Radius, MJPEG Compressor,DivX MPEG-4 Fast-Motion...).Then how can I select one of them (Such as DivX Fast-Motion) to compress the timeline using DirectShow filters?
Note:
These encoder have the same CLSID(CLSID_AVICo),only FccHandler and FridenlyName are different.How to select one of them?
Thanks!
|
|
|
|
|
Well I have been at it for some time, searched the newsgroups and all, but in the end found nothing.
I create my toolbars with this call:
g_hwndTB[j] = CreateWindowEx(0, TOOLBARCLASSNAME, (LPSTR) NULL,
TBSTYLE_TOOLTIPS | TBSTYLE_FLAT | CCS_NODIVIDER, 0, 0, 0, 0, hwndParent, 0, g_hInst, NULL);
j is the specific toolbar, this is a loop creating each toolbar in sucession. I add the bitmaps, the buttons, etc. Then I create the rebar:
HWND hwndRb = CreateWindowEx(WS_EX_TOOLWINDOW, REBARCLASSNAME, (LPSTR) NULL, RBS_VARHEIGHT |
RBS_AUTOSIZE | RBS_BANDBORDERS | RBS_DBLCLKTOGGLE | RBS_REGISTERDROP | RBS_VARHEIGHT | CCS_NODIVIDER | CCS_NOPARENTALIGN | RBS_VERTICALGRIPPER | WS_BORDER | WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_VISIBLE, 0, 0, 0, 0, hwndParent, 0, g_hInst, NULL);
After this I insert the bands as follows:
REBARBANDINFO rbbi;
rbbi.cbSize = sizeof(REBARBANDINFO);
rbbi.fMask = RBBIM_COLORS | RBBIM_CHILD | RBBIM_CHILDSIZE | RBBIM_STYLE | RBBIM_ID | RBBIM_SIZE;
rbbi.clrFore = GetSysColor(COLOR_BTNTEXT);
rbbi.clrBack = GetSysColor(COLOR_BTNFACE);
rbbi.fStyle = RBBS_NOVERT | RBBS_CHILDEDGE ;
for(int i=0; i
|
|
|
|
|
Hi !
How can I get text under mouse pointer ?
Sorry for my bad English .
|
|
|
|
|
Hmm ... ::GetCursorPos + ::RealWindowFromPoint + ::GetWindowText should will do the job.
Best regards,
-----------
Igor Soukhov (Brainbench/Tekmetrics ID:50759)
igor_soukhov@yahoo.com | ICQ:57404554 | http://siv.da.ru
|
|
|
|
|
---
|
|
|
|
|
I've made mistake in previouse post. I've written RealWindowFromPoint - but I was thinking of
WindowFromPoint, RealChildWIndowFromPoint
Best regards,
-----------
Igor Soukhov (Brainbench/Tekmetrics ID:50759)
igor_soukhov@yahoo.com | ICQ:57404554 | http://siv.da.ru
|
|
|
|
|
I've stumbled into a nasty limitation of tree controls.
I need to build a tree control that uses images from the system image list as well as my own custom images. (One branch of the tree will reference file objects in the system, and the other will reference my own objects.) I initially tried to do this by copying the entire system image list to my own image list, but alas, the system image list is dynamic, and may not have a particular icon in it unless I specifically request it. Well, I can't do tht on initialization, cause I don't know which icons I may need.
So now I'm looking at storing handles to the icons (along with other info) in the LParam for each tree node, and then using custom draw to draw the icon. However, this seems kludgy, and I'm not sure it's the best approach. Does anyone have suggestions?
TIA
|
|
|
|
|
I'd set the item image index to I_IMAGECALLBACK and handle TVN_GETDISPINFO.
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
Thanks, but I don't think that will help; it still makes use of the images in the control's image list. That's the problem: not the fact that I can't reference images in the list, but the fact that I can't even build the imge list.
|
|
|
|
|
> So now I'm looking at storing handles to the icons (along with
> other info) in the LParam for each tree node, and then using
> custom draw to draw the icon.
You can play with custom draw, but I think it would be easier to use the control's image list as a 'icon cache'. When TVN_GETDISPINFO is processed, you can add the icon to imagelist before returning from message handle - sort of 'delay loading' for icons.
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
Hi
can anyone tell me how I can realize two programs that communicate without a server with each other using TCP/IP( Peer-to-Peer)?
I would be grateful if you can give me a tip or a link
|
|
|
|
|
Listen on one end, connect on the other.
|
|
|
|
|
Hi,
I have a static frame containing an image.
I need to get a region (rectangle) of this image and rezize it (zoom it) in another static frame on the same dialog .
Somebody have an idea of how that could be done?
Thanks a lot!
Fred
|
|
|
|
|
Check the MFC example Scribble. This is deals with OLE, but it may help.
Scot Croston
|
|
|
|
|
Hi:
I'm new in C++, and visual c++ programming and I have problems in a program I'm doing. I have a class like this:
class CDatos : public CDocument
{
protected:
DECLARE_SERIAL(CDatos)
CDatos();
public:
CDatos* GetDocument();
int dia;
int mes;
int anno;
int horaActual;
CString Titulo;
int hora[24];
int temp[24];
int rocio[24];
int pres[24];
int vel[24];
char direccion[24][9];
public:
virtual void Serialize (CArchive& ar);
virtual ~CDatos();
};
After it, I do this (in a .cpp file:
CDatos datosF;
Then I read from a file and put data into member variables, something like this: fscanf(fp,"%d.%d.%d %d", &datosF.anno,&datosF.mes,&datosF.dia,&datosF.horaActual);.....etc
, and I draw a graphic with this data. If I open 2 or 3 files I don't have problems, but when I try to open more, the system memory goes down quickly and the graphics began to do strange things. I suppose the problem is than something overwrites memory.
Can anybody help me to clean memory data after reading a new file? I suppose the solution is using 'new', 'delete' or destructor class, but I don`t know how to do it.
Thank you very much.
|
|
|
|
|
> but when I try to open more, the system memory goes down quickly and
> the graphics began to do strange things.
That sounds more like a GDI resource leak than a memory leak (to me, anyway). The class, as you described it above, does not take up a great amount of memory, so I do not see how having a few of them floating around in memory would cause that problem.
Overwrites are something to consider, but we would have to see a bit more of your code.
Peace!
-=- James.
|
|
|
|
|
WELL, THIS IS THE FUNCTION DRAWING GRAPHIC:
/***************************
void CMeteoGraficaView::dibuja(CDC *pDC)
{
static int horaInicio;
static char *dir[8]= {"N","NE","E","SE","S","SO","O","NO" };
int x,x1,y,y1,maxT, minT, maxP, minP, maxV, minV,escalaT, escalaP, escalaV;
CPen *m_pPincel;
m_pPincel=NULL;
CFont* m_pLetra;
m_pLetra=NULL;
CString dirViento, actual, actual1;
int i;
float hH;
short nCount;
horaInicio=datosF.hora[0]+horaPref;
for(i=0;i<24;i++)
{
if(datosF.temp[i]!=666){
maxT=datosF.temp[i];
hayDatos=1;
}
}
for(i=0;i<24;i++)
{
if(datosF.rocio[i]!=666) minT=datosF.rocio[i];
}
for(i=0;i<24;i++)
{
if(datosF.pres[i]!=666) maxP=minP=datosF.pres[i];
}
for(i=0;i<24;i++)
{
if(datosF.vel[i]!=666) maxV=minV=datosF.vel[i];
}
for (i=0;i<24;i++)
{
if((datosF.temp[i]>maxT)&&(datosF.temp[i]!=666)) maxT=datosF.temp[i];
if ((datosF.rocio[i]<mint)&&(datosf.rocio[i]!=666)) mint="datosF.rocio[i];
if((datosF.pres[i]">maxP)&&(datosF.pres[i]!=666)) maxP=datosF.pres[i];
if ((datosF.pres[i]<minp)&&(datosf.pres[i]!=666)) minp="datosF.pres[i];
if((datosF.vel[i]">maxV)&&(datosF.vel[i]!=666)) maxV=datosF.vel[i];
if ((datosF.vel[i]<minv)&&(datosf.vel[i]!=666)) minv="datosF.vel[i];
}
escalaT=((maxT-minT)/8)+1;
escalaP=((maxP-minP)/8)+1;
escalaV=((maxV-minV)/8)+1;
" if(!lstrcmp("n",datosf.direccion[23]))="" dirviento="Norte" ;
="" else="" if(!lstrcmp("nne",datosf.direccion[23]))="" if(!lstrcmp("ne",datosf.direccion[23]))="" if(!lstrcmp("calm",datosf.direccion[23]))="" hh="(float)datosF.horaActual/100;
datosF.Titulo.MakeUpper();
actual.Format("Ultimos" datos="" del="" día="" %02d="" %d="" a="" las="" %.2f="" horas:="" %9s",="" datosf.dia,datosf.mes,datosf.anno,hh,datosf.titulo);
actual1.format("temperatura:="" %dºc,="" punto="" de="" rocio:="" presión="" atmosférica:="" mb.="" viento:="" km="" h,="" con="" dirección:="" %s."="" ,datosf.temp[23],datosf.rocio[23],datosf.pres[23],datosf.vel[23],dirviento);
pdc-="">SetMapMode(MM_LOENGLISH);
m_pLetra= new CFont();
m_pLetra->CreateFont(16,0,0,0,FW_SEMIBOLD,FALSE,FALSE,FALSE,
DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,
18,"Times New Roman");
pDC->SelectObject(m_pLetra);
pDC->TextOut(25,-2,actual);
pDC->TextOut(25,-16,actual1);
pDC->SelectObject(m_pLetra);
delete m_pLetra;
m_pLetra=NULL;
m_pLetra= new CFont();
m_pLetra->CreateFont(15,0,0,0,FW_NORMAL,FALSE,FALSE,FALSE,
DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,
18,"Times New Roman");
pDC->SelectObject(m_pLetra);
//COORDENADAS TEMPERATURA
pDC->MoveTo(60,-60);
pDC->LineTo(60,-220);
pDC->MoveTo(60,-220);
pDC->LineTo(310,-220);
pDC->TextOut(55,-45,"º",1); //1 o 2??
pDC->TextOut(63,-45,"C",1); //1 o 2??
coorH(pDC,80,215,horaInicio);
coorV(pDC,escalaT,maxT,40,60,0);
//COORDENADAS PRESION
pDC->MoveTo( 405,-60);
pDC->LineTo( 405,-220);
pDC->MoveTo( 405,-220);
pDC->LineTo( 655,-220);
pDC->TextOut( 400,-45,"mb",2); // 2 o 3??
coorH( pDC,425,215,horaInicio);
coorV( pDC,escalaP,maxP,385,60,0);
//COORDENADAS VELOCIDAD
pDC->MoveTo( 60,-280);
pDC->LineTo( 60,-440);
pDC->MoveTo( 60,-440);
pDC->LineTo( 310,-440);
pDC->TextOut( 50,-262,"km/h",4); //4 o 5??
coorH( pDC,80,435,horaInicio);
coorV(pDC, escalaV,maxV,40,280,1);
//COORDENADAS DIRECCION
pDC->MoveTo( 405,-280);
pDC->LineTo( 405,-440);
pDC->MoveTo( 405,-440);
pDC->LineTo( 655,-440);
coorH( pDC,425,435,horaInicio);
for (i=0,y=280;i<8;i++)
{
pDC->MoveTo( 400,-y);
pDC->LineTo( 410,-y);
nCount=sprintf(ch,dir[i]);
pDC->TextOut( 383,-(y-6),ch,nCount);
y=y+20;
}
//COORDENADAS MEDIDAS TEMPERATURA
m_pPincel= new CPen();
m_pPincel->CreatePen(PS_SOLID,2,RGB(255,0,0));
pDC->SelectObject(m_pPincel);
medida (pDC,80,60,maxT,escalaT,datosF.temp);
pDC->SelectObject(m_pPincel);
delete m_pPincel;
m_pPincel=NULL;
//COORDENADAS MEDIDAS ROCIO
m_pPincel= new CPen();
m_pPincel->CreatePen(PS_SOLID,2,RGB(255,96,0));
pDC->SelectObject(m_pPincel);
medida (pDC,80,60,maxT,escalaT,datosF.rocio);
pDC->SelectObject(m_pPincel);
delete m_pPincel;
m_pPincel=NULL;
//COORDENADAS MEDIDAS PRESION
m_pPincel= new CPen();
m_pPincel->CreatePen(PS_SOLID,2,RGB(0,255,255));
pDC->SelectObject(m_pPincel);
medida (pDC,425,60,maxP,escalaP,datosF.pres);
pDC->SelectObject(m_pPincel);
delete m_pPincel;
m_pPincel=NULL;
//COORDENADAS MEDIDAS VELOCIDAD
m_pPincel= new CPen();
m_pPincel->CreatePen(PS_SOLID,2,RGB(255,0,255));
pDC->SelectObject(m_pPincel);
medida (pDC,80,280,maxV,escalaV,datosF.vel);
pDC->SelectObject(m_pPincel);
delete m_pPincel;
m_pPincel=NULL;
//COORDENADAS MEDIDAS DIRECCION
for(i=0;i<24;i++)
{
x=425+(10*i);
x1=425+(10*(i+1));
y=y1=280;
...
m_pPincel= new CPen();
m_pPincel->CreatePen(PS_SOLID,2,RGB(0,255,0));
pDC->SelectObject(m_pPincel);
if (i<23&&lstrcmp("No",datosF.direccion[i])&&lstrcmp("No",datosF.direccion[i+1])&&lstrcmp("Calm",datosF.direccion[i])&&lstrcmp("Calm",datosF.direccion[i+1])&&lstrcmp("Variable",datosF.direccion[i])&&lstrcmp("Variable",datosF.direccion[i+1]))
{
pDC->MoveTo(x,-y);
pDC->LineTo (x1,-y1);
}
if (i<23&&lstrcmp("No",datosF.direccion[i])&&!lstrcmp("No",datosF.direccion[i+1]))
{
pDC->MoveTo(x,-y);
pDC->LineTo(x+3,-y);
}
pDC->SelectObject(m_pLetra);
delete m_pLetra;
m_pLetra=NULL;
pDC->SelectObject(m_pPincel);
delete m_pPincel;
m_pPincel=NULL;
}
}
/*****************************/
I CALL THE FUCTION FROM ONDRAW, THIS WAY:
void CMeteoGraficaView::OnDraw(CDC* pDC)
{
CPen *m_pPincel;
m_pPincel=NULL;
CFont* m_pLetra;
m_pLetra=NULL;
CMeteoGraficaDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
CMeteoGraficaView::dibuja(pDC);
}
/**************************************/
AND THIS IS ONE OF THE WAYS ACQUIRING DATA (WITH SERIALIZE)
void CMeteoGraficaDoc::Serialize(CArchive& ar)
{
// CDocument::Serialize(ar);
datosF.Serialize(ar);
if (ar.IsStoring())
{ ar<<datosf.dia<<datosf.mes<<datosf.anno<<datosf.horaactual<<datosf.titulo;
for(int="" i="0;" i<24;i++)
="" {
="" ar<<datosf.hora[i]<<datosf.temp[i]<<datosf.rocio[i]<<datosf.pres[i]<<datosf.vel[i];
="" ar.write(datosf.direccion[i],3);
="" }
="" }
="" else
="" ar="">>datosF.dia>>datosF.mes>>datosF.anno>>datosF.horaActual>>datosF.Titulo;
for(int i = 0; i<24;i++)
{
ar>>datosF.hora[i]>>datosF.temp[i]>>datosF.rocio[i]>>datosF.pres[i]>>datosF.vel[i];
ar.Read(datosF.direccion[i],3);
}
ficheroLeido=TRUE;
ficheroDisco=TRUE;
}
}
/*******************************/
AFTER EACH FILE OPENED I LOOSE A 5% MEMORY( 41%, 37%, 32% ...)
|
|
|
|
|
> WELL, THIS IS THE FUNCTION DRAWING GRAPHIC [...]
Whenever you call CDC::SelectObject(...), you need to store the object that is returned from that function call, and restore it back into the GDI context. Also, deleting a GDI object while it is still Selected into a Device Context (DC) is a bad thing.
My suggestions would be to:
1: Keep track of the objects returned from the call to SelectObject(...), or take a look at the SaveDC(...) and RestoreDC(...) functions. You will need to make sure to restore previously selected objects back into the DC before you delete the CGdiObjects that are currently selected into it.
2: Do not use dynamic memory allocation for the temporary GDI objects you are using (the CPen and CFont objects). Allocate them locally, on the stack, and just reuse them as needed.
Peace!
-=- James.
|
|
|
|
|
Well, I took the idea from a Microsoft Visual C++ example (In the offical book):
void CMyDrawView::SetPenBrush(CDC *pDC, bool bTransparent, UINT nColor)
{
ASSERT(pDC != NULL);
if(bTransparent)
{
m_pBrushOld = (CBrush*)pDC->SelectStockObject(NULL_BRUSH);
}
else
{
m_pBrushOld = (CBrush*)pDC->SelectStockObject(WHITE_BRUSH);
}
ASSERT(m_pBrushOld != NULL);
ASSERT(nColor - ID_COLOR_BLACK >= 0 &&
nColor - ID_COLOR_BLACK <=
(sizeof(arColors) / sizeof(arColors[0])));
m_pPenNew = new CPen(); //------->> here
m_pPenNew->CreatePen(PS_INSIDEFRAME, 0,
arColors[nColor - ID_COLOR_BLACK]);
m_pPenOld = (CPen*)pDC->SelectObject(m_pPenNew);
}
void CMyDrawView::ResetPenBrush(CDC *pDC)
{
ASSERT(pDC != NULL);
pDC->SelectObject(m_pBrushOld);
pDC->SelectObject(m_pPenOld);
delete m_pPenNew; //--------->>>>> here
m_pPenNew = NULL;
m_pPenOld = NULL;
m_pBrushOld = NULL;
}
Which is the solution then?
|
|
|
|
|
> Well, I took the idea from a Microsoft Visual C++ example [...]
> Which is the solution then?
The solution is to never use Microsoft source code as an example of good coding practices (when was the last time you crashed a Microsoft product?)!
The example code uses dynamic memory allocation because the object is allocated in the scope of one function, and used in the scope of another. While not the best solution, it gets around the scoping problem.
Note, however, that the example code DOES restore the existing objects back into the DC in the ResetPenBrush(..) function. That is what the m_pPenOld and m_pBrushOld are used for.
The original code you posted does not suffer from a scoping problem, so you should be able to use a locally (stack) allocated object.
Peace!
-=- James.
|
|
|
|
|