Re: console in mfc

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Scott McPhillips [MVP] (scottmcp_at_mvps.org.nothere)
Date: 06/08/04


Date: Tue, 08 Jun 2004 00:40:42 -0500

francis wrote:
> what i'm trying do do here is to integrate a .c file into an mfc environment. my expected output is when i click a button; a console window would appear that would print HELLO WORLD. I'm a newbie at this, and i might ask questions that may seem trivial to the experienced so please be patient with me..:) i'm doing this so that i could get a hang of calling .c functions in mfc.
>
> this is the .c and .h file that i am trying to use.
>
> hello.h
> ------------
> #if defined(__cplusplus)
> extern "C" {
> #endif
>
> void Hello();
>
> #if defined(__cplusplus)
> }
> #endif
>
> hello.c
> ----------------------
> #include <stdio.h>
> #include <stdlib.h>
> #include <conio.h>
> #include "hello.h"
>
>
> void Hello()
> {
> char c;
>
> printf("HELLO WORLD!!!");
>
> c = getch();
> }
>
> i have encountered error such as c1853 and c1010 and i resolved both this problems by making my .c file not use precomp headings and then doing a rebuild all. the erors were gone but the program still wouldn't work. I added the the function Hello(); on the BN_CLICKED part of the code and i include the hello.h. What is it that i am missing? I was told by the people here that it would work after the rebuild? i'm confused....
>
>
>

Programs that use windows for user interaction do not have a console
output. printf goes nowhere. You can build a console program, or you
can build a windowed program. It is even possible to add a console
window to a windowed program. But that is an unusual combination and
probably not a good learning exercise.

-- 
Scott McPhillips [VC++ MVP]


Relevant Pages

  • [Full-Disclosure] Shatter XP
    ... introduces several new messages for the windows button control: ... - inject shellcode to known location ... void doWrite; ... printf("+ Couldn't Find %s Window\n",tWindow); ...
    (Full-Disclosure)
  • Re: CreateProcessAsUser - Process starts then exits
    ... Windows XP Media Center ... public Int32 dwX; ... public IntPtr lpReserved2; ... parent's console. ...
    (microsoft.public.win32.programmer.kernel)
  • Re: CreateProcessAsUser - Process starts then exits
    ... service most likely runs in a separate invisible session. ... the program I was trying to start was a windows forms app I ... public IntPtr lpReserved2; ... parent's console. ...
    (microsoft.public.win32.programmer.kernel)
  • Novell Client login form enables reading and writing from and to the clipboard of the logged-in
    ... Novell Client for Windows, ... Anyone with access to the computer's local operating system console, ... inject its own textual content into the clipboard of the currently logged-in ...
    (Bugtraq)
  • Re: Cannot Correctly Preview Fax in Fax Console
    ... I no way do I doubt what you are saying, but until now, all known problems with previewing faxes have had one of two causes: incorrect file associations for TIF files or end user error using Windows Picture and Fax viewer. ... >>>I have used the fax printer Windows accessory many times. ... The Fax console comes>>> up. ...
    (microsoft.public.windowsxp.print_fax)