Форум С++

 

Ответить на сообщение

Вернуться к теме

Вы отвечаете на сообщение:

Автор: AVS   (28.11.2007 в 12:37)
В C++ Builder 6. Компонент TImage. Image->Canvas->TextOutA(x,y,"Text"). Но это просто помещается текст.

Мне подкинули вот такой код:

RECT rc;  
int angle; 
HFONT hfnt, hfntPrev; 
LPSTR lpszRotate = "String to be rotated."
 
/* Allocate memory for a LOGFONT structure. */ 
 
PLOGFONT plf = (PLOGFONT) LocalAlloc(LPTR, sizeof(LOGFONT)); 
 
 
/* Specify a font typeface name and weight. */ 
 
lstrcpy(plf->lfFaceName, "Arial"); 
plf->lfWeight = FW_NORMAL; 
 
/* Retrieve the client-rectangle dimensions. */ 
 
GetClientRect(hwnd, &rc); 
 
/* 
 * Set the background mode to transparent for the 

 * text-output operation. 
 */
 
 
SetBkMode(hdc, TRANSPARENT); 
 
/* 
 * Draw the string 36 times, rotating 10 degrees 
 * counter-clockwise each time. 
 */
 
 
for (angle = 0; angle < 3600; angle += 100) { 
    plf->lfEscapement = angle; 
    hfnt = CreateFontIndirect(plf); 
    hfntPrev = SelectObject(hdc, hfnt); 
    TextOut(hdc, rc.right / 2, rc.bottom / 2, 
        lpszRotate, lstrlen(lpszRotate)); 
    SelectObject(hdc, hfntPrev); 
    DeleteObject(hfnt); 


 
/* Reset the background mode to its default. */ 
 
SetBkMode(hdc, OPAQUE); 
 
/* Free the memory allocated for the LOGFONT structure. */ 
 
LocalFree((LOCALHANDLE) plf);


Но он рисует на самой форме. Я пытался изменить его так, чтобы рисовалось на TImage (именно на нем мне надо), но не получилось, т.к. функции TextOut различны у формы и Image.


Ваше имя:

Пароль:

Цитировать

Используйте тэги для выделения текста:
Код: [code][/code]
Жирный: [b][/b]
Наклонный: [i][/i]
URL: [url][/url]

Сообщение:

Прикрепить: