15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


RE:

Dean McCrory -- deanm@microsoft.com
Saturday, September 02, 1995

The most common cause of this is forgetting to initialize the 'length' 
member of 'WINDOWPLACEMENT'.

	myWINDOWPLACEMENT.length = sizeof(WINDOWPLACEMENT);
	GetDlgItem(i)->GetWindowPlacement(&myWINDOWPLACEMENT);

If you link your app with "/subsystem:windows,4.0", Windows will do 
extra checking and will fail the call if the length is not initialized 
correctly.  The default for the linker was changed from 3.1 -> 4.0 in 
vc++2.1, so that explains why you see the difference between vc++2.0 and 2.2.

Hope that helps,

// Dean





Steven Perry -- SPerry@msn.com
Friday, September 08, 1995

You need to create an instance of the document class.  Your creating the view 
with no document class associated with it.

Get the template pointer for 
the document class and call OpenDocumentFile().  This will return to you a 
Document pointer as well as create the view associated with the document.  
When your done with the document you can call OnCloseDocument() to destroy 
it.

To find the document template you can do the following.

	POSITION 
rPos;
	CDocTemplate* pTemplate;

	rPos = 
pApp->m_templateList.GetHeadPosition();
	while( rPos != NULL )
	{
		
pTemplate = (CDocTemplate*)pApp->m_templateList.GetNext( rPos );
		ASSERT( 
pTemplate != NULL );
		if( pTemplate->IsKindOf( RUNTIME_CLASS( CDocTemplate 
) ) )
		{
			CString strTypeName;
			if(	pTemplate->GetDocString( 
strTypeName, CDocTemplate::fileNewName) && 
					!strTypeName.IsEmpty() )
		
	{
				if( strTypeName.Compare( "Name of Document In IDR String" ) == 0 )
		
		{
					m_pDocTemp = pTemplate;
					break;
				}
			}
		}
	}

I 
hope this helps.

Steven Perry
SPerry@msn.com


----------
From:  
owner-mfc-l@netcom.com on behalf of Reza Razavipour
Sent:  Thursday, 
September 07, 1995 6:19 PM
To:  MFC-L@netcom.com

I am working on a 
project in which, so far, I have two pairs of Doc/View.


In 
App::InitInstance
{
...
	CMultiDocTemplate* dbSystemDocTemplate = new 
CMultiDocTemplate(
		IDR_DatabaseMenu,
		RUNTIME_CLASS(CBSystemDoc),
		
RUNTIME_CLASS(CMDIChildWnd), // custom MDI child frame
		
RUNTIME_CLASS(CBSystemView));
	AddDocTemplate(dbSystemDocTemplate);

	
GpointDocTemplate = new CMultiDocTemplate(
		IDR_NCM071TYPE,
		
RUNTIME_CLASS(CPtDoc),
		RUNTIME_CLASS(CChildFrame), // custom MDI child 
frame
		RUNTIME_CLASS(CPtVw));

	GPtTrDocTemplate = new CMultiDocTemplate(

		IDD_PointDefTree,
		RUNTIME_CLASS(CPtDoc),
		RUNTIME_CLASS(CChildFrame), 
// custom MDI child frame
		RUNTIME_CLASS(CPtTrVw));
...
}

CBSystemView 
is a subclass of CFormView, on this view I have a button, that
when pressed 
I want to create a frame and attach a CPtDoc and two views, 
CPtVw and 
CPtTrVw( I have a splitter window).

The following is how I do it.

When 
the ADD button on the CBSystemView is pressed:

{...
CPtDoc *ptDoc = new 
CPtDoc;
CFrameWnd *frame = GPtTrDocTemplate->CreateNewFrame(
															
							(CDocument *) ptDoc, NULL);

GPtTrDocTemplate->InitialUpdateFrame(frame, (CDocument *) ptDoc, TRUE);
...}


So far all is good and well. I dont think I am doing too many mistakes 
yet.

If I dont call 
frWnd->SetActiveView(view); before the 
InitialUpdateFrame and I try to call
CPtTrVw::InitialUpdate
{...
CPtDoc 
*ptDoc = (CPtDoc *) ((CMainFrame *) 
AfxGetApp()->m_pMainWnd)->GetActiveDocument();

...}
ptDoc is NULL;

If 
I do call
frWnd->SetActiveView(view); before the InitialUpdateFrame and I 
lose focus from this doc,
frame title is blanked out, and when I set it 
active again, it is still blank.

In all the examples I have seen, it has 
not been many, no one calls SetActiveView.

What am I doing wrong? The 
first CDocTemplate first perfectly but not the second one.

Any help is 
highly appreciated.

Reza.

	






