Thread: simple visual studio question

  1. #1
    Registered User
    Join Date
    Oct 2002
    Posts
    291

    simple visual studio question

    Good evening.

    This is what I've done so far (not much) :
    - made a MFC Project
    - added a couple of button
    - added a function for each button on click

    Now Im trying to run some code when I click on one of the buttons. Im used to doing cout << variable; for debugging my programs but this doesnt seem to work in my project (even tryed std::cout << "hello"; and included iostream but no go. So my question is bascilly, whats the best way of debugging my program ? need to know what value some variables have, before when I used visual basic I could do msgbox but there must be a better way.

    Sorry if this is too basic.

  2. #2
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    cout and any of the character based I/O routines work fine when working with a console application, but won't work within a window. Windows programming just isn't like that.

    The easiest way to debug windows apps is with your IDE's debugger, punktum, full-stop, learn how to use it, it will save you hours and hours.

    You can use message boxes to output small messages, (I don't use MFC but it can't be difficult), or to some other visual control, an edit box or static text control for example. You can, of course, write directly to the windows surface, but to do so you would need to use the MFC equivalent of the TextOut() API routine - I don't know what that is, guessing, a member of the window or DC class.

    As a total aside, I would always advocate learning the API before playing with a class library - going that way is generally easy, going the other way can be very confusing.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Question about Compile Behavior in Visual Studio
    By Tachimazu in forum C++ Programming
    Replies: 5
    Last Post: 06-22-2009, 03:28 AM
  2. Console Font Size
    By bradszy in forum Windows Programming
    Replies: 34
    Last Post: 04-26-2008, 07:09 AM
  3. Templates and Macros plus more...
    By Monkeymagic in forum C++ Programming
    Replies: 8
    Last Post: 01-20-2007, 05:53 PM
  4. using classes
    By krazykrisi in forum C++ Programming
    Replies: 9
    Last Post: 11-22-2006, 10:41 AM
  5. Visual Studio question
    By purple in forum C++ Programming
    Replies: 11
    Last Post: 03-14-2002, 10:58 PM