求教C语言图形编程的问题

C语言 码拜 9年前 (2015-05-11) 701次浏览 0个评论
 

请问:许多图形处理函数都需要横纵坐标作参数,那如果我想在窗口的特定位置进行画图,我要怎么知道那个特定点的横纵坐标呢?

在网上搜vc绘图,然后安装之后包含graphics.h头文件就可以随意的绘图了
10分
那要看你的窗口大小, 比如 1280*720,那么你按比例计算即可
GetClientRect
The GetClientRect function retrieves the coordinates of a window””s client area. The client coordinates specify the upper-left and lower-right corners of the client area. Because client coordinates are relative to the upper-left corner of a window””s client area, the coordinates of the upper-left corner are (0,0). 

BOOL GetClientRect(
  HWND hWnd,      // handle to window
  LPRECT lpRect   // address of structure for client coordinates
);
 
Parameters
hWnd 
Handle to the window whose client coordinates are to be retrieved. 
lpRect 
Pointer to aRECT structure that receives the client coordinates. The left and top members are zero. The right and bottom members contain the width and height of the window. 
Return Values
If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, callGetLastError. 

Remarks
Windows CE: Command bars are included in the client area.

QuickInfo
  Windows NT: Requires version 3.1 or later.
  Windows: Requires Windows 95 or later.
  Windows CE: Requires version 1.0 or later.
  Header: Declared in winuser.h.
  Import Library: Use user32.lib.

See Also
Windows Overview, Window Functions, GetWindowRect,RECT 

 

引用 3 楼 zhao4zhong1 的回复:

GetClientRect
The GetClientRect function retrieves the coordinates of a window””s client area. The client coordinates specify the upper-left and lower-right corners of the client area. Because client coordinates are relative to the upper-left corner of a window””s client area, the coordinates of the upper-left corner are (0,0). 

BOOL GetClientRect(
  HWND hWnd,      // handle to window
  LPRECT lpRect   // address of structure for client coordinates
);
 
Parameters
hWnd 
Handle to the window whose client coordinates are to be retrieved. 
lpRect 
Pointer to aRECT structure that receives the client coordinates. The left and top members are zero. The right and bottom members contain the width and height of the window. 
Return Values
If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, callGetLastError. 

Remarks
Windows CE: Command bars are included in the client area.

QuickInfo
  Windows NT: Requires version 3.1 or later.
  Windows: Requires Windows 95 or later.
  Windows CE: Requires version 1.0 or later.
  Header: Declared in winuser.h.
  Import Library: Use user32.lib.

See Also
Windows Overview, Window Functions, GetWindowRect,RECT 

 

赵4老师,你好,我英语不好。。。请问一下:如果我已经画一个五子棋的棋盘的话,要在棋盘上某个特定地点落子,如何确定棋子的坐标以便在我能在那个特定地点画棋子呢?就比如说我要在棋盘的第3行第4列画棋子,我怎么知道第3行第4列的横纵坐标是多少呢

30分
y坐标=第3行×每行所占像素高度
x坐标=第4列×每列所占像素宽度

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明求教C语言图形编程的问题
喜欢 (0)
[1034331897@qq.com]
分享 (0)

文章评论已关闭!