Close MDI Child Window Fail ???

in my MDI app.......I inserted a CRecordView-base Class 
named CLogin
when I input my ID and my Password .... I want this form 
disappear but when
app run to this line
			GetDocument()->OnCloseDocument();
Login Form is hide and a Error MessageBox show
Unhandled exception in QLBH.exe (MFCD42D.DLL): 0xC0000005: 
Access Violation.
and cursor point to this line in DBCORE.CPP like following:

BOOL CRecordset::IsOpen() const
	// Note: assumes base class CRecordset::Close 
called
{
	if (m_hstmt == NULL)     // Error in this line //
		return FALSE;
......
}

I tried use: 
SendMessage(WM_CLOSE) or SC_CLOSE 
or GetParentFrame()->SendMessage(WM_CLOSE);
but no result
help me
thank


///////////////////////////////////////////////////////////
///////////////

#if !defined
(AFX_LOGIN_H__2DE803FF_5C8C_4180_8AAD_43EA0E5C7199__INCLUDE
D_)
#define 
AFX_LOGIN_H__2DE803FF_5C8C_4180_8AAD_43EA0E5C7199__INCLUDED
_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// Login.h : header file
//

///////////////////////////////////////////////////////////
//////////////////
// CLogin record view

#include "QLBHSet.h"

class CLogin : public CRecordViewa
{
protected:
	CLogin();           // protected constructor used 
by dynamic creation
	DECLARE_DYNCREATE(CLogin)

// Form Data
public:
	//{{AFX_DATA(CLogin)
	enum { IDD = IDD_LOGIN_FORM };
	CEdit	m_editPass;
	CEdit	m_editID;
	CQLBHSet* m_pSet;
	//}}AFX_DATA

// Attributes
public:

// Operations
public:
	CQLBHSet* GetRecordset();


// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CLogin)
		// NOTE - the ClassWizard will add and 
remove member functions here.
	public:
	virtual CRecordset* OnGetRecordset();
	protected:
	virtual void DoDataExchange(CDataExchange* 
pDX);    // DDX/DDV support
	virtual void OnInitialUpdate();
	//}}AFX_VIRTUAL

// Implementation
protected:
	virtual ~CLogin();
#ifdef _DEBUG
	virtual void AssertValid() const;
	virtual void Dump(CDumpContext& dc) const;
#endif

	// Generated message map functions
	//{{AFX_MSG(CLogin)
	afx_msg void OnOk();
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

///////////////////////////////////////////////////////////
//////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional 
declarations immediately before the previous line.

#endif // !defined
(AFX_LOGIN_H__2DE803FF_5C8C_4180_8AAD_43EA0E5C7199__INCLUDE
D_)


///////////////////////////////////////////////////////////
///////////////

// Login.cpp : implementation file
//

#include "stdafx.h"
#include "QLBH.h"
#include "Login.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

///////////////////////////////////////////////////////////
//////////////////
// CLogin

IMPLEMENT_DYNCREATE(CLogin, CRecordView)

CLogin::CLogin()
	: CRecordView(CLogin::IDD)
{
	//{{AFX_DATA_INIT(CLogin)
	m_pSet = NULL;
	//}}AFX_DATA_INIT
}

CLogin::~CLogin()
{
	if (m_pSet)
		delete m_pSet;
}

void CLogin::DoDataExchange(CDataExchange* pDX)
{
	CRecordView::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CLogin)
	DDX_Control(pDX, IDC_EDIT2, m_editPass);
	DDX_Control(pDX, IDC_EDIT1, m_editID);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CLogin, CRecordView)
	//{{AFX_MSG_MAP(CLogin)
	ON_BN_CLICKED(IDOK, OnOk)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

///////////////////////////////////////////////////////////
//////////////////
// CLogin diagnostics

#ifdef _DEBUG
void CLogin::AssertValid() const
{
	CRecordView::AssertValid();
}

void CLogin::Dump(CDumpContext& dc) const
{
	CRecordView::Dump(dc);
}
#endif //_DEBUG

///////////////////////////////////////////////////////////
//////////////////
// CLogin message handlers

