|
Here's your sample program, modified to function like mine. To recap -- from the embedded child dialog, I want Button2 to hide Button1 and to call "function()" (declared in CDlg1). In the Button2 message handler:
"m_pDlg1->funtion();" yields "Dlg2.cpp(53) : error C2039: 'funtion' : is not a member of 'CDlgtestDlg'" compile-time.
"m_pDlg1->m_button1.ShowWindow(SW_HIDE);" causes a "memory could not be read" run-time crash.
Here's the code, please take a look when you have time:
dlgtestDlg.cpp
#include "stdafx.h"
#include "dlgtest.h"
#include "dlgtestDlg.h"
#include "dlg2.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
enum { IDD = IDD_ABOUTBOX };
protected:
virtual void DoDataExchange(CDataExchange* pDX);
protected:
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
END_MESSAGE_MAP()
CDlgtestDlg::CDlgtestDlg(CWnd* pParent )
: CDialog(CDlgtestDlg::IDD, pParent)
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CDlgtestDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_BUTTON1, m_button1);
}
BEGIN_MESSAGE_MAP(CDlgtestDlg, CDialog)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
END_MESSAGE_MAP()
BOOL CDlgtestDlg::OnInitDialog()
{
CDialog::OnInitDialog();
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
SetIcon(m_hIcon, TRUE);
SetIcon(m_hIcon, FALSE);
m_dlg2.Create(CDlg2::IDD, this);
CRect wRect; GetWindowRect(wRect);
m_dlg2.SetWindowPos(GetDlgItem(IDD_DLGTEST_DIALOG), wRect.left, wRect.top, 0, 0, SWP_SHOWWINDOW|SWP_NOSIZE);
return TRUE;
}
void CDlgtestDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
void CDlgtestDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this);
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
HCURSOR CDlgtestDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CDlgtestDlg::function()
{
AfxMessageBox("Generic function called.");
}
dlgtestDlg.h
#if !defined(AFX_DLGTESTDLG_H__B42E61F1_E754_4EAD_B51A_EF1DC2AE9DA8__INCLUDED_)
#define AFX_DLGTESTDLG_H__B42E61F1_E754_4EAD_B51A_EF1DC2AE9DA8__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "Dlg2.h"
class CDlgtestDlg : public CDialog
{
public:
CDlgtestDlg(CWnd* pParent = NULL);
CDlg2 m_dlg2;
void function();
enum { IDD = IDD_DLGTEST_DIALOG };
CButton m_button1;
protected:
virtual void DoDataExchange(CDataExchange* pDX);
protected:
HICON m_hIcon;
virtual BOOL OnInitDialog();
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
DECLARE_MESSAGE_MAP()
};
#endif // !defined(AFX_DLGTESTDLG_H__B42E61F1_E754_4EAD_B51A_EF1DC2AE9DA8__INCLUDED_)
Dlg2.cpp
#include "stdafx.h"
#include "dlgtest.h"
#include "Dlg2.h"
#include "DlgtestDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
CDlg2::CDlg2(CWnd* pParent )
: CDialog(CDlg2::IDD, pParent)
{
}
CDlg2::CDlg2(CDlgtestDlg* pDlg, CWnd* pParent )
:CDialog(CDlg2::IDD,pParent)
{
m_pDlg1 = 0;
m_pDlg1 = pDlg;
}
void CDlg2::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CDlg2, CDialog)
ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
END_MESSAGE_MAP()
void CDlg2::OnButton2()
{
}
Dlg2.h
#if !defined(AFX_DLG2_H__11E9112B_9C78_4698_9C02_403F39EEE0FA__INCLUDED_)
#define AFX_DLG2_H__11E9112B_9C78_4698_9C02_403F39EEE0FA__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class CDlgtestDlg;
class CDlg2 : public CDialog
{
public:
CDlg2(CWnd* pParent = NULL);
CDlg2(CDlgtestDlg* pDlg, CWnd* pParent = NULL);
enum { IDD = IDD_DIALOG1 };
CDlgtestDlg* m_pDlg1;
protected:
virtual void DoDataExchange(CDataExchange* pDX);
protected:
afx_msg void OnButton2();
DECLARE_MESSAGE_MAP()
};
#endif // !defined(AFX_DLG2_H__11E9112B_9C78_4698_9C02_403F39EEE0FA__INCLUDED_)
|
|
|
|
|
As in my previous post I'm working on an MDI project with two document types. Both have been registered in the CMultiDocTemplate successfully and can have new instances opened.
I've read an article by Roger Allen
http://www.codeproject.com/useritems/DocViewEnhancements.asp
which suggests deriving from the CDocManager class in order to be able to instantiate documents of a specfic type dynamically, but I'd rather avoid this.
Can anyone suggest another method by which I can take data from one copy of one document type & use it to instantiate two copies of another document type??
Sorry for the wordiness of the last bit :/ ....
Thanks in advance for any suggestions. I've hunted around but this area of the document/view architecture seems to be little documented
Dave
|
|
|
|
|
If you call OpenDocumentFile(NULL) on the document templates for the new document types, this will return CDocument* object to you. You can then cast these pointers to the correct document types and use an overridden operator=(COtherDocType&) function to copy the data across.
Something like this:
void CDoc1Type::CreateCopies()
{
CDocTemplate *pDocTemplate = ?;
CDoc2Type *pDoc2 = static_cast<CDoc2Type>(pDocTemplate->OpenDocumentFile(NULL));
*pDoc2 = this;
...
}
const CDoc2Type& CDoc2Type::Operator=(const CDoc1Type& doc1)
{
}
The coed and the idea is a bit rough. Hopefully it makes sense!
Roger Allen - Sonork 100.10016
Roger Wright: Remember to buckle up, please, and encourage your friends to do the same. It's not just about saving your life, but saving the quality of life for those you may leave behind...
|
|
|
|
|
Hi,
This is my first proper MFC app so please bear with me a little, I've got a feeling I have overcomplicated things for myself :/.
I've presently got one document type which maintains a frame grabber, two cameras and their capture (all in one instance) and another type for DIBs. These are intended as the result of any image processing carried out & will have multiple instances.....
As soon as I write this I see the error of my ways I should just have the main frame own & control the cameras then pass the captured pixel-array to any DIB documents from there.
Shouldn't this simplify maintaining my data? as I'll only ever need the one document type, or is it just as complicated to associate data owned by the main frame with a CView and CMDIChildWnd? (without an accompanying document)
Thanks for the prompt reply btw, if nothing else I'm a little more educated on the workings of the DocManager & DocTemplates
Dave
|
|
|
|
|
Hi,
When I try to debug a program with microsoft visual studio and use the "step into" command, it gets into library functions (like for example the function "new") and asks me for the path, while I would like of course to debug only the functions I wrote and that are part of the project.
How can I avoid this?
Thank you
Alex
|
|
|
|
|
|
Simple: Don't "Step In". Use "Step Over".
|
|
|
|
|
It's not so simple. If I have something like this:
ptr = new Myclass();
I want to get into the constructor of Myclass and see what happens, I don't want to debug the code of "new". If I use "step over" I don't see what happens inside the constructor.
Anyway, the Borland 4.52 worked differently. By the way, I tried to run it on windows 2000 and it tells me it cannot find the 32 bit compiler (I set the path). Any idea what's wrong?
Alex
|
|
|
|
|
cnd12001 wrote:
I don't want to debug the code of "new". If I use "step over" I don't see what happens inside the constructor.
Put a breakpoint inside the constructor. Duh.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
I was about to write "put the breakpoint in the constructor" but you beat me too it.
Programmers often forget that "contruction" involves more than just calling MyObject::MyObject() . Stepping into new MyObject() may take you to any number of places before you get to the object constructor. If one isn't careful, clean, and clear on this you can introduce bugs through side effects.
Instead of second guessing the runtime, just put break points on the parts you want to inspect.
|
|
|
|
|
|
Hi People!
I’m trying to start an Anti-spam community project. The general purpose of it is to protect and prevent spam from getting in side of users mailboxes; also I want to be able to trace an original spammer, so it can be punished in one way or in another. If things will work out I also would want to change the identification methods for POP/SMTP science I found that most of the email servers have no identification for sending mail (so you can send spam from any user account on the server, and stay undetected)
So if any of you would like to help me please email me or send a post to this treat, thanks.
Also send any ideas if you have!
Alex,
tech@lrcommunications.net
|
|
|
|
|
tempgp wrote:
I also would want to change the identification methods for POP/SMTP science I found that most of the email servers have no identification for sending mail (so you can send spam from any user account on the server, and stay undetected)
This must be solved, if the server cannot identify itself during the mime transfer then refuse the mime.
Yeah its a good idea....
|
|
|
|
|
Is it a server id?
I don’t think so; it is more user identification process for access… If the server is on MS Server OS w/ Exchange than you can just use firewall like ISA to block any one who is not on AD…
|
|
|
|
|
tempgp wrote:
The general purpose of it is to protect and prevent spam from getting in side of users mailboxes;
As long as there are users of computers, this is an impossible task. Spammers use social engineering to help spread their germs.
tempgp wrote:
also I want to be able to trace an original spammer, so it can be punished in one way or in another.
If it was as simple as creating a project, the folks at FTC would have already "been there, done that."
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Yes, and they can, one thing thay have to think diferently....
If you update the protocols so you can trace the location, than you can go after Spammers, that will reduce spamming ....
|
|
|
|
|
tempgp wrote:
If you update the protocols...
While this is being worked on, there is no guarantee that it will be implemented. You cannot foce computers to be upgraded. It's up to the owner/administrator as to what gets updated/patched and what does not.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
And If microsoft will release this update?
+ Other big companies?
|
|
|
|
|
I spent a week at Microsoft HQ a few years back, talking with some folks in the development and research departments. Out of all that was talked about, what I remember most was what was said about Microsoft's product output. It was said that 90% of the projects presented to Microsoft are terminated very early on (i.e., they only bother creating 10% of all the ideas they receive). Some of them are scraped at the concept stage while others might make it to the early development stage. When asked why, they responded that it costs very little money to determine if a product is worthwhile or not, whereas once a product goes into development, the costs start going up quickly. They would rather spend a few million up front shooting holes in a concept rather than 10 times that later on supporting a product that was not well received. I said all that to say, you'd have to present Microsoft with a very solid case if you wanted them to release it. They already have an initiative in place that pays a reward if certain virus-writers are caught, so the desire to thwart spammers can't be too far off.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Yes, too pruve the MS that the project is woth it you just have to have some expiriense in top level presentations, or wight phone numbers
My intend to make people afraid of sanding SPAM because FBI can go after them....
Also as I alredy mentioned I can get large companies to cooperate, so I just need people who just want to do it, like for idea and not for money
(Well, yes i can say that because I have a lot of free time and...)
|
|
|
|
|
Hi,
I'm new at C++, and am taking over a Visual C++/MFC app. My first assignment involves parsing a data file and creating a graph. Once created i need to interact with the graphdata - for calibration/zoom/etc.
I was wondering where i could find resources on graphing in VC++.
Any suggestions would be greatly appreciated.
Cheers,
Mike
|
|
|
|
|
|
If you'd like to use an inexpensive, royalty-free commercial product, I recommend Lassalle's AddFlow OCX[^]. We've been using it for a while without any problems.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
I am using MFC with Visual Studio 2003. Is there a way to retrieve all of the written data off of a CD, and save it as a file? I don't know weather or not copy protection is going to be an issue, and I am assuming that this is not going to be an easy thing to do, so any help at all is appreciated
-Dev578
|
|
|
|
|
I am trying to run a Dialog based application on different machines(desktop and a laptop) , both having different display settings . I develop in the Desktop and when i run this app on the laptop I am unable to display all components . How do I make my Dialog adjust to this ? I need to do this both for the main Dialog and all the subcomponents too . Please help
|
|
|
|