|
[EDITTED]
Got the answer in MSDN forum. It turns out I had a large global array, which I had defined earlier to test something and had forgotten about it! ah...bad programming practice!;P
[/EDITTED]
Hi,
I have a relatively small Visual C++ project using MFC which allocates
unusually hight amount of virtual memory as soon as the program
starts(roughly 280MB), even before hitting the internal MFC stuff. When I
debug them program in Visual Studio 2005 with a breakpoint at the beginning
of int _tmainCRTStartup(void) function in crt0.c Windows Task Manager shows
the following information:
Memory Usage: 5,620K
Peak Memory Usuage: 5,620K
Page Faults: 1,420
VM Size: 282,360 K
Paged Pool: 632K
NP Pool: 2K
Handles: 102
Threads: 1
GDI Object: 6
Running the program in release mode produces the same result. Also,
compiler/linker settings are almost set to default.
My question why the program allocates so much VM, before even its started
WinMain() function? Is it a Windows issue or Visual C++?
Any help appreciated!
- Rob
-- modified at 23:30 Saturday 16th September, 2006
|
|
|
|
|
This is neither a windows or VC++ issue since it's not normal for a "plain" app unless you are using extensive DLLs especially from third party.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
I am only using one thirdparty DLL coded by myself. SO I will have to investigate that.
Thanks for the lead.
|
|
|
|
|
Hello,
i want to make my edit boxes and labels transparent to show my own bitmap;
can somene help me?
|
|
|
|
|
fx9200 wrote: i want to make my edit boxes and labels transparent to show my own bitmap;
Override the OnCtlColor method:
Ex:
if(pWnd->GetDlgCtrlID()==)
{
COLORREF clrStruct=RGB();
hbr = CreateSolidBrush(clrStruct);
pDC->SetBkColor(clrStruct);
pDC->SetTextColor(RGB(0,0,0));
}
You can do something like this.
Try this....
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
I didn't find that method
it ssems it cannot be added by class wizard !
|
|
|
|
|
fx9200 wrote: I didn't find that method
What version of editor are you using. VS6.0 / VS .NET 2003 or something else.
fx9200 wrote: it ssems it cannot be added by class wizard !
You can also add the code with your hands
In the header file
HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
In the .cpp file
HBRUSH CadfDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// Add your code here
return hbr;
}
In Message map of your class
ON_WM_CTLCOLOR()
But avoid doing so...
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
thanks,
it worked;
but with this i can't set a bitmap as a back round of the edit box;
|
|
|
|
|
HBRUSH CYourDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
CBrush m_Brush;
m_pBrush.CreateStockObject (NULL_BRUSH);
if(pWnd->GetDlgCtrlID()==IDC_STATIC1)
{
pDC->SetBkMode (1);
return (HBRUSH)mBrush;
}
return hbr;
}
I hope that your problem would be solved with this.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
if you use VS2003 you can use from property window for insert WM_CTLCOLOR yto your class.
|
|
|
|
|
i'm in the end of the project;
and i dont think its a good idea to convert it automatically with wizard;
|
|
|
|
|
|
|
Hi
Can anyone tell me if it is possible to use a time delay when working on a console application.
Say if I needed to wait 3 seconds before displaying output to the screen.
eg:
char name;
cin << name;
// delay output for 3 seconds ***
cout<< name;
Web searches have proved useless so if anyone has any useful links or code it would be greatly appreciated !!!!!
Thanks in advance.
I really hate this darn machine;
I wish that they would sell it.
It won't do what I want it to,
but only what I tell it.
~Author Unknown
|
|
|
|
|
Mark_Murphy wrote: needed to wait 3 seconds
Use Sleep(3000);
1 milli second=(1/1000) seconds
However, avoid using Sleep(/*time interval*/).
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Ahhhhhhh
Thanks AnShumAn
Tried the Sleep earler but was using the (s) in lower case instead of upper.
Cheers for the help, just need to read things better next time.
I really hate this darn machine;
I wish that they would sell it.
It won't do what I want it to,
but only what I tell it.
~Author Unknown
|
|
|
|
|
Hi there,
I created a dummy MFC app in VS2005. All I want to do is to paint the view black color. When I resize the window, the view is flashing white color all over. I thought painting to an off-screen DC then calling BitBlt could avoid that. Can someone please tell me how? Thanks a lot!
This is my OnDraw function.
void CtestView::OnDraw(CDC* pDC)
{
CtestDoc* pDoc = GetDocument();
if (!pDoc)
return;
CDC offScreenDC;
CBitmap offScreenBitmap;
CBitmap * pOldBitmap = NULL;
CRect clientRect;
GetClientRect(clientRect);
if (offScreenDC.CreateCompatibleDC(pDC))
{
if (offScreenBitmap.CreateCompatibleBitmap(
pDC,
clientRect.Width(),
clientRect.Height()
)
)
{
pOldBitmap = offScreenDC.SelectObject(&offScreenBitmap);
}
}
CBrush brush;
CBrush *pOldBrush = NULL;
if (!brush.CreateSolidBrush(RGB(0, 0, 0)))
return;
pOldBrush = offScreenDC.SelectObject(&brush);
offScreenDC.FillRect(clientRect, &brush);
pDC->BitBlt(
clientRect.left,
clientRect.top,
clientRect.Width(),
clientRect.Height(),
&offScreenDC,
0,
0,
SRCCOPY
);
offScreenDC.SelectObject(pOldBrush);
offScreenDC.SelectObject(pOldBitmap);
}
|
|
|
|
|
Override OnEraseBkgnd and do nothing, return simply true.
like this;
void CtestView::OnEraseBkgnd(CDC* pDC)
{
return TRUE;
}
|
|
|
|
|
Great! I'll try that tonight and report the result. Thanks!
|
|
|
|
|
Awesome, it works like a charm! Thanks so much!
|
|
|
|
|
My pleasure.
|
|
|
|
|
Hi,
By using MFC Appwizard I have created a project.
Say FirstApp as an SDI application and chosen the Header files only as databasesupport.
I wrote a function in FirstAppView class to get the database connection.
After that I have inserted another Dialog resource and added a few controls for it and then added a new class for it.
Now I want to invoke the function which I wrote in FirstAppView class.
Can you plz say How can I do that?
Thanks in advance.
|
|
|
|
|
Does this help;
AfxGetMainWnd()->GetActiveView()->YourFunction();
|
|
|
|
|
Hi Prasad,
Actually I tried this way but I got an error saying that my application class is not derived from CWnd.
Can u say how to overcome it.
Thanks in advacne.
|
|
|
|
|
Can you show some code?
I assume your application is SDI with Doc/view support. and you have a dilaog class from which you want to access a function in view class, isn't it?
|
|
|
|