|
When your app closes down, Windows takes care of freeing up any memory that was allocated, closing file handles, and releasing GDI objects.
BTW, is this an MFC application?
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
My small app is made with WTL, is only 30kbytes..
But the memory usage that we can see in Task Manager is
around 3MBytes..
What a strange.. Messager's is only around 1.5MB when it is on the tray..
Is there any way to reduce the memory usage?
any documents?
|
|
|
|
|
bektek wrote:
But the memory usage that we can see in Task Manager...
Don't use TM to determine your app's memory usage. Those numbers represent the amount of address space that is in use. They have nothing to do with the amount of that address space your program is actually using.
If you are really interested, use the heap walking functions to track what is going on.
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Thanks your reply..
DavidCrow wrote:
Don't use TM to determine your app's memory usage. Those numbers represent the amount of address space that is in use. They have nothing to do with the amount of that address space your program is actually using.
I've got some process monitoring tool for sysinternal.com
It shows private memory usage..
In case of my app which is only 30kbytes, it shows that my app use 800kbytes private memory...
Does that mean real memory usage of my app?
It that same as heap usage?
|
|
|
|
|
bektek wrote:
Does that mean real memory usage of my app?
What do you mean by "real memory usage?"
bektek wrote:
It that same as heap usage?
"Heap usage" is how much memory your progrm has allocated on the heap.
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Hi guys,
I want to write application configuration information to an xml file usind msxml.
Please could somebody help me on how do accomplish this.
|
|
|
|
|
Here I have two problems, I only have two classes, an App and a Window.
1. I want each LETTER a different (random(switch)) color.
2. I don't want the color to change when I resize the Client Area (which it does now...)
All that happens now is that the first letter prints off the M.I.L. ("abc")
or the two menu items ("Katie", "Anna") in a diferent color...
Where have I gone wrong?
-thanks a lot
//////////////////////////////////////////////////////////////////////////////
#include <afxwin.h>
#include <cstdlib>
#include <cstdlib>
#include <ctime>
#include ".\katieapp.h"
#include ".\ckatiewin.h"
#include ".\resource.h"
CKatieWin::CKatieWin(void): m_sText("abc"), m_crColor(RGB(0,255,0))
{
Create (NULL, _T("Katie App"), WS_OVERLAPPEDWINDOW,
rectDefault, NULL, MAKEINTRESOURCE(IDR_MENU1));
CDC* pDC = GetDC();
pDC->SetBkMode(TRANSPARENT);
UpdateWindow();
}
CKatieWin::~CKatieWin(void)
{
}
BEGIN_MESSAGE_MAP(CKatieWin, CFrameWnd)
ON_WM_PAINT()
ON_COMMAND(ID_FILE_EXIT, OnFileExit)
ON_COMMAND(ID_FILE_ABOUT, OnFileAbout)
ON_COMMAND(ID_PERSON_KATIE, OnPersonKatie)
ON_COMMAND(ID_PERSON_ANNA, OnPersonAnna)
END_MESSAGE_MAP()
void CKatieWin::OnFileExit()
{
DestroyWindow();
}
void CKatieWin::OnFileAbout()
{
MessageBox("Copyright: Skunked Works 2004", "Katie App", MB_ICONEXCLAMATION);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////// MY GUESS IS THAT THE PROBLEM IS HERE SOMEWHERE..!!
void CKatieWin::OnPaint()
{
CPaintDC dc(this);
CRect rect;
CFont font;
font.CreatePointFont(2000, _T("Arial"));
dc.SelectObject(&font);
dc.SetBkColor(::GetSysColor(COLOR_WINDOW));
GetClientRect(&rect);
for(int i = 0; i < m_sText.GetLength(); i++)
{
CKatieWin::SetTextClr();
dc.SetTextColor(GetTextClr());
//dc.DrawText(m_sText[i], rect, DT_SINGLELINE);
dc.TextOut((i+1)*200, 0, m_sText.GetAt(i));
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////
TCHAR CKatieWin::GetText(int i)
{
TCHAR c = m_sText.GetAt(i);
return c;
}
void CKatieWin::SetText(CString _m_sText)
{
m_sText = _m_sText;
}
void CKatieWin::OnPersonKatie()
{
SetText("Katie");
Invalidate();
}
void CKatieWin::OnPersonAnna()
{
SetText("Anna");
Invalidate();
}
void CKatieWin::SetTextClr(void)
{
srand((unsigned)time(NULL));
int j;
j = rand() % 3;
switch(j)
{
case 0:
m_crColor = RGB(0,0,255);
break;
case 1:
m_crColor = RGB(0,255,0);
break;
case 2:
m_crColor = RGB(255,0,0);
break;
}
}
COLORREF CKatieWin::GetTextClr(void)
{
return m_crColor;
}
|
|
|
|
|
2. I don't want the color to change when I resize the Client Area (which it does now...)
now, you're resetting(randomizing) the colors at every paint event; try setting the colors elsewhere.
(hint: when you change the text ... )
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Thanks- that sounds like the thing to do...
How about gettig each letter in a random color?
|
|
|
|
|
Hi all,
I really don't know what I'm doing wrong...
I have a simple dialog (MFC), and I want to create a buffer, paint some pixels on it, and BitBlt it onto the dialog's client area.
In my dialog class I've created a new DC member:
CDC m_PicDC;
In my OnInitDialog method I create it to be compatible with my dialogs's own DC, and draw some pixels on it:
{
CDialog::OnInitDialog();
...
m_PicDC.CreateCompatibleDC(GetDC());
... draw some pixels inside m_PicDC using CDC::SetPixel ....
}
Finally, in the OnPaint method I do this:
CPaintDC dc(this);
dc.BitBlt(0,0,100,100,&m_PicDC, 0, 0, SRCCOPY);
Each and every SetPixel call returns -1 (as if I'm trying to draw outside the clipping area). All other GDI functions return TRUE. It's worth noting that if I draw directly onto the dialog's DC, everything's great, so it's unlikely that my pixel drawing routine is bad or something... but why isn't the DC big enough to hold my pixels? How can I change its size? I've trying using the SetBoundsRect method, but I'm not sure which flags to use. In any combination I tried, the SetPixel calls still returned -1..
Any ideas?
Thanks...
/=/=/=/= Sagmam =\=\=\=\
|
|
|
|
|
You need to create a bitmap of appropriate size to draw onto. The code below may help
CDC* pDC = GetDC();
ASSERT(pDC != NULL);
CRect rc(0, 0, 100, 100);
CDC memDC;
memDC.CreateCompatibleDC(pDC);
CBitmap bitmap;
bitmap.CreateCompatibleBitmap(pDC, rc.Width(), rc.Height());
CBitmap* pOldBmp = memDC.SelectObject(&bitmap);
...Draw some pixels
memDC.SelectObject(pOldBmp);
ReleaseDC(pDC);
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain)
|
|
|
|
|
Hi there!
My project looks like this:
#1 - libiupwin.lib - library written completely in C
#2 - app.exe - application written in C++ - depends on libiupwin.lib
The problem:
I can compile #1, and a .lib file is generated
I can compile #2, but linker fails with plenty of messages like:
Unresolved external '_iupDlgNext' referenced from (...)\libiupwin.lib|itraverse
"itraverse" is one of C files included in library, and iupDlgNext is of course a function (placed in library, too). I found one instance of 'iupDlgNext' and one instance of '_iupDlgNext' in a .lib file (using a text search).
I guess this has something to do with differences between C and C++ function calls, but since I have little experience with "linking problems" I could use some help with this one.
Thanks in advance.
[ CoY0te ]
Coyotus incrediblus...
|
|
|
|
|
If you have a header file for this library, you might need to add some lines like this at the top:
#ifdef _cplusplus
extern "C" {
#endif
and lines like this at the bottom
#ifdef _cplusplus
}
#endif
rebuild your C++ components, then see if it links okay.
|
|
|
|
|
The usual problem is that C linking is not specifed in the C header files. Therefor, the linker mangles the name found in the header file.
#ifdef __cplusplus
extern "C" {
#endif
/* C-Funcion prototypes */
#ifdef __cplusplus
}
#endif
The error message you show does not seem to imply that this is the problem, but it is well worth checking out.
Note: A function name mangled with an underscore in the error message is just the internal name of the function generated by the compilier (you may ignore the underscore). If you had named you function _Func the the error message would have called it __Func. Remember leading underscores are supposed to be reserved for vender/specific global variable/function names.
Well I do not know it this helped.
Good Luck!
INTP
|
|
|
|
|
I've managed to solve my problem yesterday.
I can't really tell what it really was, but it seem to me like a page size problem. Library had a page size increased to 64 since it was too large. I have created three libraries out of this one and left efault page size (16). Now it links juzt fine. Since I created new project, I'm not quite sure if something else didn't get involved, but perhaps it really was the page size.
So in cae anybody runs into similar problem this may be the hint.
Thanks for help.
[ CoY0te ]
Coyotus incrediblus...
|
|
|
|
|
i am a beginer to socket programming, i read your article i think it the best for beginers like me, i have two questions;
1. my question is how can i assign a specific ip address to server and client for example 193.125.100.10 and 193.125.100.11 for server and client respectively.
2. 2nd question is i want the application to act as server and client simultaneously, and can chat with multiple peers simultaneously.
i will be greatful for your help, and i am sure you will help beginner like me.
thanks and bye.
ShehrYar.
|
|
|
|
|
hi,
following problem:
i trace the actual front window with GetForegroundWindow(), then look up, if its classname is "CabinetWClass" or "ExploreWClass", witch are the explorer window-classes. ok, so far, so good.
then i subclass the "SysListView32" if it exists by passing through the CWnd-childwindows with
EnumChildWindows(..., ...) - fine, works!
i subclass the resulting CListView of the explorer-window and subclass its CListCtrl - ok - i can get the index of the selected item with .GetSelectonMark(). all functions work like .GetSelectionCount() and so on...
but the function .GetItemText(item, subitem) dosen´t work - also the .GetItem(&pItem) dosent return the filename of the selected file... so what??? anyone have an idea?
what i try to do:
i want to check out if specific files are selected in the windows-explorer-windows - if they are selected, i want to run a action...
cheers,
vertex_x
|
|
|
|
|
vertex_x wrote:
what i try to do:
i want to check out if specific files are selected in the windows-explorer-windows - if they are selected, i want to run a action...
Why not just add your action item to the context menu that pops up when you right-click a file? It's much easier, and wouldn't be nearly as annoying, than what you are currently doing.
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
of course, thats right. but excessive right-clicking and popping windows takes to much time for me. i just want to cycle through a lot of files and directly see some type of preview... without draging files to a preview window or starting applikations via right-click...
|
|
|
|
|
Fair enough. Have you checked out the IShellChangeNotify interface? There's also SHChangeNotifyRegister() .
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
thanx alot!
i actually can´t find any documentation about them, even not in my msdn-library ;o) looking now on msdn in the net for it ;o)
i´ll notice here, if it works...
cheers,
vertex
|
|
|
|
|
with the above functions i get only messages if something is changed - eg. file rw-access, folder creation/delet, media insertion/remov and so on... but thanks anyway ;o) it was a good tray )
cheers,
vertex
|
|
|
|
|
Hey Guys
I have memory leak problem in my app.
I found one function in MSDN which gives the dump of memory if you have leak in u'r programm.
The functions is, _CrtDumpMemoryLeaks()
But it gives the output on console. I want to dump all information in one text file. Any pointer how to do that. ?
I use have also used following to print it in file
_CrtSetReportMode( _CRT_WARN, _CRTDBG_MODE_FILE )
_CrtSetReportFile( _CRT_WARN, handle);
Where handle is _HFILE type of handle of opened file. But still it doesn't gives result as expected. My new created text file is empty...
Any help plz ?
Regards
Mike
|
|
|
|
|
is _DEBUG defined?
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
The following call redirects standard output to a file:
freopen( "log.txt", "w", stdout );
Hope it helps.
[ CoY0te ]
coyotus incrediblus...
|
|
|
|
|