LPPOINT lpPoints; // Path data points
LPBYTE lpTypes; // Path data types
int i, iNumPts;
SIZE size; // Text size info
float fXScale, fYScale; // Scaling values
int iTopInd, iBotInd; // Guide array indices // Set to transparent so we dont get an outline around the text string
SetBkMode(hDC, TRANSPARENT);
// Output the text into a path
BeginPath(hDC);
TextOut(hDC, 0, 0, szText, strlen(szText));
EndPath(hDC);
// How many points are in the path
// How many points are in the path
iNumPts = GetPath(hDC, NULL, NULL, 0);。 if (iNumPts == -1)
return FALSE;
// Allocate room for the points
lpPoints = (LPPOINT)GlobalAlloc(GPTR, sizeof(POINT) * iNumPts);
if (!lpPoints) return FALSE; // Allocate room for the point types
lpTypes = GlobalAlloc(GPTR, iNumPts);
if (!lpTypes) {
GlobalFree(lpPoints);
return FALSE;
}
// Get the points and types from the current path
iNumPts = GetPath(hDC, lpPoints, lpTypes, iNumPts);
// Even more error checking
if (iNumPts == -1) {
GlobalFree(lpTypes);
GlobalFree(lpPoints);
return FALSE;
}
//Get extents of the text string for scaling purposes
GetTextExtentPoint32(hDC, szText, strlen(szText), &size);
// Relocate the points in the path based on the guide lines
for (i=0; i < iNumPts; i++) {
// How far along is this point on the x-axis
fXScale = (float)lpPoints[i].x / (float)size.cx; // What point on the top guide does this coorespond to
iTopInd = (int)(fXScale * (dwTopPts-1));
// What point on the bottom guide does this coorespond to
iBotInd = (int)(fXScale * (dwBotPts-1)); // How far along is this point on the y-axis
fYScale = (float)lpPoints[i].y / (float)size.cy; // Scale the points to their new locations
lpPoints[i].x = (int)((lpBot[iBotInd].x * fYScale) + (lpTop[iTopInd].x * (1.0f-fYScale)));
lpPoints[i].y = (int)((lpBot[iBotInd].y * fYScale) + (lpTop[iTopInd].y * (1.0f-fYScale)));
} // Draw the new path
RenderPathPoints(hDC, lpPoints, lpTypes, iNumPts, bOutlineOnly);
GlobalFree(lpPoints);
GlobalFree(lpTypes);
LPBYTE lpTypes; // Path data types
int i, iNumPts;
SIZE size; // Text size info
float fXScale, fYScale; // Scaling values
int iTopInd, iBotInd; // Guide array indices // Set to transparent so we dont get an outline around the text string
SetBkMode(hDC, TRANSPARENT);
// Output the text into a path
BeginPath(hDC);
TextOut(hDC, 0, 0, szText, strlen(szText));
EndPath(hDC);
// How many points are in the path
// How many points are in the path
iNumPts = GetPath(hDC, NULL, NULL, 0);。 if (iNumPts == -1)
return FALSE;
// Allocate room for the points
lpPoints = (LPPOINT)GlobalAlloc(GPTR, sizeof(POINT) * iNumPts);
if (!lpPoints) return FALSE; // Allocate room for the point types
lpTypes = GlobalAlloc(GPTR, iNumPts);
if (!lpTypes) {
GlobalFree(lpPoints);
return FALSE;
}
// Get the points and types from the current path
iNumPts = GetPath(hDC, lpPoints, lpTypes, iNumPts);
// Even more error checking
if (iNumPts == -1) {
GlobalFree(lpTypes);
GlobalFree(lpPoints);
return FALSE;
}
//Get extents of the text string for scaling purposes
GetTextExtentPoint32(hDC, szText, strlen(szText), &size);
// Relocate the points in the path based on the guide lines
for (i=0; i < iNumPts; i++) {
// How far along is this point on the x-axis
fXScale = (float)lpPoints[i].x / (float)size.cx; // What point on the top guide does this coorespond to
iTopInd = (int)(fXScale * (dwTopPts-1));
// What point on the bottom guide does this coorespond to
iBotInd = (int)(fXScale * (dwBotPts-1)); // How far along is this point on the y-axis
fYScale = (float)lpPoints[i].y / (float)size.cy; // Scale the points to their new locations
lpPoints[i].x = (int)((lpBot[iBotInd].x * fYScale) + (lpTop[iTopInd].x * (1.0f-fYScale)));
lpPoints[i].y = (int)((lpBot[iBotInd].y * fYScale) + (lpTop[iTopInd].y * (1.0f-fYScale)));
} // Draw the new path
RenderPathPoints(hDC, lpPoints, lpTypes, iNumPts, bOutlineOnly);
GlobalFree(lpPoints);
GlobalFree(lpTypes);
解决方案 »
- 树根节点下的所有一级节点
- vs2010+win7写的程序.到xp上出错.无法定位程序输入点_except_handler4_common与动态链接库msvcrt.dll上.咋办?
- 有关ToolTip控制的问题
- 怎样用VC++读取MP4格式文件的时长与码率……………………回帖即给分!!
- 我用winsock写一个类但connect不上服务器请问???
- 我用BHO插件,想用它获得浏览的页面的frame的个数怎么做??
- 关于DLL库文件注册失败的问题?(贴子1)
- 考研好还是搞计算机技术好啊??
- 我想在WIN98下构造XP界面,但WIN98的标题Y值太小,有什么方法可使标题的Y值增大?
- 用vc时要用到许多函数,有的函数是c语言提供的,有的函数是操作系统提供的,语言的设计者应该提供那些函数,而操作系统的设计者又该提供
- 删除文件
- 线程中调用CreateDispatch()失败,但在线程外调用则成功。请教
第一个;LPBYTE lpTypes;这样定义为什么编译时不会报错。为什么我自己这么写就不行呢?
LPBYTE lpTypes;本来这样定义就是对的呀你这样定义出错了??报什么错呢
这是win32的类型怎么会出错呢?你是指什么?
include "windows.h"
如果是运行出问题可能是你没有为之分配内存,它只是个指针
编译的结果是这样的.
C2275: 'LPBYTE' : illegal use of this type as an expression
C:\Program Files\Microsoft Platform SDK for Windows XP SP2\include\windef.h(150) : see declaration of 'LPBYTE'
textfx.c(441) : error C2146: syntax error : missing ';' before identifier 'lpTypes'
textfx.c(441) : error C2065: 'lpTypes' : undeclared identifier因为我是在看MSDN里的一个程序的源代码,所以看到不会的我就想自己试着模仿一下,所以我自己在人家的源程序上加了一个自己的菜单.可是在这里面我只是写了一行LPBYTE lpTypes;我也想过是指针问题,但具体我也不太知道该怎么办.
lpTypes = GlobalAlloc(GPTR, iNumPts);为什么要这样呢?