CRecordset* CLogin::OnGetRecordset()
{
	if (m_pSet != NULL)
		return m_pSet;

	m_pSet = new CQLBHSet(NULL);
	m_pSet->Open();

	return m_pSet;
}

CQLBHSet* CLogin::GetRecordset()
{
	CQLBHSet* pData = (CQLBHSet*) OnGetRecordset();
	ASSERT(pData == NULL || pData->IsKindOf
(RUNTIME_CLASS(CQLBHSet)));
	return pData;
}

void CLogin::OnInitialUpdate()
{
	BeginWaitCursor();
	GetRecordset();
	CRecordView::OnInitialUpdate();
	if (m_pSet->IsOpen())
	{
		CString strTitle = m_pSet->m_pDatabase-
>GetDatabaseName();
		CString strTable = m_pSet->GetTableName();
		if (!strTable.IsEmpty())
			strTitle += _T(":") + strTable;
		GetDocument()->SetTitle(strTitle);
	}
	EndWaitCursor();

	ResizeParentToFit(FALSE);
}

void CLogin::OnOk() 
{
	// TODO: Add your control notification handler 
code here
	CString	strID,strPass;

	m_editID.GetWindowText(strID);
	m_editPass.GetWindowText(strPass);

	m_pSet->MoveFirst ();
	while(!m_pSet->IsEOF())
	{
		if(!strID.Compare(m_pSet->m_ID))
		{
			if (!strPass.Compare(m_pSet-
>m_Pass))
				AfxMessageBox("ok");
			else
				AfxMessageBox("wrong");

			GetDocument()->OnCloseDocument
(); //Error//
			//GetParentFrame()->SendMessage
(WM_CLOSE); // error //
		}
		
		m_pSet->MoveNext();
	}
	
}



0
skidrow406 (16)
8/2/2003 8:29:32 PM
vc.mfc 33608 articles. 0 followers. Follow

1 Replies
942 Views

Similar Articles

[PageSpeed] 38

I think you need to delete your m_pSet in the OnDestroy handler of your 
view, rather than in the destructor.  And remember to assign NULL to 
your pointer after it is deleted.

In article <013001c35934$c82a1b40$a501280a@phx.gbl>, beginner says...
> in my MDI app.......I inserted a CRecordView-base Class 
> named CLogin
> when I input my ID and my Password .... I want this form 
> disappear but when
> app run to this line
> 			GetDocument()->OnCloseDocument();
> Login Form is hide and a Error MessageBox show
> Unhandled exception in QLBH.exe (MFCD42D.DLL): 0xC0000005: 
> Access Violation.
> and cursor point to this line in DBCORE.CPP like following:
> 
> BOOL CRecordset::IsOpen() const
> 	// Note: assumes base class CRecordset::Close 
> called
> {
> 	if (m_hstmt == NULL)     // Error in this line //
> 		return FALSE;
> .....
> }
> 
> I tried use: 
> SendMessage(WM_CLOSE) or SC_CLOSE 
> or GetParentFrame()->SendMessage(WM_CLOSE);
> but no result
> help me
> thank
> 
> 
> ///////////////////////////////////////////////////////////
> ///////////////
> 
> #if !defined
> (AFX_LOGIN_H__2DE803FF_5C8C_4180_8AAD_43EA0E5C7199__INCLUDE
> D_)
> #define 
> AFX_LOGIN_H__2DE803FF_5C8C_4180_8AAD_43EA0E5C7199__INCLUDED
> _
> 
> #if _MSC_VER > 1000
> #pragma once
> #endif // _MSC_VER > 1000
> // Login.h : header file
> //
> 
> ///////////////////////////////////////////////////////////
> //////////////////
> // CLogin record view
> 
> #include "QLBHSet.h"
> 
0
8/2/2003 11:24:07 PM
Reply:

Similar Artilces:

Microsoft Windows 2000 Pro
Does anyone have alot of experience with 2000 Pro??? Something went completly haywire with my Outlook. First its refers to IIS 4.0, then to some patch and send me to the vendor which I've been sent to another file and another until I guess run out. Sure would like some help with this. I can't uninstall or reinstall Mico Windows 2000 Pro. Patch error again. Thanks You're not making a lot of sense here. Can you explain what you are trying to do and with what version of Outlook? Also mention the exact errors you get and from what programs these errors come from. -- Robert S...

exchange or windows forestprep
Hi I currently have exchange 2000 in a 2000 AD environment, I am about to upgrade our environment to windows 2003 and exchange 2003 by putting in a new FE server. I was wondering should I run Exchange 2003 forestprep and domainprep 1st or Windows 2003 forestprep and domainprep. Does it actually matter? TIA Joe Sorry Nuevo My fault, my new FE server isn't going to be a 2003 DC as well. I am going to install e2k3 (FE) on a new 2003 member server, then a week or 2 later deploy my 1st w2k DC. Do I still need to run windows 2003 forestprep and domainprep 1st, then exchange 2003...

ThisWorkbook.Close question
Please take a look at the code below: Public Sub DumbFoo ( ) ThisWorkbook.Close() Sheet1.Range("A1").Value = -1 ThisWorkbook.Save() End Sub Is it safe to assume that the code below the "ThisWorkbook.Close()" line will NOT be executed??? My question is basically: Does all VBA code stop executing once a .Close() function is called??? Thank you! I don't believe the code would execute at all because of the parentheses after Close. It would throw an error an tell you that something is missing, or type mismatch. But, if you did...

position of a CDialog window
Hi all, I'm just a beginner in MFC programming, and I have a littel problem: I don't know how to set the position of a window created here's my code: ================================================================== CDialogOpInCorso* pDialog; pDialog = new CDialogOpInCorso(); //Check if new succeeded and we got a valid pointer to a dialog object if(pDialog != NULL) { BOOL ret = pDialog->Create( IDD_OPINCORSO, this ); if(!ret) //Create failed. { MessageBox("Error creating Dialog", TITOLO_ERRORE, MB_ICONERROR ); } pDialog->m_strOpInCorsoMsg = &quo...

How to Enable Close(cross) button of MB_YESNO messagebox
Hi, I want to enable the close(cross) button in the right corner of YESNO message box. Can anybody tell me how to do this. Klic. "Klic" <rohit.turambekar@gmail.com> wrote in message news:1186120969.045121.287770@i13g2000prf.googlegroups.com... > I want to enable the close(cross) button in the right corner of YESNO > message box. > Can anybody tell me how to do this. Why? If there is a valid answer other than yes or no, then how about a yes/no/cancel message box in which (I would guess) the x button is equivalent to cancel. That would be more standard. Da...

Outlook closes and closes
Hi I have a strange bug. Windows XP Sp2 and outlook from office 20003 with all service packs applied. When I start outlook from windows out of standby postion, outlook immediately after the splash screen closes without reporting any errors in the eventlog or in any other log. If I start outlook the 10th time (or so) it stabilizes and does not close anymore and everything works again. info: My machine is fully patched and I am well known with keeping things healthy. Outlook.exe Version: 11.0.6353.0 Any ideas what to do? Thanks... try the detect and repair in the help menu. >----...

closing
What's the best way to close for the day? Making a backup is a given, but what about the computer? Is it better to shut everything off every day, or is it less wear and tear on the computer to leave it on all the time? Any thoughts on this would be appreciated. Craig That's a matter of preference really. Personally I always turn off my rigs at home when I'm done with them. At the store we leave most of ours on 24/7. We've done it for years with no issues. Our register must be left on as it does automatic backups to a tape drive every night. I'd set your monitors ...

Windows xp updates question
When I try to update Windows XP IE will not load page. It's as if the page didn't exist. I go click on 'Tools/Window Update' but the MS update page will not be found. How can I fix this? Tony Alpha wrote: > When I try to update Windows XP IE will not load page. It's as if > the page didn't exist. I go click on 'Tools/Window Update' but the > MS update page will not be found. > > How can I fix this? Windows XP _____ Edition with Service Pack _ __-Bit? Internet Explorer version _? Assuming some 32-bit version of Windows XP...