Steven Perry -- /O=MICROAPP/OU=LINDENHURST/CN=RECIPIENTS/CN=SPERRY@upsmot02.msn.com
Tuesday, September 26, 1995

Try this.

void CTestView::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) 

{
	CWnd * pWnd = AfxGetMainWnd();
	if( pWnd != NULL )
		pWnd->FlashWindow( 
TRUE );
	CView::OnChar( nChar, nRepCnt, nFlags );
}

or
void 
CTestView::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) 
{
	
AfxGetMainWnd()->FlashWindow( TRUE );
	CView::OnChar( nChar, nRepCnt, nFlags 
);
}

Steven Perry


----------
From: 	owner-mfc-l@netcom.com on 
behalf of MIKE  
Sent: 	Thursday, September 21, 1995 10:12 AM
To: 	
'mfc-l@netcom.com'

Why doesn't this window flash?  

void 
CTestView::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) 
{
	CFrameWnd * 
pWnd = (CFrameWnd *)AfxGetApp()->m_pMainWnd;
	pWnd->FlashWindow(TRUE);
	
CView::OnChar(nChar, nRepCnt, nFlags);
}







Mike Blaszczak -- mikeblas@interserv.com
Sunday, October 08, 1995

Shiva Shenoy  wrote:

 > Try doing 
 >    ::SendMessage(AfxGetApp()->m_pMainWnd->m_hWnd, 
 >                 WM_SETMESSAGESTRING,0, (LONG)lpcStr);

As a point of style, you should more safely code:

   ASSERT(AfxGetApp()->m_pMainWnd != NULL);
   AfxGetApp()->m_pMainWnd->SendMessage(WM_SETMESSAGESTRING,
	0, (LONG) lpcStr);

.B ekiM



LeRoy Baxter -- lbaxter@cinfo.com
Wednesday, October 18, 1995

Perhaps you need to draw on response to OnActivate() ?

----------
From: 	Chris Marshall[SMTP:cmarshall@swallow.com]
Sent: 	Thursday, October 12, 1995 6:22 AM
To: 	mfc-l@netcom.com

Hi,

I am trying to create a Property Page for an application which has a series
of OwnerDraw buttons which allow me to change the colour (ala the
CColorPage from OLE CDK).  I have created a page and the buttons.  The
following os the CPP file for the actual page.  The problem that I am
having is that nothing is displayed on the screen.  If I step through the
code then first time round it will execute the code within the  however after that it always fails the check.

Any suggestions would be welcome.

Cheers
Chris
Home Mail Address: chrism@marshes.demon.co.uk
Work Mail Address: chrism@swallow.com

 ---Code Segment---
// colpage.cpp : implementation file
//

#include "stdafx.h"
#include "FormDesigner.h"
#include "colpage.h"

#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif

////////////////////////////////////////////////////////////////////////////
/
// CColourPage property page

IMPLEMENT_DYNCREATE(CColourPage, CPropertyPage)

CColourPage::CColourPage() : CPropertyPage(CColourPage::IDD)
{
	//{{AFX_DATA_INIT(CColourPage)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}

CColourPage::~CColourPage()
{
}

void CColourPage::DoDataExchange(CDataExchange* pDX)
{
	CPropertyPage::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CColourPage)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CColourPage, CPropertyPage)
	//{{AFX_MSG_MAP(CColourPage)
	ON_WM_DRAWITEM()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()


////////////////////////////////////////////////////////////////////////////
/
// CColourPage message handlers

BOOL CColourPage::OnInitDialog()
{
	CPropertyPage::OnInitDialog();
	
	// TODO: Add extra initialization here
	
	return TRUE;
}

