两个问题一起来(各50$)!(100分)

  • 主题发起人 主题发起人 esheen
  • 开始时间 开始时间
E

esheen

Unregistered / Unconfirmed
GUEST, unregistred user!
上一次网不易,上大富翁更不易,两个问题一起来吧!
1、Canvas上有一由若干个点组成的折线,我想用鼠标移动各个点,
就是说用鼠标点中一点就使其获得焦点(小黑矩形),用鼠标按下移动就可以把此点移到一个新位置,我想此问题应该是一个一般性的
问题(如把点换成别的形状),应该有一个通用的办法。
2、在canvas上有一个100X200像素(pixel)的矩形,如何使其在打印机上打出10X20厘米的矩形?
 
1.好像用huizhang的那个TLine就可以解决.
 
2.
uses printers;
procedure TForm1.FormCreate(Sender: TObject);
begin
setmapmode(printer.Canvas.Handle,MM_Lometric);//坐标映射为1个逻辑坐标
等于0.1mm
printer.begindoc;
printer.Canvas.Rectangle(0,0,10*100,20*100);//10cmx20cm
printer.enddoc;
end;
 
1.可以在程序中动态建立Image控件,每个Image控件作为一个节点,并用TList
对象来管理它们;编写一个通用的MouseMove事件过程来处理鼠标按下拖动节点
情况(在该事件中检测鼠标上是否有按钮被按下);每个Image控件的位置对应一
个节点的位置。至于节点的形状可以在自己在Image控件的Canvas上去画出来。

这是一个笨办法,但实现起来比较简单。
 
举个例子,比如在word中用绘图工具绘图时,每个图形元素都能获得
焦点(线段有两个焦点,矩形有8个焦点),都能实现移动、拉伸和挤压,这是如何实现的?
 
简单:
先保存所有需要有焦点的矩形坐标. 然后在WM_LBUTTONDOWN消息里
判断鼠标处于哪个矩形框里, 画焦点的显示(比如焦点处变黑, 鼠标形状改变
等等). 在WM_MOUSEMOVE消息里判断是否拖动(鼠标左键是否按下状态)
处理焦点的拖动并改变焦点的矩形坐标.
如果觉得麻烦可以将单个焦点定成一个类(比如一个3*3大小的panel). 然后
处理这个类的click, mousedown, mousemove, mouseup事件并画两个焦点
之间的连线. 所以, 直线可以认为是两个panel + canvas上lineto组成.
矩形就是8个panel+这些panel之间的连线啦.
 
我看还是一步到位,将任何矢量单元都作为一个对象,
接受焦点以后的动作由此对象自己完成,包括改变自身已显示变化
 
tlaolao:能否给个例子,或哪里有这样的例子可下载,急!!!例子较大的
话可Email给我:eastsh@cmmail.com,哪位大虾有这样的例子也不妨“奉献”出来:-),万分感谢!
 
Delphi的例子里有呀!?
 
2:
int SetMapMode(

HDC hdc, // handle of device context
int fnMapMode // new mapping mode
);


Parameters

hdc

Identifies the device context.

fnMapMode

Specifies the new mapping mode. It can be any one of the following values:

Value Description
MM_ANISOTROPIC Logical units are mapped to arbitrary units with arbitrarily scaled axes. Use the SetWindowExtEx and SetViewportExtEx functions to specify the units, orientation, and scaling that you want.
MM_HIENGLISH Each logical unit is mapped to 0.001 inch. Positive x is to the right; positive y is up.
MM_HIMETRIC Each logical unit is mapped to 0.01 millimeter. Positive x is to the right; positive y is up.
MM_ISOTROPIC Logical units are mapped to arbitrary units with equally scaled axes; that is, one unit along the x-axis is equal to one unit along the y-axis. Use the SetWindowExtEx and SetViewportExtEx functions to specify the units and the orientation of the axes that you want. Graphics device interface (GDI) makes adjustments as necessary to ensure the x and y units remain the same size (for example, if you set the window extent, the viewport will be adjusted to keep the units isotropic).
MM_LOENGLISH Each logical unit is mapped to 0.01 inch. Positive x is to the right; positive y is up.
MM_LOMETRIC Each logical unit is mapped to 0.1 millimeter. Positive x is to the right; positive y is up.
MM_TEXT Each logical unit is mapped to one device pixel. Positive x is to the right; positive y is down.
MM_TWIPS Each logical unit is mapped to one twentieth of a printer's point (1/1440 inch, also called a "twip"). Positive x is to the right; positive y is up.
 
请问BlueGenie:您指的是哪个例子,我怎么没找到?
 
请继续讨论或结束问题
 
多人接受答案了。
 
后退
顶部