I got 1 error!!

This is a discussion on I got 1 error!! within the Windows Programming forums, part of the Platform Specific Boards category; Here I have it: BOOL TextOut( HDC hdc, // handle to device context int nXStart, // x-coordinate of starting position ...

  1. #1
    BubbleMan
    Guest

    Question I got 1 error!!

    Here I have it:

    BOOL TextOut(
    HDC hdc, // handle to device context
    int nXStart, // x-coordinate of starting position
    int nYStart, // y-coordinate of starting position
    LPCTSTR lpString, // pointer to string
    int cbString; // number of characters in string
    );

    char *f_name = "Matt";
    TextOut(HDC, 10, 10, *f_name, strlen(*f_name));

    but I get:

    89 book_windows.cpp
    parse error before `,'

  2. #2
    Has a Masters in B.S.
    Join Date
    Aug 2001
    Posts
    2,267
    TextOut(HDC, 10, 10, *f_name, strlen(*f_name));

    HDC is a type you can't use it as a variable.

    are you using MFC?
    theirs another textout for MFC.
    ADVISORY: This users posts are rated CP-MA, for Mature Audiences only.

  3. #3
    BubbleMan
    Guest

    Question What do I put?

    I use Dev-C++ MinGW. How do I print text?

  4. #4
    Has a Masters in B.S.
    Join Date
    Aug 2001
    Posts
    2,267
    the
    TextOut() given previously.

    using HDC as a param is invalid since its a type thats whats causing the error.

    you need too get a handle to your windows DC an use that.
    ADVISORY: This users posts are rated CP-MA, for Mature Audiences only.

  5. #5
    BubbleMan
    Guest

    Ok, a Q about that

    How would I do that. I am a little new to Win programming. But I can do menus. How do I do that?

  6. #6
    Has a Masters in B.S.
    Join Date
    Aug 2001
    Posts
    2,267
    do you have the variable hWnd(handle to the window)?
    ADVISORY: This users posts are rated CP-MA, for Mature Audiences only.

  7. #7
    BubbleMan
    Guest

    Post I have..

    I have hwnd

  8. #8
    Has a Masters in B.S.
    Join Date
    Aug 2001
    Posts
    2,267
    then use this

    HDC hDC = GetDC(hwnd);

    char *f_name = "Matt";
    TextOut(hDC, 10, 10, *f_name, strlen(*f_name));
    ADVISORY: This users posts are rated CP-MA, for Mature Audiences only.

  9. #9
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,786
    To get a HDC try -

    HDC hdc;



    hdc = GetDC(hwnd); hwnd bing the handle of the window you are working with


    [EDIT]Doh....didnt realise this thread was in use - sorry guys[/EDIT]

  10. #10
    BubbleMan
    Guest

    Post Now I get..

    I get these:

    85 book_windows.cpp
    default argument `GetDC(hwnd)' uses local variable `hwnd'

    85 book_windows.cpp
    default argument missing for parameter 2 of `BOOL TextOutA(HDC__ * = {error}, int, int, const TCHAR *, int)'

    88 book_windows.cpp
    `hDC' undeclared (first use this function)

    88 book_windows.cpp
    (Each undeclared identifier is reported only once

    88 book_windows.cpp
    for each function it appears in.)

    88 book_windows.cpp
    passing `char' to argument 1 of `strlen(const char *)' lacks a cast

  11. #11
    Has a Masters in B.S.
    Join Date
    Aug 2001
    Posts
    2,267
    worry not Fordy good answer.
    ADVISORY: This users posts are rated CP-MA, for Mature Audiences only.

  12. #12
    Has a Masters in B.S.
    Join Date
    Aug 2001
    Posts
    2,267
    im honstly a little confused. could you post some code?
    ADVISORY: This users posts are rated CP-MA, for Mature Audiences only.

  13. #13
    BubbleMan
    Guest

    Post Code

    Code:

    BOOL TextOut(
    HDC hDC = GetDC(hwnd), // handle to device context
    int nXStart, // x-coordinate of starting position
    int nYStart, // y-coordinate of starting position
    LPCTSTR lpString, // pointer to string
    int cbString // number of characters in string
    );

    char *f_name = "Matt";
    TextOut(hDC, 10, 10, *f_name, strlen(*f_name));
    }

  14. #14
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,786
    Sorry but why are you declaring the whole TextOut function? Its included in windows.h

    Try


    Code:
    HDC hDC = GetDC(hwnd);
    char *f_name = "Matt"; 
    TextOut(hDC, 10, 10, *f_name, strlen(*f_name));

  15. #15
    Has a Masters in B.S.
    Join Date
    Aug 2001
    Posts
    2,267
    ok i see

    don't put this in the code

    BOOL TextOut(
    HDC hDC = GetDC(hwnd), // handle to device context
    int nXStart, // x-coordinate of starting position
    int nYStart, // y-coordinate of starting position
    LPCTSTR lpString, // pointer to string
    int cbString // number of characters in string
    );

    just use this,

    HDC hDC = GetDC(hwnd);

    char *f_name = "Matt";
    TextOut(hDC, 10, 10, *f_name, strlen(*f_name));
    ADVISORY: This users posts are rated CP-MA, for Mature Audiences only.

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. An error is driving me nuts!
    By ulillillia in forum C Programming
    Replies: 5
    Last Post: 04-04-2009, 09:15 PM
  3. Making C DLL using MSVC++ 2005
    By chico1st in forum C Programming
    Replies: 26
    Last Post: 05-28-2008, 01:17 PM
  4. Connecting to a mysql server and querying problem
    By Diod in forum C++ Programming
    Replies: 8
    Last Post: 02-13-2006, 09:33 AM
  5. Couple C questions :)
    By Divx in forum C Programming
    Replies: 5
    Last Post: 01-28-2003, 12:10 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21