Help
When creating or fowarding an e-mail message using outlook 2000, scrolling through my "recipients" list (contacts) causes the program to close unexpectedly. So, I click "new", click "to", switch to my "contacts" list, and as I scroll through the names, the program just closes. Is there a possibility that one of my contact records is corrupt? I have opened all of my contacts and saved them without an error. This problem developed shortly after the install of Office 2000's calender update, and basic security update. I have since fully u...

Workflow Rule -> Closing Activity
I set up a Manual Workflow Rule for Contacts to close out Holiday Season cards sent. The rule uses a condition to check for Contacts with cards sent and then Creates an Activity to add to each of the appropriate Contacts for future reference. What else do I need to do to close out all of activites rather than 1 at a time? Here is the workflow rule if that helps: if Contact.holidaycardlist = 1 then Letter: Send Holiday Card endif -- Dan W Systems Engineer Denver, CO ...

Auto-close Quotes when Closing Opportunity
We would like the ability to close an opportunity and have it ask if you want to close all the associated quotes. Right now, it says you can’t close the opp until you close all the open quotes and you have to each one of those one by one. Barring that, if we could select multiple quotes and click on a menu item (Close all selected quotes), that would be most useful. ---------------- This post is a suggestion for Microsoft, and Microsoft responds to the suggestions with the most votes. To vote for this suggestion, click the "I Agree" button in the message pane. If you do not ...

Data file not closed properly #3
I saw several post regarding this, but none had any answers, so I starting a new post. There is also nothing in the KB about this. Since othe people are having the same problem Microsoft should take a look at it. I get the message "The data file 'Personal Folders" was not closed properly" every time I close Outlook 2003. It runs a quick check/fix and starts up fine. I am running XP pro w/ SP-2. Outlook 2003 w/ SP-1 All patches and updates are current. My notebook was just rebuilt for so I could get a clean slate for the office 2003 install, (reformat drive and new ins...

Outlook2003 open and closed immediatly
I checked event log, nothing. And this happened when I just reboot my machine and first time tried to open Outlook, still same problem. But I found, when I double click anywhere in the Outlook Windows even it only gave me 0.5 second, then it won't close. Andy -------------------------------------------------------------- >>Look in task manager - processes, and see if multiple >>instances are running. If so, end all of them and try >>starting again. I had similar problem w/user, posted >>above. >>>>>-----Original Message----- >>>>>My O...

Outlook Closes After Closing an Email
When I click the 'X' to close an email after reading it, Outlook closes (or tries to close, but I get a warning because I have templates in my Outbox). This only seems to happen when I close a new email. I have Outlook 2003. Thank you. ...

Publish completed with errors, CRM failed
This is a multi-part message in MIME format. ------=_NextPart_000_0026_01C514DB.882B0040 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi, I have CRM 1.2 server and Database server installed in one system. All = these Days I used to add one or more attributes to CRM using deployment = manager. Now I have requirements for adding few more attributes, hence i = have added few more attributes and trying to do publish customization. I = have select Lead and then seleted target CRM server and said next then = it says "Publish completed ...

YE Closing Procedures
The year end closing procedures need to be more efficient and user friendly. For example, the payables and receivable management is date sensitive except for amounts since last close, vendor yearly summary etc. These modules should be fully date sensitive and the ability to enter into multiple years without caveats should exist. Year end is stressful enough ---------------- This post is a suggestion for Microsoft, and Microsoft responds to the suggestions with the most votes. To vote for this suggestion, click the "I Agree" button in the message pane. If you do not see the b...

Permissions / Closing MDB left open
I need to learn how to create - well, I'm not actually sure what I need to learn... Let me explain: I'm a surgical resident. I've been working on an Access MDB as a patient census - for day-to-day management including tables, queries, and forms that print based on room number or service. Everything is setup as needed in the local file. I've been working on the content of the database on and off for a year. Recently, before I can implement my project, I realized I have a very big challenge to overcome related to usage of the file. Now, to complicate my iss...

