Compiles and runs fine with VC6, seems there are other headers now parksie.
Printable View
Compiles and runs fine with VC6, seems there are other headers now parksie.
Ok, I looked into the code now. There are some problems.
1) You must not pass NULL as szClassName. For the frame window, first call AfxRegisterWndClass and then use the returned string. For the edit control, use the Create member function instead of CreateEx and add extended styles afterwards using the ModifyStyleEx member function.
2) You basically get problems when you try to use MFC not the way it was meant. Not deriving the main window from CFrameWnd could get you into trouble.
3) I said this already, it doesn't look good to use something that looks like a type name as variable name. m_pEdit would be a far better name for your edit control.
Your last question: You can do that in your call to AfxRegisterWndClass. (BTW this function is responsible for that you can easily find out if an app is made with MFC using Spy++)
Ok i tried the ModifyStylesEx function and it doesnt seem to want to work.
This code works (I tried):
PHP Code:CWndMain::CWndMain(const char *title)
{
LPCTSTR szWndClass = AfxRegisterWndClass(NULL, AfxGetApp()->LoadCursor(IDC_ARROW), (HBRUSH) (COLOR_WINDOW + 1), AfxGetApp()->LoadIcon(IDI_APPLICATION));
CreateEx(0, szWndClass, title, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL);
}
void CWndMain::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
CEditMain = new CEdit();
CEditMain->Create(WS_VISIBLE | ES_MULTILINE | WS_VSCROLL | ES_NOHIDESEL, CRect(), this, 1);
CEditMain->ModifyStyleEx(0, WS_EX_CLIENTEDGE);
}
ChimpFace,
I've been learning MFC for a little while now and I'm curious to
know why you don't want to use AppWizard. I know you said
that you feel like you're not learning anything but in the long
run you will. The only thing about MFC is once you know the
framework it's very easy to do all the things you want to do.
The problem is that there is a TON to learn. AppWizard creates
everything for you and you're right...it's not easy to learn stuff
from the generated code unless you understand MFC. Once
you understand MFC beter you will know exactly what to do
with the generated code. I'm still unsure about a lot of things
but I'm confident with learning MFC and when I learn more and
more about it coding will be THAT much easier with AppWizard.
Why would I want to recreate all the code I already understand.
My advice from someone that is learning fairly quick.....use
AppWizard to generate your code and use the tutorials that
are made for AppWizard. When you're unsure of how something
is done learn extensively how to use the debugger and find
out where and how it is done in the framework and in conjunction
with the online help add the necessary code within your
generated code. The most important thing I learned so far from
someone that knows extensively about well almost everything
is that you want to work WITH MFC not against it. Everything is
basically done for you just need to learn how to modify it. This
is more profound than it seems.
Good luck.
Hmmm. It doesn't work (i.e. the Assertion Failure) on 5 or 7...Quote:
Originally posted by CornedBee
Compiles and runs fine with VC6, seems there are other headers now parksie.
You might be missing what I mean by it doesn't work. I class it as not working if *anything* goes wrong, not just if it's totally screwed.