The following code draws a grid in the client area of a window, spacing the lines 50pixels apart starting from the
upper left corner. The variable hwnd is assumed to be a handle to the window, hdc is a handle to the device
context, and x and y are integers: 

下面的程序代码从窗口的左上角开始,在显示区域中画一个网格,线与线之间相隔50个图素,其中hwnd是窗口句柄,hdc是设备内容句柄,而x和y是整数

 

    int x,y;
RECT rect;
GetClientRect(hwnd,&rect); //该函数获取窗口客户区的坐标,用rect保存
for(x=0;x<rect.right;x+=50)
{
MoveToEx(hDC,x,0,NULL);
LineTo(hDC,x,rect.bottom);
}
for(y=0;y<rect.bottom;y+=50)
{
MoveToEx(hDC,0,y,NULL);
LineTo(hDC,rect.right,y);
}



相关文章:

  • 2022-12-23
  • 2021-10-27
  • 2021-12-26
  • 2022-12-23
  • 2022-12-23
  • 2021-05-07
猜你喜欢
  • 2022-12-23
  • 2021-05-22
  • 2022-01-19
  • 2022-12-23
  • 2022-12-23
  • 2022-02-02
  • 2021-12-03
相关资源
相似解决方案