Windows Live Mail keeps Signing me In
Windows Live Mail keeps Signing me In on a PC where I removed my Hotmail email. I even un-installed live mail and deleted the left over folders. When I re-installed live mail it still signs in to my Hotmail account. I went online and changed my password and that created a new problem. Now when I try to sign into my Hotmail it makes me type in hard to read codes because windows live mail on that PC is still trying to sign in with the wrong password. How do I kill this thing? Eagle Sign in is not related to the any type of email account setup in WLM. Sign in is intended for s...

Closed account not so closed?
Hi All... I have (had) an investment account with E*Trade, which I have since closed. In MS Money 2006, I have it as "Account Is Closed", in the account list. There are a few weird things going on: 1. When I go into the account list, this account appears in gray with $0.00 next to it, but the "To Review" column has "Update in Progress" in it. This account is definately not part of my regular online updates (though when it was active, it was). 2. When I click into this account, 2 securities are listed. Neither one of them has Quantity or Cost Basis,...

how to set the size of my window?
hi, I want set the size of my window. if possible, can I change the dimensions of my window when I want? thanks. note: excuse me for my english SetWindowPos(). Red wrote: > hi, > > I want set the size of my window. > if possible, can I change the dimensions of my window when I want? > > thanks. > > note: excuse me for my english > > SetWindowPos or MoveWindow. SetWindowPos is often more convenient if you need to change only one parameter (width or height). joe On Tue, 29 Jul 2003 01:41:43 -0400, "Red" <red.zrari@sympatico.ca> w...

Maximize Windows -
OK. I've read every post about this, but cannot find an answer that fixes my problem. One day, I inadvertently expanded my taskbar that is at the bottom of the window up a notch. I was in a Publisher file at the time. It make the Publisher file shrink by the amount of space that the taskbar took up when moved up. OK. So I maximized the page and went on working. But SINCE then, everytime I open a Publisher file, it is the same size as the document before I maximized it. I have opened a document, sized it and closed it. I have opened a document, used the maximize button and close...

when closing outlook favourite files disappear
When I create a favourite file by right clicking it creates ok and appears in the favouites section. After closing and reopening outlook the file disappears from the favourites section Bummer! -- Milly Staples [MVP - Outlook] Post all replies to the group to keep the discussion intact. How to ask a question: http://support.microsoft.com/KB/555375 "ceh" <ceh@discussions.microsoft.com> wrote in message news:9C6E3908-E47D-4398-B12F-376AC9A7A8F8@microsoft.com... > When I create a favourite file by right clicking it creates ok and appears > in > the favouites sec...

Closing Excel #2
I have inherited an App desigend by an ex employee Sometimes the program leaves Excel in the task manager The programe uses various routines and calling various functions that define Excel sheets etc (badly named) I'm finding it hard to follow (my 1st experince of .NET) is there a way to KILL any Excel instence when exiting the program. I have come across some posts about GC (garbage collection) like this System.Runtime.InteropServices.Marshal.ReleaseComObject(oXLWsheet) oXLWsheet = Nothing 'System.Runtime.InteropServices.Marshal.ReleaseComObject(oXLWs) oXLWs = Nothing oBook.Clos...

Windows Mail won't allow me to sign in with correct Usr/pass
I'm having a problem connecting to my windows mail. I have it set up throught my wow account but today i had to reset my password so that i could check my email. now it will now allow me to log in i keep getting this error message The message could not be sent. The authentication setting might not be correct for your outgoing e-mail [SMTP] server. For help solving this problem, go to Help, search for "Troubleshoot Windows Mail", and read the "I'm having problems sending e-mail" section. If you need help determining the proper server settings, please c...

Messages Close When Outlook Closes
Our company has recently upgraded to Outlook 2003 from 2000. 2003 has one very annoying feature that was not present in 2000: When the main Outlook program is closed, any open messages are also closed. 2000 would allow the messages to remain open when Outlook closed. Is this change by design, by oversight or by error? Is there some hidden registry tweak to change this behavior? Heck, even Outlook Express will allow messages to remain open when the program is closed! Jerry Are you using Word as the editor? If so, they might stay open... note that Outlook 2000 didn't allow it - it ...