滚动后无法打印文本....(Unable to print text after scrolling....)

   IT问题网   2021-02-23 00:00:00

问 题

嗨,

我用win32函数编写了一个小程序。

我想基本上启用行缓冲。例如:当文本到达窗口的末尾时,我想将文本滚动到上面的一行,然后将下一行打印到窗口的末尾。

问题:当我到达窗口的末尾时,我能够向上滚动文本但是我无法看到下一行被打印到窗口的末尾。

你能否指出我的代码中的缺陷。

  //  代码供您参考//  
lresult callback wndproc(hwnd hwnd,uint消息,wparam wparam,lparam lparam)
{
static cxchar,cychar,cxclient,cyclient,ivertpos = 0 ,icnt = 0 ;
hdc hdc;
paintstruct ps;
textmetric tm;
静态 rect rect;
static tchar cch,cscrollflag = ' n ";
tchar szbuffer [ 30 ];

switch (消息)
{
case wm_create:
hdc = getdc(hwnd);
gettextmetrics(hdc,amp; tm);
cxchar = tm.tmavecharwidth;
cychar = tm.tmheight;
releasedc(hwnd,hdc);
break ;

case wm_size:
cxclient = loword(lparam);
cyclient = hiword(lparam);

rect.left = cxchar;
rect.right = cxclient;
rect.top = cychar;
rect.bottom = cyclient;

invalidaterect(hwnd,amp; rect,true);

break ;

case wm_char:
cch = wparam;
ivertpos = ++ icnt * cychar;

if (ivertposgt; = cyclient) // 到达窗口的末尾//
{
cscrollflag = ' y';
scrollwindow(hwnd, 0 , -cychar,amp; rect,amp; rect);
}
其他 // 没有到达窗口的末尾//
{
invalidaterect(hwnd,amp; rect,false);
cscrollflag = ' n';
}
break ;

case wm_paint:
hdc = beginpaint(hwnd,amp; ps);
wsprintf(szbuffer,text(" [%2d]按下键:%c,当前位置:%d "),icnt,cch,ivertpos);
if (ivertpos)
{
if (cscrollflag == ' y' // 如果需要滚动//
{
textout(hdc,cxchar,ivertpos,szbuffer,lstrlen(szbuffer));
}
其他 // 不需要滚动//
{
textout(hdc,cxchar,ivertpos,szbuffer,lstrlen(szbuffer));
}
}
endpaint(hwnd,amp; ps);
break ;

case wm_destroy:
postquitmessage( 0 );
break ;
}
return defwindowproc(hwnd,message,wparam,lparam);
}
//




注意:我想使用原始win32函数实现这一点,但不能使用mfc或其他一些高级概念重新实现它。







谢谢

解决方案

您需要为 wm_vscroll 实现处理程序,如果需要,还需要 wm_hscroll 消息,然后在 wm_paint 处理程序您需要显示当前属于数据可视部分的每一行。例如,如果您向下滚动一行,则需要打印2-n行,其中n是适合窗口可见部分的最后一行。互联网上有各种代码示例,例如这一个 [ ^ ]。

标签:滚动转动无法没法打印文本



分享:

  • 微信
  • QQ好友
  • QQ空间
  • 新浪微博


热门推荐

我使用radgrid,我从数据库获取列名,但我希望他们的名称作为不同的名称,如何重命名RadGrid的列名(Im using a radgrid ,i get column names from database but i want their names as diferent names,How to rename those columns names of RadGrid)

problem im using a radgrid ,i get column names from datab ...

用于showbits函数的头文件(header file to be used for showbits function)

problem which header file shd be used for showbits() func ...

在gridview控件中删除事件行。(Row Deleting event in gridview control.)

problem i am trying to delete userid and groupid from the ...

如何查看.dll文件中编写的代码?(how to view code written in .dll file)

problem hi to all.i have downloaded source co ...

登录 - 使用哈希值检查密码(login - check password with hashed one)

problem this is my code to hash class hashin ...

上传图片时出现问题(problem in uploading images)

problem i want to upload images that will be saved in a f ...

如何使用c#向Bixolon热敏打印机发送命令(How to Send commands to Bixolon thermal printer using c#)

problem first of all , i have searched on goo ...

图像波动问题(image fluctuation problem)

problem i want to know how to remove image fluctuate from ...

LISTVIEW每行的随机ID(LISTVIEW random id for each row)

problem hi, all i want is to generate an id ...

如何创建自定义Web控件......?(How to create a custome web control...)

problem 1) i want to create a class that will inherited f ...

如何管理该代码(how to manage that code)

problem my question is......... we have 3 buttns on page ...

如何删除sysobjects中的列数据但不删除它们的关系(how to delete columns data in sysobjects but not deleted their relations)

problem hello how to delete all system table columns dat ...

异步wcf调用和mantaining会话?(asynchronous wcf call and mantaining session )

problem i have two pages on my website .from page 1 i am ...

通过网络传递序列化数据(Passing serialized data over network)

problem hey, i have a problem with deserializing an objec ...

程序显示按完成时间排序的跑步者,其中一列显示其年龄组内的完成位置(排名)。(Program to display the runners sorted by finish time with a column showing their finish position (ranking) within their age group.)

problem you have a list of runners and their race times a ...

如何调试我的xpath并检查它是否存在一些问题?(How to debug my xpath and to check if there are some problems in it )

problem hi,everyone! now i have a xml file and it looked ...

用户界面设计(User interface Design)

problem hi, i want to design all the user interface scree ...

在ASP.Net中拖放图像(Drag and drop image in ASP.Net)

problem hi, i saw "the drag and drop image i ...

任何人都可以帮助解决'/'应用程序中的服务器错误。(Can any one help dis error Server Error in '/' Application.)

problem hi every one i am upload one .aspx p ...

灰度图像处理(Gray Scale image Processing)

problem hi i want cut the image from pattern the output o ...