www.digitalmars.com         C & C++   DMDScript  

c++.mfc - WOOOOOOOOOO IT WORKS!!!!

reply "James Kirkham" <JamesKirkham1 hotmail.com> writes:
Thank you bw, Jan and user domian.invalid!!! I finally managed to get my
basic app to compile and it works!!!!  Expect me to be coming back with more
coding problems later ;o) now I've just got to wait for my mfc tutorial book
to come from the library.  Thanks for all your time and patience!!!!

James
Oct 15 2002
parent reply "James Kirkham" <JamesKirkham1 hotmail.com> writes:
Just one little thing.....

When I run my app it opens a window (as expected) but it also opens a blank
console screen first.  Why does it do this?  Is it in the code or something
I need to workaround (i.e a compiler issue) etc?  I got the code from the
msdn site to test the compiler, so if its just something in there when I
learn mfc it wont matter.

"James Kirkham" <JamesKirkham1 hotmail.com> wrote in message
news:aoham6$2i4$1 digitaldaemon.com...
 Thank you bw, Jan and user domian.invalid!!! I finally managed to get my
 basic app to compile and it works!!!!  Expect me to be coming back with

 coding problems later ;o) now I've just got to wait for my mfc tutorial

 to come from the library.  Thanks for all your time and patience!!!!

 James

Oct 15 2002
parent reply Jan Knepper <jan smartsoft.us> writes:
I guess you might be using a wrong .def file, indicating that the program you
compile is a console program or you link command might be wrong, but that would
require a 'main' function somewhere in your code.



James Kirkham wrote:

 Just one little thing.....

 When I run my app it opens a window (as expected) but it also opens a blank
 console screen first.  Why does it do this?  Is it in the code or something
 I need to workaround (i.e a compiler issue) etc?  I got the code from the
 msdn site to test the compiler, so if its just something in there when I
 learn mfc it wont matter.

 "James Kirkham" <JamesKirkham1 hotmail.com> wrote in message
 news:aoham6$2i4$1 digitaldaemon.com...
 Thank you bw, Jan and user domian.invalid!!! I finally managed to get my
 basic app to compile and it works!!!!  Expect me to be coming back with

 coding problems later ;o) now I've just got to wait for my mfc tutorial

 to come from the library.  Thanks for all your time and patience!!!!

 James


Oct 15 2002
parent reply "James Kirkham" <JamesKirkham1 hotmail.com> writes:
Here is some info:

Command Line Compile:
c:\dm\bin\sc code.cpp -L/ENTRY:WinMainCRTStartup


My Code:
#include <afxwin.h>

#ifdef MINIMAL

// Stub out non-critical CRT initialization functions
extern "C" void _setenvp() { }
extern "C" void _setargv() { }

// Define a window class derived from CWnd
class CHelloWindow : public CWnd
{
public:
    CHelloWindow()
    {
        CreateEx(WS_EX_CLIENTEDGE,
            AfxRegisterWndClass(0, ::LoadCursor(NULL, IDC_ARROW),
(HBRUSH)(COLOR_WINDOW+1)),
            _T("Hello World!"), WS_OVERLAPPEDWINDOW,
            CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
NULL, NULL, 0);
    }
};

#else

// Define a window class derived from CFrameWnd
class CHelloWindow : public CFrameWnd
{
public:
    CHelloWindow()
        { Create(NULL, _T("Hello World!"), WS_OVERLAPPEDWINDOW,
rectDefault); }
};

#endif

// Define an application class derived from CWinApp
class CHelloApp : public CWinApp
{
public:
    virtual BOOL InitInstance()
    {
        m_pMainWnd = new CHelloWindow();
        m_pMainWnd->ShowWindow(m_nCmdShow);
        m_pMainWnd->UpdateWindow();
        return TRUE;
    }
};

CHelloApp HelloApp;  // HelloApp's constructor initializes and runs the app

"Jan Knepper" <jan smartsoft.us> wrote in message
news:3DAC660E.68565CF9 smartsoft.us...
 I guess you might be using a wrong .def file, indicating that the program

 compile is a console program or you link command might be wrong, but that

 require a 'main' function somewhere in your code.



 James Kirkham wrote:

 Just one little thing.....

 When I run my app it opens a window (as expected) but it also opens a


 console screen first.  Why does it do this?  Is it in the code or


 I need to workaround (i.e a compiler issue) etc?  I got the code from


 msdn site to test the compiler, so if its just something in there when I
 learn mfc it wont matter.

 "James Kirkham" <JamesKirkham1 hotmail.com> wrote in message
 news:aoham6$2i4$1 digitaldaemon.com...
 Thank you bw, Jan and user domian.invalid!!! I finally managed to get



 basic app to compile and it works!!!!  Expect me to be coming back



 more
 coding problems later ;o) now I've just got to wait for my mfc



 book
 to come from the library.  Thanks for all your time and patience!!!!

 James



