answersLogoWhite

0

C++ has no generic graphics capability whatsoever. Graphics are platform-specific, and every C++ implementation provides its own API and libraries specific to the intended platform.

For instance, the following user-defined Visual C++ MFC function will centre any text (t) within a given rectangle (r) relative to the given device context (dc):

void centre_text(CString& t, CRect& r, CDC& dc)

{

CRect b; // bounding rectangle.

// Calculate the bounding rectangle of the text:

dc.DrawText( t, b, DT_CALCRECT );

// Position the bounding rectangle in the centre of the given rectangle:

b.MoveToXY(

r.left + (( r.Width() - b.Width() ) / 2 ),

r.top + (( r.Height() - b.Height() ) / 2 ));

// Draw the text in the bounding rectangle:

dc.DrawText( t, b, DT_NOCLIP );

}

Note that the above code is non-generic and therefore cannot be ported to other platforms. It will only work in Visual C++ MFC applications. However, the principal will be largely the same on other platforms: calculate the bounding rectangle, move it to the centre of the intended rectangle and then print the text in the bounding rectangle.

User Avatar

Wiki User

11y ago

What else can I help you with?

Related Questions

Write a java script program to print first ten odd natural numbers in C?

Q.1 Write a program to print first ten odd natural numbers. Q.2 Write a program to input a number. Print their table. Q.3 Write a function to print a factorial value.


Write a C plus plus function that print a triangle of stars?

Write a function that print a triangle of stars.


What is the purpose of print strings in python?

It means that python will print(or write out) a value you input.


What are the example of turbo c with using scan and print function?

#include<stdio.h> Void main() { int a,b; printf("Enter a Number: "); // for print function as an out-put scanf("%d",&a); //for scan function as in input /* Here we can use print function once again as: */ a=a++; printf("%d",a); }


Given the coordinates xy of a center of a circle and its radius write a program which will determine whether a point lies inside the circleon the circle or outside the circle conditional statements?

Center is at (Xc, Yc ). Radius = R. ======================================= Print "Input the coordinates of point 'P', separated by a comma." Input A, B D = (Xc - A)2 + (Yc - B)2 If D < R2 then print "'P' is inside the circle." If D = R2 then print "'P' is on the circle." If D > R2 then print "'P' is outside the circle." by arup nandy


Write a program in 'C' language to accept 6 strings as input and print them in lexicographic?

(ab)*b


2 Write a program to print a following program?

USING STRING LITERAL VALUES TO ADD 2 NUMBERS If you just want to show the outcome of two numbers you have: PRINT 4 + 5 This will print '9' the answer to 4 + 5. If you want to show the addition: PRINT "4 + 5 = "; 4 + 5 This will show the question and then calculate the answer. If you want the user to input numbers to add, use variables and then add them the same way. ====== COLLECTING USER INPUT FROM THE KEYBOARD/USING NUMERIC VARIABLES In the following example, the end user can get to interact with the program by typing in their numbers at the keyboard; then, pressing the [Enter] key. CLS PRINT "PROGRAM: Add 2 numbers" PRINT INPUT "Enter the 1st number: ", number1 INPUT "Enter the 2nd number: ", number2 PRINT sumTotal=number1+number2 PRINT "The sum total is: "; sumTotal PRINT INPUT "Again, Y/N"; yesNo$ IF UCASE$(LEFT$(yesNo$,1))="Y" THEN RUN END ====== CREATE FUNCTION/THEN, MAKE A FUNCTION CALL TO ADD 2 NUMBERS Another way to write this program is to create a function/then, make a function call... '*** PROGRAM: Add 2 numbers... '*** Variable declaration list... number1=7 '...initialise numeric variable 1 number2=3 '...initialise numeric variable 2 '*** Main program... CLS '...(CL)ear the (S)creen PRINT add(number1,number2) '...make function call/passing in 2 numbers to add END '...END of program/halt program code execution '*** Function(s)... FUNCTION add(num1,num2) '...this line marks the start of the Function add=num1+num2 '...this line returns the sum total of the 2 numbers END FUNCTION '...this line marks the end of the Function


How do you write the pseudo code for an application that accepts a number as input and displays the value that is one more than the number?

input number print number + 1


How do you write a pseudocode program that commutes and displays a 15 percent tip when you input the price of the meal?

input price calc tip = price*0.15 print tip


How do you write the pseudocode for an application that accepts a number as input and displays the number three times?

input number for loop = 1 to 3 inclusive print number end for


What is the meaning of print and input in idle python?

"print" will output a value onto the screen for a user to see. "input" or "raw_input" gets a user's input.


Write a program that prompts the user to input the length and width of a rectangle and then prints the rectangle's area and perimeter?

PRINT "Give me the rectangle's length.": Input L PRINT "Give me the rectangle's width.": Input W PRINT "The rectangle's area is "; L x W PRINT "The rectangle's perimeter is "; 2 x (L + W) PRINT "You've been a great audience. I'm here til Thursday. Don't forget to tip your waiter. Have a nice day."