續: 如何在mousedown的位置顯示一個小圖案 |
尚未結案
|
ayy
一般會員 發表:5 回覆:9 積分:2 註冊:2003-06-22 發送簡訊給我 |
對不起! 請容許我問同樣的問題.
我想在mousedown的位置显示一个小图案 .bmp 或 .ico.
我试过 Hagar 建議的方法,寫了以下程式,但没有任何反应? 问题在哪? unit Unit1; interface uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls; type
TForm1 = class(TForm)
Image1: TImage; //載入圖案 procedure Form1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
private
{ Private declarations }
public
{ Public declarations }
end; var
Form1: TForm1; implementation {$R *.dfm} procedure TForm1.Form1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
Image1.Left := X;
Image1.Top := Y;
end; end.
|
Justmade
版主 發表:94 回覆:1934 積分:2030 註冊:2003-03-12 發送簡訊給我 |
你在設計時己在 Image1 載好了 picture 了嗎 ? 你是否設定了 Visible 是 False (不顯示) ? 若兩皆是的話,可以 :
procedure TForm1.Form1MouseDown(Sender: TObject; Button: TMouseButton;Shift: TShiftState; X, Y: Integer); begin Image1.Left := X; Image1.Top := Y; Image1.Visible := true; end; procedure TForm1.Form1MouseUp(Sender: TObject; Button: TMouseButton;Shift: TShiftState; X, Y: Integer); begin Image1.Visible := false; end;若 Image1 的 圖要動態才載入,你需要在顯示前載入圖片,如可以在 FormCreate 加入 : Image1.Picture.LoadFromFile('C:\test.bmp'); 1. 修改 標錯 code 2. 另你已載入圖案改成我上述的程式應可行 3. 若你Mouse 放手時不需隱藏便不用 Form1MouseUp 那段 發表人 - Justmade 於 2003/07/02 17:01:31 |
ayy
一般會員 發表:5 回覆:9 積分:2 註冊:2003-06-22 發送簡訊給我 |
我也不知道是否正確載入image1, 第一次接觸.以下是dfm文件, 麻煩大家看看! object Form1: TForm1
Left = 234
Top = 396
Width = 696
Height = 480
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object Image1: TImage
Left = 608
Top = 24
Width = 49
Height = 41
Picture.Data = {
07544269746D6170F6160000424DF61600000000000036040000280000003C00
………} //很長的一段code
Visible = False
end
end <--沒有begin, 為何有end?
|
ayy
一般會員 發表:5 回覆:9 積分:2 註冊:2003-06-22 發送簡訊給我 |
|
ayy
一般會員 發表:5 回覆:9 積分:2 註冊:2003-06-22 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |