AMIO编辑器开发(九):键盘的左右键交互
发布日期:2021-10-23 09:05:16 浏览次数:1 分类:技术文章

本文共 1361 字,大约阅读时间需要 4 分钟。

与之前的键盘上下键一样的封装逻辑,这里就不复重了。

改变是:绘制缓冲区字符串时,要加上列的偏移量:

void EditView::drawText(HDC hdc){	int OFFSET = 0;	HFONT hFont = CreateFontIndirect(&logFont);	SelectObject(hdc, hFont);	//-----------------------	int firstRowIndex = lpEditViewAdapter->firstVisibleRowIndex;	int rowCount = lpEditViewAdapter->visibleRowCount;	int columnIndex = lpEditViewAdapter->firstVisibleColumnIndex;	TCHAR * textBuffer = NULL;	RECT textRect;	int incHeight = getCharHeight();	int i = 0;	int j = 0;	VIEW_RECT viewRect = getArea();	// initial RECT of draw text in editor area.	textRect.left = viewRect.left;	textRect.right = viewRect.right - 1;	textRect.top = viewRect.top;	textRect.bottom = textRect.top + incHeight;	OFFSET = lpEditViewAdapter->firstVisibleColumnIndex;	for (i = firstRowIndex, j = 0; i <= firstRowIndex + rowCount; i++, j++){		// move to row		textBuffer = lpEditViewAdapter->editTextBuffer[0] + j * GOLBAL_MEM_COLUMN_MAX + OFFSET;		// move to first visible column		textBuffer += columnIndex;		// draw text on screen		DrawText(hdc, textBuffer, lstrlen(textBuffer), &textRect, DT_LEFT);		// refresh vertical parameter of RECT.		textRect.top = incHeight * (j+1);		textRect.bottom = textRect.top + incHeight;		}// end for	//-----------------------	DeleteObject(hFont);	}

最右的边界检测没有做,等以后再作为BUG微调:

下一步,就是绑定滚动条以及滚动条的UI。

转载于:https://www.cnblogs.com/aimo/archive/2012/05/05/2484424.html

转载地址:https://blog.csdn.net/weixin_30549657/article/details/95799539 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:工作笔记——一些常用函数的封装
下一篇:第十一周总结

发表评论

最新留言

很好
[***.229.124.182]2024年03月04日 04时23分53秒

关于作者

    喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!

推荐文章