Oct 15 2002
next sibling parent Jan Knepper <jan smartsoft.us> writes:
What about the .DEF file?



James Kirkham wrote:

 Here is some info:

 Command Line Compile:
 c:\dm\bin\sc code.cpp -L/ENTRY:WinMainCRTStartup

 My Code:
 #include <afxwin.h>

 #ifdef MINIMAL

 // Stub out non-critical CRT initialization functions
 extern "C" void _setenvp() { }
 extern "C" void _setargv() { }

 // Define a window class derived from CWnd
 class CHelloWindow : public CWnd
 {
 public:
     CHelloWindow()
     {
         CreateEx(WS_EX_CLIENTEDGE,
             AfxRegisterWndClass(0, ::LoadCursor(NULL, IDC_ARROW),
 (HBRUSH)(COLOR_WINDOW+1)),
             _T("Hello World!"), WS_OVERLAPPEDWINDOW,
             CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
 NULL, NULL, 0);
     }
 };

 #else

 // Define a window class derived from CFrameWnd
 class CHelloWindow : public CFrameWnd
 {
 public:
     CHelloWindow()
         { Create(NULL, _T("Hello World!"), WS_OVERLAPPEDWINDOW,
 rectDefault); }
 };

 #endif

 // Define an application class derived from CWinApp
 class CHelloApp : public CWinApp
 {
 public:
     virtual BOOL InitInstance()
     {
         m_pMainWnd = new CHelloWindow();
         m_pMainWnd->ShowWindow(m_nCmdShow);
         m_pMainWnd->UpdateWindow();
         return TRUE;
     }
 };

 CHelloApp HelloApp;  // HelloApp's constructor initializes and runs the app

 "Jan Knepper" <jan smartsoft.us> wrote in message
 news:3DAC660E.68565CF9 smartsoft.us...
 I guess you might be using a wrong .def file, indicating that the program

 compile is a console program or you link command might be wrong, but that

 require a 'main' function somewhere in your code.



 James Kirkham wrote:

 Just one little thing.....

 When I run my app it opens a window (as expected) but it also opens a


 console screen first.  Why does it do this?  Is it in the code or


 I need to workaround (i.e a compiler issue) etc?  I got the code from


 msdn site to test the compiler, so if its just something in there when I
 learn mfc it wont matter.

 "James Kirkham" <JamesKirkham1 hotmail.com> wrote in message
 news:aoham6$2i4$1 digitaldaemon.com...
 Thank you bw, Jan and user domian.invalid!!! I finally managed to get



 basic app to compile and it works!!!!  Expect me to be coming back



 more
 coding problems later ;o) now I've just got to wait for my mfc



 book
 to come from the library.  Thanks for all your time and patience!!!!

 James




Oct 15 2002
prev sibling parent reply Jan Knepper <jan smartsoft.us> writes:
Do not know what your problem is.
Works fine for me.
You might want to check the shell-link properties.
Jan



James Kirkham wrote:

 Here is some info:

 Command Line Compile:
 c:\dm\bin\sc code.cpp -L/ENTRY:WinMainCRTStartup

 My Code:
 #include <afxwin.h>

 #ifdef MINIMAL

 // Stub out non-critical CRT initialization functions
 extern "C" void _setenvp() { }
 extern "C" void _setargv() { }

 // Define a window class derived from CWnd
 class CHelloWindow : public CWnd
 {
 public:
     CHelloWindow()
     {
         CreateEx(WS_EX_CLIENTEDGE,
             AfxRegisterWndClass(0, ::LoadCursor(NULL, IDC_ARROW),
 (HBRUSH)(COLOR_WINDOW+1)),
             _T("Hello World!"), WS_OVERLAPPEDWINDOW,
             CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
 NULL, NULL, 0);
     }
 };

 #else

 // Define a window class derived from CFrameWnd
 class CHelloWindow : public CFrameWnd
 {
 public:
     CHelloWindow()
         { Create(NULL, _T("Hello World!"), WS_OVERLAPPEDWINDOW,
 rectDefault); }
 };

 #endif

 // Define an application class derived from CWinApp
 class CHelloApp : public CWinApp
 {
 public:
     virtual BOOL InitInstance()
     {
         m_pMainWnd = new CHelloWindow();
         m_pMainWnd->ShowWindow(m_nCmdShow);
         m_pMainWnd->UpdateWindow();
         return TRUE;
     }
 };

 CHelloApp HelloApp;  // HelloApp's constructor initializes and runs the app

 "Jan Knepper" <jan smartsoft.us> wrote in message
 news:3DAC660E.68565CF9 smartsoft.us...
 I guess you might be using a wrong .def file, indicating that the program

 compile is a console program or you link command might be wrong, but that

 require a 'main' function somewhere in your code.



 James Kirkham wrote:

 Just one little thing.....

 When I run my app it opens a window (as expected) but it also opens a


 console screen first.  Why does it do this?  Is it in the code or


 I need to workaround (i.e a compiler issue) etc?  I got the code from


 msdn site to test the compiler, so if its just something in there when I
 learn mfc it wont matter.

 "James Kirkham" <JamesKirkham1 hotmail.com> wrote in message
 news:aoham6$2i4$1 digitaldaemon.com...
 Thank you bw, Jan and user domian.invalid!!! I finally managed to get



 basic app to compile and it works!!!!  Expect me to be coming back



 more
 coding problems later ;o) now I've just got to wait for my mfc



 book
 to come from the library.  Thanks for all your time and patience!!!!

 James




