1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

how to use the TextOut

Discussion in 'Win32' started by vidhya, Jul 2, 2007.

  1. vidhya

    vidhya New Member

    Joined:
    May 17, 2007
    Messages:
    36
    Likes Received:
    0
    Trophy Points:
    0
    hi

    what i want to know is ,how to display the text in window using TextOut.what i want is when i execute the for loop the textout should print or display the text on next ,next line.
    i.e one string on one line,next string on next line.

    can any body tell me how to do this.it is very urgent.

    regards
    vidhya
     
  2. NewsBot

    NewsBot New Member

    Joined:
    Dec 2, 2008
    Messages:
    1,267
    Likes Received:
    2
    Trophy Points:
    0
    Will you please explain as I could not understand what you are looking for?
     
  3. vidhya

    vidhya New Member

    Joined:
    May 17, 2007
    Messages:
    36
    Likes Received:
    0
    Trophy Points:
    0
    ya.what i want to do is when i execute a for loop in that loop i am printing some text on window using textout.at first time when for loop runs textout print text on window on one line.next time when it execute the textout should print the text in second line on same window.how to do this.

    regards
    vidhya
     
  4. NewsBot

    NewsBot New Member

    Joined:
    Dec 2, 2008
    Messages:
    1,267
    Likes Received:
    2
    Trophy Points:
    0
    Have some static variable to store the line previously print and do the TextOut ( yStart ) accordingly depending on the variable value.
     
  5. vinothnat

    vinothnat New Member

    Joined:
    Aug 9, 2007
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Programmer
    Location:
    Chennai
    Home Page:
    Hey Vidya....

    Here is the sample for TextOut....


    Syntax for TextOut():

    BOOL TextOut(HDC hdc,int nXStart,int nYStart,LPCTSTR lpString,int cbString);

    Then put the following code in WndProc,

    case WM_PAINT:
    hdc = BeginPaint(hDlg, &ps);
    TextOut(hdc, 0, 0, "Hello, Windows!", 15);
    EndPaint(hDlg, &ps);
    break;


    That’s it…
     
  6. SatK

    SatK New Member

    Joined:
    Feb 1, 2008
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    A more appropriate example will be.
    Code:
    case WM_PAINT:
    	{
    		hdc = BeginPaint(hWnd, &ps);
    		wchar_t* msg[3] = { L"vidhya", L"satindar",L"vinoth", };
    		for( int i=0;i < 3; i++ ){
    			TextOut(hdc, 0, 20*i,  msg[i], lstrlen( msg[i] ) ); 
    		}
    
    		EndPaint(hWnd, &ps);
    	}
    	break;
    
     

Share This Page