Re: [問題] 請問要怎麼樣讓按鈕會移動

看板C_and_CPP (C/C++)作者 (薯)時間16年前 (2009/08/23 00:46), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串3/3 (看更多)
※ 引述《maplefog (楓霧)》之銘言: : 這個有二種解決方法 我講簡單這個,另一個是用DragDrop和DragOver : Button是動態產生也可以用 : 程式碼 : void __fastcall TForm1::Button1MouseUp(TObject *Sender, TMouseButton Button, : TShiftState Shift, int X, int Y) : { : int WIDTH = ((TButton*)Sender)->Width; : int HEIGHT = ((TButton*)Sender)->Height; : ((TButton*)Sender)->Left = ((TButton*)Sender)->Left+X-WIDTH/2; : ((TButton*)Sender)->Top = ((TButton*)Sender)->Top+Y-HEIGHT/2; : } : 試試看吧 我把方向轉換一下 switch(Key) { case 87: A->Top= A->Top-5; //上 break; case 83: A->Top= A->Top+5; //下 break; case 65: A->Left= A->Left-5; //左 break; case 68: A->Left= A->Left+5; //右 break; } 把方向鍵(37~40)改成CS裡常使用的WSAD 發現Button可以動了 而我有寫另外按下按鍵顯示他們的值的程式碼 Label3->Caption= Key; 以及放開按鍵顯示按鍵的值 Label4->Caption= Key; 發現按鍵盤上的方向鍵← → ↑ ↓ 這兩個Label並不會顯示任何東西 這是為什麼呢? 另外 今天我按'e'這個按鍵 Label3->Caption= Key; 顯示的值是69 Label4->Caption= Key; 顯示的值是'e' 為什麼會有這個差別? 兩者不應該是一樣的嗎? -- 肝不好 肝若好 人生無法起跑 程式沒有辦法跑 、 ﹐ ● ●b ▎ ●> ● ▌ ﹍﹍ 囧> 幹... ▲ ■┘ ▎ ■ ▋ ︶■ 〈﹀ ∥ ▁▁∥ ▎ ﹀〉▊ 〈\ ψcockroach727 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 118.232.53.48 ※ 編輯: liu2007 來自: 118.232.53.48 (08/23 00:48)
文章代碼(AID): #1Aa23GPo (C_and_CPP)
文章代碼(AID): #1Aa23GPo (C_and_CPP)