Click here to Skip to main content
15,918,193 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Die Pin
ThatsAlok4-May-07 0:44
ThatsAlok4-May-07 0:44 
AnswerRe: Read This Pin
Hamid_RT20-Apr-07 20:16
Hamid_RT20-Apr-07 20:16 
GeneralRe: Read This Pin
toxcct21-Apr-07 10:21
toxcct21-Apr-07 10:21 
AnswerRe: Read This Pin
ThatsAlok20-Apr-07 21:29
ThatsAlok20-Apr-07 21:29 
QuestionUsing one thread for multiple views Pin
jagannathan thiruvengadathan20-Apr-07 18:26
jagannathan thiruvengadathan20-Apr-07 18:26 
Questioncompilation error Pin
rsanju20-Apr-07 17:41
rsanju20-Apr-07 17:41 
AnswerRe: compilation error Pin
prasad_som22-Apr-07 20:00
prasad_som22-Apr-07 20:00 
QuestionMemory leak problem in custom control creation [modified] Pin
Birkan Cilingir20-Apr-07 12:01
Birkan Cilingir20-Apr-07 12:01 
Hi, I am using the Visual Studio 2005 Professional with SP1. When I tried to create my own custom control as described in "Creating Custom Controls By Chris Maunder" and "Creating and Using custom controls in VC++ By Yogesh M Joshi" (thanks to them by the way...Smile | :) ). In debug mode, program exits as soon as it starts with a memory leak error.

The steps I took to create the control is as follows,
1) I created a dialog based application (Unicode support & Static Library).
2) I created a new MFC class named "CMyCustomClass" which inherits from CView.
3) I declared and defined a public function to register the class. Code of this classs is given below

#define CLASS_NAME _T("CustomClassCtrl")

BOOL CMyCustomClass::RegisterScreenSaverClass(void)
{
	HINSTANCE hInst = ::AfxGetInstanceHandle();
	WNDCLASS wndcls;

	if (!(::GetClassInfo(hInst, CLASS_NAME, &wndcls)))
	{
		wndcls.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW;
		wndcls.lpfnWndProc = AfxWndProc;
		wndcls.cbClsExtra = wndcls.cbWndExtra = 0;
		wndcls.hInstance = hInst;
		wndcls.hIcon = NULL;
		wndcls.hCursor = ::AfxGetApp()->LoadStandardCursor(IDC_ARROW);
		wndcls.hbrBackground = (HBRUSH)::GetStockObject(WHITE_BRUSH);
		wndcls.lpszMenuName = NULL;
		wndcls.lpszClassName = CLASS_NAME;
		
		if (!AfxRegisterClass(&wndcls))
		{
			::AfxThrowResourceException();
			return FALSE;
		}
	}
	return TRUE;
}


4) I called this function from "CMyCustomClass" constructor.
5) I dragged and droped a custom control in the dialog window and set its class name as "CustomClassCtrl".
6) There is no more addion to the project just these steps.
7) When I compile and run the code. The following error occurs. (By the way I couldn't understand why dumping objects announced a path in drive "f:", my Visual Studio is installed in "c:")

Detected memory leaks!
Dumping objects ->
f:\sp\vctools\vc7libs\ship\atlmfc\src\mfc\occmgr.cpp(195) : {69} normal block at 0x003F4AE8, 24 bytes long.
 Data: <                > 01 00 00 00 00 00 00 00 02 00 00 00 00 00 00 00 
{68} normal block at 0x003F8F98, 16 bytes long.
 Data: <                > FF FF FF FF 00 00 00 00 00 00 00 00 00 00 00 00 
Object dump complete.
The program '[2672] Screen Saver.exe: Native' has exited with code 0 (0x0)


I have been searching for the answer for a long time now and found none yet...
Thanks for all the help.



-- modified at 18:46 Friday 20th April, 2007
AnswerRe: Memory leak problem in custom control creation Pin
cp987620-Apr-07 13:42
cp987620-Apr-07 13:42 
QuestionRe: Memory leak problem in custom control creation Pin
Birkan Cilingir20-Apr-07 23:50
Birkan Cilingir20-Apr-07 23:50 
AnswerRe: Memory leak problem in custom control creation Pin
Rick York20-Apr-07 19:13
mveRick York20-Apr-07 19:13 
QuestionAVIFileOpen trouble Pin
R.A.V.E.20-Apr-07 10:14
R.A.V.E.20-Apr-07 10:14 
QuestionRe: AVIFileOpen trouble Pin
Mark Salsbery20-Apr-07 10:52
Mark Salsbery20-Apr-07 10:52 
AnswerRe: AVIFileOpen trouble Pin
R.A.V.E.20-Apr-07 10:58
R.A.V.E.20-Apr-07 10:58 
GeneralRe: AVIFileOpen trouble Pin
Mark Salsbery20-Apr-07 11:07
Mark Salsbery20-Apr-07 11:07 
AnswerRe: AVIFileOpen trouble Pin
R.A.V.E.21-Apr-07 8:41
R.A.V.E.21-Apr-07 8:41 
QuestionRe: AVIFileOpen trouble Pin
Mark Salsbery22-Apr-07 7:14
Mark Salsbery22-Apr-07 7:14 
AnswerRe: AVIFileOpen trouble Pin
R.A.V.E.23-Apr-07 3:05
R.A.V.E.23-Apr-07 3:05 
GeneralRe: AVIFileOpen trouble Pin
Mark Salsbery23-Apr-07 4:52
Mark Salsbery23-Apr-07 4:52 
Questionright way to implement a popup window Pin
Jim Crafton20-Apr-07 8:43
Jim Crafton20-Apr-07 8:43 
QuestionSqlConnection does't work with CString????? Pin
Romiks20-Apr-07 8:27
Romiks20-Apr-07 8:27 
AnswerRe: SqlConnection does't work with CString????? Pin
Mark Salsbery20-Apr-07 9:19
Mark Salsbery20-Apr-07 9:19 
QuestionTrouble linking to SQL DB in VC++ Pin
@largeinsd20-Apr-07 8:14
@largeinsd20-Apr-07 8:14 
AnswerRe: Trouble linking to SQL DB in VC++ Pin
Mark Salsbery20-Apr-07 8:25
Mark Salsbery20-Apr-07 8:25 
GeneralRe: Trouble linking to SQL DB in VC++ Pin
@largeinsd20-Apr-07 8:40
@largeinsd20-Apr-07 8:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.