|
Hi guys,
On closing my app I got a list of memory leaks in the output window. No problem, I went through the list, double-clicking the code line reference and adding a "delete" for that object. However, I'm left with 1 single frustrating little bugger that doesn't have a code line reference at all:
Detected memory leaks!
Dumping objects ->
{562} normal block at 0x0032D488, 4 bytes long.
Data: < s2 > 10 73 32 00
Object dump complete.
Why does this one not have a code line reference and how do I go about finding it?
Many thanks,
Simon
|
|
|
|
|
Take a look at the _CrtSetBreakAlloc in the MSDN. You can assign this your allocation number (562). So if you run your software the exact same way, you should get a BP when that allocation takes place in your program. You can then use the stack trace to backtrack to the offending code.
If you vote me down, my score will only get lower
|
|
|
|
|
Hi Roger,
Thanks for the reply - this looks exactly what I'm looking for. The only thing is that my allocation number isn't the same every time, even when I run the app in exactly the same way. It shifts between 510 and 520 with the occasional 550 thrown in for good measure! Is there a way around that?
Thanks again for your help,
Simon
|
|
|
|
|
Hi,
i have an mc file containing text in english and korean languages.I have changed my System Locale to Korean and my OS is Windows 2000(English).When i compiled this mc file i am getting all the string ids in .h file.So i was not able to access these ids using FindResourceEx() as it is searching the string table for the ids and my other language id is in .h file.How can i make this fucntion to search in .h file also?Or Is there any other way where i can copy the string ids to string table
Plz help me
Poorni
|
|
|
|
|
Dear Experts,
I am a novice student programmer who is touching Embedded Visual C++ for the first time in my life. (Previously only learnt BASIC and Visual Basic).
Currently, I am involved in this project to this simple pda to pda wireless communication. I am currently stuck at the server side of the communication program. (The client program has been written and tested to be working well).
The problem with the server side is that the program does not seems to execute the OnAccept function of the Listening socket(
although it jolly well could create a socket, listen for connection and seems to make the client program aware of its presence
by enable the client able to establish connection with the server whenever the client is attempting to connect the same port
that the socket is listening to). By not doing so, I am unable to create another client socket for communication. (Came to this
conclusion as neither results I have put in the function has appear when excuted)
I have declared the following Classes:
CServerApp (By default generated)
CServerDlg (By default generated)
CListenSocket (Class for the listening scoket. Base class: CSocket)
CLinkSocket (Class for the Client scoket. Base class: CSocket)
Member Variables (Only for the class CServerDlg, the rest does not have any)
IDC_cmdListen
Function: Listen for connection
Type: CButton
Member: m_bListen
IDC_cmdDisConnect
Function: Disconnect current connection
Type: CButton
Member: m_bDisconnect
IDC_cmdStop
Function: Stop all server service
Type: CButton
Member: m_bStop
IDC_Port
Function: hold the value of the port name
Type: int
Member: m_sPort
IDC_Status
Function: hold the value of the text meant for a status screen
Type: CString
Member: m_sStatus
|
|
|
|
|
#if !defined(AFX_LISTENSOCKET_H__E3F3638D_86D1_4A2D_B54C_87F2197FF509__INCLUDED_)
#define AFX_LISTENSOCKET_H__E3F3638D_86D1_4A2D_B54C_87F2197FF509__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
// ListenSocket.h : header file
//
#ifndef _LISTENSOCKET_H__
#define _LISTENSOCKET_H__
/////////////////////////////////////////////////////////////////////////////
// CListenSocket command target
class CServerDlg;
class CListenSocket : public CSocket
{
DECLARE_DYNAMIC(CListenSocket);
// Attributes
public:
CListenSocket(CServerDlg* pDlg);
CServerDlg* m_pDlg;
virtual ~CListenSocket();
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CListenSocket)
public:
virtual void OnAccept(int nErrorCode);
//}}AFX_VIRTUAL
// Generated message map functions
//{{AFX_MSG(CListenSocket)
// NOTE - the ClassWizard will add and remove member functions here.
//}}AFX_MSG
// Implementation
protected:
//virtual void OnAccept(int nErrorCode);
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif
#endif
// !defined(AFX_LISTENSOCKET_H__E3F3638D_86D1_4A2D_B54C_87F2197FF509__INCLUDED_)
|
|
|
|
|
// ListenSocket.cpp : implementation file
//
#include "stdafx.h"
#include "resource.h"
#include "ListenSocket.h"
#include "ServerDlg.h"
#include "Server.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CListenSocket
CListenSocket::CListenSocket(CServerDlg* pDlg)
{
m_pDlg = pDlg;
}
// CListenSocket member functions
CListenSocket::~CListenSocket()
{
}
// Do not edit the following lines, which are needed by ClassWizard.
#if 0
BEGIN_MESSAGE_MAP(CListenSocket, CSocket)
//{{AFX_MSG_MAP(CListenSocket)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
#endif // 0
IMPLEMENT_DYNAMIC (CListenSocket, CSocket)
/////////////////////////////////////////////////////////////////////////////
void CListenSocket::OnAccept(int nErrorCode)
{
CSocket::OnAccept(nErrorCode);
m_pDlg->pAccept();
}
|
|
|
|
|
#if !defined(AFX_LINKSOCKET_H__12D75D46_F7FA_4860_B853_6F83CAB47C85__INCLUDED_)
#define AFX_LINKSOCKET_H__12D75D46_F7FA_4860_B853_6F83CAB47C85__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
// LinkSocket.h : header file
//
#ifndef _LINKSOCKET_H__
#define _LINKSOCKET_H__
/////////////////////////////////////////////////////////////////////////////
// CLinkSocket command target
class CServerDlg;
class CLinkSocket : public CSocket
{
DECLARE_DYNAMIC(CLinkSocket);
// Attributes
public:
CLinkSocket(CServerDlg* m_pDlg);
CServerDlg* m_pDlg;
virtual ~CLinkSocket();
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CLinkSocket)
public:
virtual void OnReceive(int nErrorCode);
//}}AFX_VIRTUAL
// Generated message map functions
//{{AFX_MSG(CLinkSocket)
// NOTE - the ClassWizard will add and remove member functions here.
//}}AFX_MSG
// Implementation
protected:
//virtual void OnReceive(int nErrorCode);
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif
#endif
// !defined(AFX_LINKSOCKET_H__12D75D46_F7FA_4860_B853_6F83CAB47C85__INCLUDED_)
|
|
|
|
|
// LinkSocket.cpp : implementation file
//
#include "stdafx.h"
#include "resource.h"
#include "LinkSocket.h"
#include "ServerDlg.h"
#include "Server.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CLinkSocket
CLinkSocket::CLinkSocket(CServerDlg* pDlg)
{
m_pDlg = pDlg;
}
/////////////////////////////////////////////////////////////////////////////
// CLinkSocket member functions
CLinkSocket::~CLinkSocket()
{
}
// Do not edit the following lines, which are needed by ClassWizard.
#if 0
BEGIN_MESSAGE_MAP(CLinkSocket, CSocket)
//{{AFX_MSG_MAP(CLinkSocket)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
#endif // 0
IMPLEMENT_DYNAMIC (CLinkSocket, CSocket)
void CLinkSocket::OnReceive(int nErrorCode)
{
CSocket::OnReceive(nErrorCode);
m_pDlg->Read(this);
}
|
|
|
|
|
// ServerDlg.h : header file
//
#if !defined(AFX_SERVERDLG_H__68FD52BF_0A0E_4EF9_8F71_52B633DED1A3__INCLUDED_)
#define AFX_SERVERDLG_H__68FD52BF_0A0E_4EF9_8F71_52B633DED1A3__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
#include "afxwin.h"
#include "LinkSocket.h"
#include "ListenSocket.h"
/////////////////////////////////////////////////////////////////////////////
// CServerDlg dialog
class CServerDlg : public CDialog
{
// Construction
public:
CServerDlg(CWnd* pParent = NULL); // standard constructor
struct Packet
{
int packetno;
int cstatus;
char UserID[10];
char Message[20];
};
Packet RPacket;
Packet SPacket;
int State;
CListenSocket* lSocket;
CLinkSocket* eSocket;
CString screen;
void pAccept(void);
void Read(CLinkSocket* eSocket);
// Dialog Data
//{{AFX_DATA(CServerDlg)
enum { IDD = IDD_SERVER_DIALOG };
CButton m_bStop;
CButton m_bListen;
CButton m_bDisconnect;
CString m_sStatus;
int m_sPort;
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CServerDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
HICON m_hIcon;
// Generated message map functions
//{{AFX_MSG(CServerDlg)
virtual BOOL OnInitDialog();
afx_msg void OnHelpInfo();
afx_msg void OncmdDisconnect();
afx_msg void OncmdListen();
afx_msg void OncmdStop();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft eMbedded Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_SERVERDLG_H__68FD52BF_0A0E_4EF9_8F71_52B633DED1A3__INCLUDED_)
|
|
|
|
|
// ServerDlg.cpp : implementation file
//
#include "stdafx.h"
#include "Server.h"
#include "ServerDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CServerDlg dialog
CServerDlg::CServerDlg(CWnd* pParent /*=NULL*/)
: CDialog(CServerDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CServerDlg)
m_sStatus = _T("");
m_sPort = 0;
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CServerDlg:oDataExchange(CDataExchange* pDX)
{
CDialog:oDataExchange(pDX);
//{{AFX_DATA_MAP(CServerDlg)
DDX_Control(pDX, IDC_cmdStop, m_bStop);
DDX_Control(pDX, IDC_cmdListen, m_bListen);
DDX_Control(pDX, IDC_cmdDisconnect, m_bDisconnect);
DDX_Text(pDX, IDC_Status, m_sStatus);
DDX_Text(pDX, IDC_Port, m_sPort);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CServerDlg, CDialog)
//{{AFX_MSG_MAP(CServerDlg)
ON_WM_HELPINFO()
ON_BN_CLICKED(IDC_cmdDisconnect, OncmdDisconnect)
ON_BN_CLICKED(IDC_cmdListen, OncmdListen)
ON_BN_CLICKED(IDC_cmdStop, OncmdStop)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CServerDlg message handlers
BOOL CServerDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
CenterWindow(GetDesktopWindow()); // center to the hpc screen
State = 0;
GetDlgItem(IDC_cmdDisconnect) -> ShowWindow(FALSE);
GetDlgItem(IDC_cmdStop) -> EnableWindow(FALSE);
GetDlgItem(IDC_cmdListen) -> ShowWindow(TRUE);
screen.Empty();
SPacket.packetno = 0;
return TRUE; // return TRUE unless you set the focus to a control
}
void CServerDlg::OnHelpInfo()
{
MessageBox(_T("Help"));
}
//Listen Function
void CServerDlg::OncmdListen()
{
UpdateData(TRUE);
lSocket = new CListenSocket(this);
int Port;
Port = m_sPort;
//char* txtPort;
//int i = m_sPort;
//_itoa(i, txtPort, 10);
//MessageBox(txtPort,NULL,MB_OK);
//If cannot create port
if (!lSocket->Create(Port))
{
MessageBox(_T("No port Created!"), NULL, MB_OK);
return;
}
else
{
}
//If cannot listen
if (!lSocket->Listen())
{
MessageBox(_T("Cannot listen"), NULL, MB_OK);
return;
}
else
{
MessageBox(_T("Listening"), NULL, MB_OK);
GetDlgItem(IDC_cmdListen) -> EnableWindow(FALSE);
GetDlgItem(IDC_cmdStop) -> EnableWindow(TRUE);
State = 1;
}
}
//Accept Function
void CServerDlg::pAccept(void)
{
eSocket = new CLinkSocket(this);
if (lSocket->Accept(*eSocket))
{
State = 2;
MessageBox(_T("Connection Accepted!"), NULL, MB_OK);
GetDlgItem(IDC_cmdStop) -> ShowWindow(FALSE);
GetDlgItem(IDC_cmdDisconnect) -> ShowWindow(TRUE);
}
else
{
MessageBox(_T("Connection not Accepted!"), NULL, MB_OK);
delete eSocket;
}
}
// Read Function
void CServerDlg::Read(CLinkSocket* eSocket)
{
CString strcommand;
int pRead = eSocket->Receive(&RPacket, sizeof(Packet));
if (pRead > 0)
{
if (RPacket.cstatus == 0)
{
OncmdDisconnect();
}
else
{
//command = mbstowcs(buffer, RPacket.Message, 100)
}
}
}
void CServerDlg::OncmdStop()
{
GetDlgItem(IDC_cmdListen) -> EnableWindow(TRUE);
GetDlgItem(IDC_cmdDisconnect) -> EnableWindow(FALSE);
SPacket.cstatus = 0;
lSocket->Close();
delete lSocket;
GetDlgItem(IDC_cmdListen) -> EnableWindow(TRUE);
GetDlgItem(IDC_cmdStop)-> EnableWindow(FALSE);
State = 0;
}
// Disconnect Function
void CServerDlg::OncmdDisconnect()
{
SPacket.cstatus = 0;
eSocket->Close();
lSocket->Close();
delete eSocket;
delete lSocket;
GetDlgItem(IDC_cmdDisconnect) -> ShowWindow(FALSE);
GetDlgItem(IDC_cmdStop) -> ShowWindow(TRUE);
State = 1;
}
|
|
|
|
|
How can develop (using c++) the multiple clipboard Like Word...?
Thanks
Multiple Clipboard
|
|
|
|
|
Maybe you can save the content of clipboard into variable every time the clipboard is accessed
<italic>Work hard and a bit of luck is the key to success.
|
|
|
|
|
If you're using VC++ 7.x the IDE already has this feature. Use Ctrl+Shift+V to cycle though and paste the items. If you're using VC++ 6 there's a macro that does it. It's either here at codeproject or at codeguru. It looks like this...
' Three simple macros to implement a secondary clipboard
' Global to act as clipboard
Dim gSecondClipBoard
gSecondClipBoard = ""
Sub SecondaryClipBoardCut()
'DESCRIPTION: Performs a cut of current selection to a secondary clipboard.
gSecondClipBoard = ActiveDocument.Selection.Text
ActiveDocument.Selection.Text = ""
End Sub
Sub SecondaryClipBoardCopy()
'DESCRIPTION: Performs a copy of current selection to a secondary clipboard.
gSecondClipBoard = ActiveDocument.Selection
End Sub
Sub SecondaryClipBoardPaste()
'DESCRIPTION: Performs a paste of secondary clipboard to the current selection.
ActiveDocument.Selection = gSecondClipBoard
End Sub
Kevin
|
|
|
|
|
Did anybody know ?
Without function gethostbyaddr() please
---Ranger---
|
|
|
|
|
In my application, i need to open a dialog box which will input a path(i.e C:\xyz, etc) from the user. How do i do it. How do i detect that whatever the user had input is a valid path or not? is there any existing file dialog that supports this?
|
|
|
|
|
I think you seacrhing for CFileDialog this will solve you r problem,for reference see MSDN abt CFileDialog
-----------------------------
"I Think It will Work"
Formerly Known As "Alok The Programmer" at CP
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
I think you want a select folder dialog box. This can be done using the SHBrowseForFolder api function.
See http://www.codeproject.com/shell/cxsbrowsefolder.asp for a class that encapsulates this function
|
|
|
|
|
Can anyone pls tell me how to make a coloumn invisible in the datagrid during run time. This is the first time I am using datagrid. Thanks..
Jaya
|
|
|
|
|
Hello, do you guys know of any better replacement for strtok function.
(No MFC and no .NET String)
thanks
Sonork 100.41263:Anthony_Yio
|
|
|
|
|
|
Ivan Cachicatari wrote:
You can use the CStringTokenizer class...
Which uses MFC.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
|
Hi i've got these two data structures:
obj *pObj1 = new obj[10000];
obj **pobj2 = new (*obj)[10000];
for (int i=0;i<10000;++i);
pobj2[i]=new obj;
which are the advantages and disadvantages from each one of them?
i know it's an exam question, but it seems to be interesting. i can't think of many.. first, i think the first one is easier to use, but the second one is more like ordered.
i'll really appreciate your help!!
thanks!
|
|
|
|
|
1. The first is much easier to understand for most people
2. The second is useful when you might have to use a 2D array.
3. The first method allocates memory for the objects in one big allocation. If there is not enough contiguous memory left it will fail. The second method is good when memory is fragmented as it allocates individual chunks of memory for each object.
4. The second is useful if two items in the array must actually point to the same object - in the first case, each array element is unique.
Those are a few to get started
Ryan "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"
|
|
|
|