关于HANDLE的一个疑问! |
答題得分者是:shaofu
|
xiaoning79627
初階會員 發表:46 回覆:60 積分:26 註冊:2002-11-10 發送簡訊給我 |
各位先进,我最近在用SetCaptureControl时发现在VCL中的定义
[CODE]
procedure SetCaptureControl(Control: TControl);
begin
ReleaseCapture;
CaptureControl := nil;
if Control <> nil then
begin
if not (Control is TWinControl) then
begin
if Control.Parent = nil then Exit;
CaptureControl := Control;
Control := Control.Parent;
end;
SetCapture(TWinControl(Control).Handle);//请留意这
end;
end;
我用SetCapture(TWinControl(Image1).Handle)不会出错,TIMAGE不属于TWinControl,为什么可以这样用,此时的Handle代表什么?谢谢 發表人 - xiaoning79627 於 2003/07/15 14:41:05
|
william
版主 發表:66 回覆:2535 積分:3048 註冊:2002-07-11 發送簡訊給我 |
The way you type cast will not check for type compatibility, and you can even do this: TWinControl(pointer(1)).Handle. The handle returned of course is invalid (or access violation in some cases). If you want type checking, you can use as: (AObject as TWinControl).Handle. The simple answer to your original question is: The handle returned is invalid.
|
shaofu
高階會員 發表:5 回覆:136 積分:103 註冊:2003-01-07 發送簡訊給我 |
|
xiaoning79627
初階會員 發表:46 回覆:60 積分:26 註冊:2002-11-10 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |