MDI程序,如何让视图的左边和上边有标尺,就像在VC中编辑对话框控件资源时 旁边的那种标尺? Photoshop也有类似的功能界面。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 // 画尺子 void DrawRuler (HDC hdc, int cx, int cy) { int iAdj, i, iHeight; LOGFONT lf; TCHAR ch; iAdj = GetVersion () & 0x80000000 ? 0 : 1; // Black pen with 1-point width SelectObject (hdc, CreatePen (PS_SOLID, cx / 72 / 6, 0)); // Rectangle surrounding entire pen (with adjustment) Rectangle (hdc, iAdj, iAdj, cx + iAdj + 1, cy + iAdj + 1); // Tick s for (i = 1 ; i < 96 ; i++) { if (i % 16 == 0) iHeight = cy / 2; // inches else if (i % 8 == 0) iHeight = cy / 3 ; // half inches else if (i % 4 == 0) iHeight = cy / 5 ; // quarter inches else if (i % 2 == 0) iHeight = cy / 8 ; // eighths else iHeight = cy / 12; // sixteenths MoveToEx (hdc, i * cx / 96, cy, NULL); LineTo(hdc, i * cx / 96, cy - iHeight); } // Create logical font FillMemory (&lf, sizeof (lf), 0); lf.lfHeight = cy / 2; lstrcpy (lf.lfFaceName, TEXT ("Times New Roman")); SelectObject (hdc, CreateFontIndirect (&lf)); SetTextAlign (hdc, TA_BOTTOM | TA_CENTER); SetBkMode(hdc, TRANSPARENT); // Display numbers for (i = 1 ; i <= 5 ; i++) { ch = (TCHAR) (i + '0'); TextOut (hdc, i * cx / 6, cy / 2, &ch, 1); } // Clean up DeleteObject (SelectObject (hdc, GetStockObject (SYSTEM_FONT))); DeleteObject (SelectObject (hdc, GetStockObject (BLACK_PEN))); } 小弟新建C++技术交流群,邀请C++界各路大神小鬼加入,在此谢过! word\excel\ppt是用对话框怎么显示的 聊天室程序,启动服务器端,显示乱码 请指教:怎样判断串口发送已完毕? 用什么API判断窗口是否可见,急啊。 VC++(带给我无尽的烦恼,无尽的痛苦)望高手指点迷津 请教宏高手 问哈大家,我现在想动态生成网络拓扑图,该怎么实现? 如何使程序独立运行 谁用SDK做过浏览器,不用MFC的任何类? 高手帮忙:谁能提供CAsyncSocket类写的通讯例子,谢谢! 有没有选文件路径的对话框类?CFileDialog好像是选文件的,我只是想选一个路径,就像安装软件的时候选路径一样。
void DrawRuler (HDC hdc, int cx, int cy)
{
int iAdj, i, iHeight;
LOGFONT lf;
TCHAR ch;
iAdj = GetVersion () & 0x80000000 ? 0 : 1;
// Black pen with 1-point width
SelectObject (hdc, CreatePen (PS_SOLID, cx / 72 / 6, 0));
// Rectangle surrounding entire pen (with adjustment)
Rectangle (hdc, iAdj, iAdj, cx + iAdj + 1, cy + iAdj + 1);
// Tick s
for (i = 1 ; i < 96 ; i++)
{
if (i % 16 == 0) iHeight = cy / 2; // inches
else if (i % 8 == 0) iHeight = cy / 3 ; // half inches
else if (i % 4 == 0) iHeight = cy / 5 ; // quarter inches
else if (i % 2 == 0) iHeight = cy / 8 ; // eighths
else iHeight = cy / 12; // sixteenths
MoveToEx (hdc, i * cx / 96, cy, NULL);
LineTo(hdc, i * cx / 96, cy - iHeight);
}
// Create logical font
FillMemory (&lf, sizeof (lf), 0);
lf.lfHeight = cy / 2;
lstrcpy (lf.lfFaceName, TEXT ("Times New Roman"));
SelectObject (hdc, CreateFontIndirect (&lf));
SetTextAlign (hdc, TA_BOTTOM | TA_CENTER);
SetBkMode(hdc, TRANSPARENT);
// Display numbers
for (i = 1 ; i <= 5 ; i++)
{
ch = (TCHAR) (i + '0');
TextOut (hdc, i * cx / 6, cy / 2, &ch, 1);
}
// Clean up
DeleteObject (SelectObject (hdc, GetStockObject (SYSTEM_FONT)));
DeleteObject (SelectObject (hdc, GetStockObject (BLACK_PEN)));
}