|
Hey, I have been programming c++ for 4-5 years now (my real love is Java), but I am trying to make an mfc project (VS 2005) for the first time.
I went through the wizard and then made some extra dialog boxes making sure to name all of the compnents(dropdown boxes, textboxes, etc). Now I am trying to connect the dialog boxes and I am having some problems.
I have tried looking at some tutorials online, but am still having some problems.
I am trying to create a dialog box (Main_DIALOG) when "ok" is clicked on in the orginal box (LogOn_DIALOG).
Here is what I have now:
I know this is a lot of code to look at, but I really don't know where the problem is. The wizard wrrote most of the code and I am freaking hating that.
-----------------------------------------------------------
#pragma once
class CMyLogOnDialog : public CDialog
{
DECLARE_DYNAMIC(CMyLogOnDialog)
public:
CMyLogOnDialog(CWnd* pParent = NULL);
virtual ~CMyLogOnDialog();
enum { IDD = LogOn_DIALOG };
protected:
virtual void DoDataExchange(CDataExchange* pDX);
DECLARE_MESSAGE_MAP()
public:
afx_msg void OnBnClickedButton();
};
----------------------------------------
#pragma once
class CMyMainDialog : public CDialog
{
DECLARE_DYNAMIC(CMyMainDialog)
public:
CMyMainDialog(CWnd* pParent = NULL);
virtual ~CMyMainDialog();
enum { IDD = Main_DIALOG };
protected:
virtual void DoDataExchange(CDataExchange* pDX);
DECLARE_MESSAGE_MAP()
};
-------------------------------------------------
#include "stdafx.h"
#include "ECO.h"
#include "MyLogOnDialog.h"
#include "MyMainDialog.h"
IMPLEMENT_DYNAMIC(CMyLogOnDialog, CDialog)
CMyLogOnDialog::CMyLogOnDialog(CWnd* pParent )
: CDialog(CMyLogOnDialog::IDD, pParent)
{
}
CMyLogOnDialog::~CMyLogOnDialog()
{
}
void CMyLogOnDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CMyLogOnDialog, CDialog)
ON_BN_CLICKED(LogOnOK_Button, &CMyLogOnDialog::OnBnClickedButton)
END_MESSAGE_MAP()
void CMyLogOnDialog::OnBnClickedButton()
{
CMyMainDialog dlg;
dlg.DoModal();
}
----------------------------------------------
#include "stdafx.h"
#include "ECO.h"
#include "MyMainDialog.h"
IMPLEMENT_DYNAMIC(CMyMainDialog, CDialog)
CMyMainDialog::CMyMainDialog(CWnd* pParent )
: CDialog(CMyMainDialog::IDD, pParent)
{
}
CMyMainDialog::~CMyMainDialog()
{
}
void CMyMainDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CMyMainDialog, CDialog)
END_MESSAGE_MAP()
----------------------------------------------------
I don't get any error messages, but my second window doesn't popup. Did I put my action handler in the wrong class? Or am I just totally off here?
I am sorry for asking such a stupid question, but I am really just not getting it which is weird considering how fast I picked up c++ and Java (witout any wizards).
Feeling Stupid,
Brandy
|
|
|
|
|
Don't be discouraged by the wizards. They are a great help once you understand what they are doing for you (this is where most people get choked up with MFC, and why they think it is a horrible library ... it is actually quite good if you understand what is under the hood).
Now, looking at your code, nothing glaring stands out (other than not making your dialog IDs all caps and not checking the return value of DoModal ... but I can forgive those
Open the "Main" dialog in the resource editor and make sure that the dialog's settings match that of your "Log in" dialog (basically, you want it to be a popup with a frame).
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
I am not sure where the problem lies still, but I found other problems as well.
I tried just to see if I could get the text out of the Password textbox stored as C_Password, defined in the file ECODlg.h. I included ECODlg.h, but when I tried this code:
void CMyLogOnDialog::OnBnClickedButton()
{
CString password;
c_Password.getWindowText(password);
CMyMainDialog dlg;
dlg.DoModal();
}
it will not compile. I get the error:
error C2065: 'c_Password' : undeclared identifier
|
|
|
|
|
whats type c_Password?
whitesky
|
|
|
|
|
It is a CEdit.
I copied all of the dialogboxes over to a new project and started rewritting all of the actionhandlers and for some reason it works now.?
|
|
|
|
|
Could it be case sensitivity?
You mentioned a C _Password textbox:
aei_totten wrote: C_Password, defined in the file ECODlg.h
But your code has a lower case c _Password:
aei_totten wrote: c_Password.getWindowText(password);
----------
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them.
- Laurence J. Peters
|
|
|
|
|
If you are still having problems displaying your main dialog, change the DoModal call to the following:
int result = mainDlg.DoModal();
And place a breakpoint on that line. If you get to the breakpoint, then check the return value for DoModal. If you don't get to it, it means your message map isn't set properly (check the ID for your button and make sure you have correctly mapped the handler for it).
As far as this new problem ... I'm assuming you have an Edit Box on the dialog and that you set its password property (e.g. show up as *'s). Make sure the c_Password variable (which I'm assuming is the edit control) is a member of your CMyLogOnDialog class (you will see a declaration like: CEdit c_Password; in its header file). Additionally, the DoDataExchange method should have a DDX_Control call with the ID for that edit control and the c_Password variable as parameters.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Is your message handler, OnBnClickedButton, called when you click the button?
Put a breakpoint there and see if your app breaks.
Your message map looks strange to me, but I haven't done VS2005 yet so I don't know what kind of spells the wizard does. Have you edited the message map yourself?
I would like to the following in the message map:
ON_BN_CLICKED( IDC_LOGON_BUTTON, OnBnClickedButton )
where IDC_LOGON_BUTTON is the resource ID of the button and OnBnClickedButton is the function pointer to the message handler.
--
Roger
It's supposed to be hard, otherwise anybody could do it!
Regarding CodeProject: "resistance is pointless; you will be assimilated"
|
|
|
|
|
Hi, everybody
I need a POP3 server code in C or C++. Could you please suggest me where I can find such code?
Thanks in advance
--
======
Arman
|
|
|
|
|
Hi,
I request u to kindly ans :
"How to place an edit box and dialog box on a window(SDI)in VC++ dot Net".
Thank you very much.
|
|
|
|
|
|
I would like to have a control (a list) to always be the full length of the application screen, no matter what size the app is. Is there an easy way to have the control resize based on what size the user's resolution is?
thanks in advance.
|
|
|
|
|
You can always use the GetSystemMetrics API with the Screen Width and Height values and do some math to size your control properly (I assume you don't want the control to take up the entire screen). Something like the following:
<br />
const int ScreenWidth = ::GetSystemMetrics(SM_CXSCREEN);<br />
const int ScreenHeight = ::GetSystemMetrics(SM_CYSCREEN);<br />
<br />
CRect ControlRect;<br />
ControlRect.top = 100;
ControlRect.left = 50;
ControlRect.right = ControlRect.left + 300;
ControlRect.bottom = ScreenHeight - 50;
<br />
wndMyControl.MoveWindow(&ControlRect, TRUE);<br />
If you wanted the control on the right side, use the width variable and subtract the desired value from the starting place (and adjust your left value accordingly).
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
I suggest use Zac Howland answer and also you can use WM_SIZE with this code
for example if your window has WS_THICKFRAME or...
whitesky
|
|
|
|
|
hi
check out this article "http://www.codeproject.com/dialog/layoutmgr.asp"
hope u will find it useful...
There are two ways of meeting difficulties :you alter the difficulties, or u alter yourself to meet them(Phyllis Bottome).
regards
harilal
|
|
|
|
|
hi
How can i read the physical memory from a perticular address
in windows 98.
thanx
nirmal
|
|
|
|
|
|
|
aaaan wrote: How can i read the physical memory from a perticular address in windows 98.
Although Chris has answered your question I'd still like to know why and what you think you will find on that address.
Generally you have no idea where the memory manager has mapped things.
Even if you're trying memory mapped I/O, this will only have a chance to work on a toy-OS as Win98.
Later OS-versions requires a driver executing in kernel mode (Ring 0) to get access to such stuff.
--
Roger
It's supposed to be hard, otherwise anybody could do it!
Regarding CodeProject: "resistance is pointless; you will be assimilated"
|
|
|
|
|
Roger Stoltz wrote: what you think you will find on that address.
Generally you have no idea where the memory manager has mapped things.
that's why i didn't answer directly but asked some questions instead...
TOXCCT >>> GEII power
[VisualCalc 3.0 updated ][Flags Beginner's Guide new! ]
|
|
|
|
|
Yup, I know why you asked the questions you did, tox... I know you know what you're doing/knowing.
I just wanted the guy to start asking himself questions about where he's heading.
We might still learn something...
It's supposed to be hard, otherwise anybody could do it!
Regarding CodeProject: "resistance is pointless; you will be assimilated"
|
|
|
|
|
hi
actually i want to read the memory area from 0x0000F000 to 0xFFFFFFFF in RAM,
where the smbios information are stored.
its urgent ,i need this.Can any body help me please?
Thanx.
nirmal
|
|
|
|
|
Have a look at this[^] great article from Anton Bassov.
I found it searching for "physical address" at our favourite site: CodeProject!
However, I suspect since you're asking this kind of questions and are in a hurry, you don't really have the time to read and understand the article. Do it anyway! Tampering with the stuff Anton describes in his article can easily destroy things beyond repair.
Good luck!
--
Roger
It's supposed to be hard, otherwise anybody could do it!
Regarding CodeProject: "resistance is pointless; you will be assimilated"
|
|
|
|
|
Thanx Roger
this article only for windows nt based,
but i need it to work in windows 95,98,ME.
Can u help me more.
thanx
nirmal
|
|
|
|
|
aaaan wrote: Can u help me more
Nope. Since I haven't done this myself, at least not yet, I cannot tell you what to do.
I directed you to an article that has got something do to with it, but it not be suitable for your situation since apparently you'll need it working on old toy-OSs.
Why not use a later version the OS, at least Win2k. Then it would be a something that would last instead of something very temporarely.
If Win95 is the only option I suggest you use Google to find an article that Matt Pietrek has written about this since Anton claims that Matt Pietrek "has done this for Win95 many years ago".
--
Roger
It's supposed to be hard, otherwise anybody could do it!
Regarding CodeProject: "resistance is pointless; you will be assimilated"
|
|
|
|