|
From: Jason H. <jas...@bt...> - 2001-10-17 12:06:10
|
You never said where you would be displaying your text, but if you are using the windows GDI, then I have found a function that may be of use. I'm still learning windows myself. When outputting text (to a window normally) you can use TextOut, or DrawText. With DrawText() you can specify the rectangle the text will be drawn into and specify the formatting of that text including justification. I will advise you that it's a headache waiting to happen if you are a beginner. You can look it up in the Win32 Reference for more info. If you are using a console then stick with the formula. Jason. ----- Original Message ----- From: "Jason Hardman" <jas...@bt...> To: "Dev-C++" <dev...@li...> Sent: Wednesday, October 17, 2001 5:20 AM Subject: Re: [Dev-C++] simle formatting > Assuming that you need the x coordinate of the left most character in the > string you need to output then the formula is fairly simple. > > left_coord = (area_width - text_width) / 2 > > Area_width meaning the width of whatever you are trying to center the text > into. The formular is the same weather you are using console mode text, or > pixels in a window. If you want to center verticaly then just use height > values instead. > > If you don't understand why this works then just ask and I will explain it. > > It depends upon what environment you are working in as to how to clear the > screen. In a console you could just scroll the entire area off view, > althought there may be a dedicated function that clears the screen but I > don't know it. Anyone else? If you are working in OpenGL or DirectX then > there is probably a function to do it, but I don't know much about them so > you should refer to the documentation if necessary. > > Jason. > > ----- Original Message ----- > From: "Mansoor Nathani" <man...@sy...> > To: "Dev users" <dev...@li...> > Sent: Wednesday, October 17, 2001 6:44 AM > Subject: [Dev-C++] simle formatting > > > > I cant seem to be able to clear the screen. > > > > Another problem I am facing is the aligning of text. If I need to output > > text, aligned in the centre, is there some sort of predefined function > > to do that? > > > > Any help would be greatly appreciated. > > > > > > _______________________________________________ > > Dev-cpp-users mailing list > > Dev...@li... > > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > > > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users |