Oct 15 2002
parent reply bw <bw_member pathlink.com> writes:
In article <3DAC8C67.B7E31F88 smartsoft.us>, Jan Knepper says...
 Command Line Compile:
 c:\dm\bin\sc code.cpp -L/ENTRY:WinMainCRTStartup


to kill the console window opening use a def file (EXETYPE NT) there's probably a linker switch for this too?
Oct 15 2002
parent reply bw <bw_member pathlink.com> writes:
In article <aoiehl$17pe$1 digitaldaemon.com>, bw says...
to kill the console window opening use a def file (EXETYPE NT) there's probably
a linker switch for this too?

well actually i made an assumption, cuz using /EXETYPE:NT switch to the linker does not stop the console window opening first... but SOMETHING in this .def file does. must be a combination of things? NAME BUILD32 DESCRIPTION 'MFC Win32 Application' EXETYPE NT SUBSYSTEM WINDOWS,4.0 VERSION 4.0
Oct 15 2002
next sibling parent "James Kirkham" <JamesKirkham1 hotmail.com> writes:
So I can just use this .def file to kill the console?

"bw" <bw_member pathlink.com> wrote in message
news:aoiesi$17t1$1 digitaldaemon.com...
 In article <aoiehl$17pe$1 digitaldaemon.com>, bw says...
to kill the console window opening use a def file (EXETYPE NT) there's


a linker switch for this too?

well actually i made an assumption, cuz using /EXETYPE:NT switch to the

 does not stop the console window opening first... but SOMETHING in this

 file does.  must be a combination of things?

 NAME         BUILD32
 DESCRIPTION  'MFC Win32 Application'
 EXETYPE      NT
 SUBSYSTEM    WINDOWS,4.0
 VERSION      4.0

Oct 16 2002
prev sibling next sibling parent "James Kirkham" <JamesKirkham1 hotmail.com> writes:
Yes it worked thanks bw! Whats even more amazing is I rembered how to use
the .def file ;o)

Thanks

James


"bw" <bw_member pathlink.com> wrote in message
news:aoiesi$17t1$1 digitaldaemon.com...
 In article <aoiehl$17pe$1 digitaldaemon.com>, bw says...
to kill the console window opening use a def file (EXETYPE NT) there's


a linker switch for this too?

well actually i made an assumption, cuz using /EXETYPE:NT switch to the

 does not stop the console window opening first... but SOMETHING in this

 file does.  must be a combination of things?

 NAME         BUILD32
 DESCRIPTION  'MFC Win32 Application'
 EXETYPE      NT
 SUBSYSTEM    WINDOWS,4.0
 VERSION      4.0

Oct 16 2002
prev sibling parent "Charles Sanders" <sanders-consulting comcast.net> writes:
The subsytem call.

dmc main.cpp -L/EXET:NT -L/SU:windows


"bw" <bw_member pathlink.com> wrote in message
news:aoiesi$17t1$1 digitaldaemon.com...
 In article <aoiehl$17pe$1 digitaldaemon.com>, bw says...
to kill the console window opening use a def file (EXETYPE NT) there's


a linker switch for this too?

well actually i made an assumption, cuz using /EXETYPE:NT switch to the

 does not stop the console window opening first... but SOMETHING in this

 file does.  must be a combination of things?

 NAME         BUILD32
 DESCRIPTION  'MFC Win32 Application'
 EXETYPE      NT
 SUBSYSTEM    WINDOWS,4.0
 VERSION      4.0

Nov 01 2003