void CColourPage::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct)
{
	CBrush bshBack;
	CPen penBorder;
	CPen* pOldPen;
	CDC* pDC;
	BOOL bSuccess;
	
	penBorder.CreatePen(PS_SOLID,1,RGB(0,0,0));
	switch(nIDCtl) {
		case IDC_COL_ONE:
			bSuccess = bshBack.CreateSolidBrush(RGB(0,0,0));
			break;

		case IDC_COL_TWO:
			bSuccess = bshBack.CreateSolidBrush(RGB(0,0,0));
			break;

		case IDC_COL_THREE:
			bSuccess = bshBack.CreateSolidBrush(RGB(0,0,0));
			break;

		case IDC_COL_FOUR:
			bSuccess = bshBack.CreateSolidBrush(RGB(0,0,0));
			break;

		case IDC_COL_FIVE:
			bSuccess = bshBack.CreateSolidBrush(RGB(0,0,0));
			break;

		case IDC_COL_SIX:
			bSuccess = bshBack.CreateSolidBrush(RGB(0,0,0));
			break;

		case IDC_COL_SEVEN:
			bSuccess = bshBack.CreateSolidBrush(RGB(0,0,0));
			break;

		case IDC_COL_EIGHT:
			bSuccess = bshBack.CreateSolidBrush(RGB(0,0,0));
			break;

		case IDC_COL_NINE:
			bSuccess = bshBack.CreateSolidBrush(RGB(0,0,0));
			break;

		case IDC_COL_TEN:
			bSuccess = bshBack.CreateSolidBrush(RGB(0,0,0));
			break;

		case IDC_COL_ELEVEN:
			bSuccess = bshBack.CreateSolidBrush(RGB(0,0,0));
			break;

		case IDC_COL_TWELVE:
			bSuccess = bshBack.CreateSolidBrush(RGB(0,0,0));
			break;

		case IDC_COL_THIRTEEN:
			bSuccess = bshBack.CreateSolidBrush(RGB(0,0,0));
			break;

		case IDC_COL_FOURTEEN:
			bSuccess = bshBack.CreateSolidBrush(RGB(0,0,0));
			break;

		case IDC_COL_FIFTEEN:
			bSuccess = bshBack.CreateSolidBrush(RGB(0,0,0));
			break;

		case IDC_COL_SIXTEEN:
			bSuccess = bshBack.CreateSolidBrush(RGB(0,0,0));
			break;

		default:
			break;
	}
	pDC->FromHandle(lpDrawItemStruct->hDC);
	if (pDC != NULL) {
		if (bSuccess) {
			pOldPen = pDC->SelectObject(&penBorder);
			pDC->FillRect(&lpDrawItemStruct->rcItem ,&bshBack);
			pDC->SelectObject(pOldPen);
		}
	}
	pDC->DeleteTempMap();

//	CPropertyPage::OnDrawItem(nIDCtl, lpDrawItemStruct);
}







Steven Youngs -- steve@ncgrafix.demon.co.uk
Wednesday, October 18, 1995

On 12 Oct 95 at 13:22, Chris Marshall wrote:

> Hi,
> 
> I am trying to create a Property Page for an application which has a
> series of OwnerDraw buttons which allow me to change the colour (ala
> the CColorPage from OLE CDK).  I have created a page and the
> buttons.  The following os the CPP file for the actual page.  The
> problem that I am having is that nothing is displayed on the screen.
>  If I step through the code then first time round it will execute
> the code within the  however after that it
> always fails the check.
> 
> Any suggestions would be welcome.
> 
> Cheers
> Chris
> Home Mail Address: chrism@marshes.demon.co.uk
> Work Mail Address: chrism@swallow.com
> 

> void CColourPage::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT
> lpDrawItemStruct) {

[snip]

>  CDC* pDC;

[snip]

>  pDC->FromHandle(lpDrawItemStruct->hDC);
>  if (pDC != NULL) {
>   if (bSuccess) {
>    pOldPen = pDC->SelectObject(&penBorder);
>    pDC->FillRect(&lpDrawItemStruct->rcItem ,&bshBack);
>    pDC->SelectObject(pOldPen);
>   }
>  }
>  pDC->DeleteTempMap();
> 
> //	CPropertyPage::OnDrawItem(nIDCtl, lpDrawItemStruct);
> }
> 

Chris,
  You have created a variable "pDC" which is a *pointer* to a CDC 
class. However you then do

  pDC->FromHandle(lpDrawItemStruct->hDC);

instead of

  pDC = CDC::FromHandle(lpDrawItemStruct->hDC);

Normally, this would give a runtime error in the situations where pDC 
was NULL however since CDC::FromHandle is a static member 
function of the class CDC you do not even get this.

Hope this helps you.

Cheers,
Steve.

----------------------------
Steven Youngs
NC Graphics (Cambridge) Ltd.



Chris Krahe -- ckrahe@clark.net
Tuesday, January 09, 1996

At 03:03 PM 1/8/1996 -0500, Madhu wrote:
>I have started writing user interface to ACCESS data base using
>Database classes of MFC(Visual C++ 1.51).
>I have a problem with the CTime class.
>When the dates stored in the database are earlier than (1-1-1970)
>the CTime class fetches a date of 12-31-1969. When I want save
>a date, CTime class returns an exception error if the date is earlier than
>1-1-1970. From the MFC source, I have ound that the CTime class
>does not accept the dates earlier than 1-1-1970. Can anyone give me
>some suggestions. 

We use a CString on our clients to hold dates, changing the RFX function to
use the convert function available on our SQL Server.  Not pretty, but it
works for us for now.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Chris Krahe, ckrahe@clark.net
  http://www.clark.net/pub/ckrahe
  http://www.kcm-inc.com (my employer)
 "A car does not the driver make", cpk`88
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~





| Вернуться в корень Архива |