程式中用 tpanel 做了容器, 需要給它乙個背景; 發現這竟是個難題!
發現我經常使用的滾動箱控制項 tscrollbox, 是乙個很好的替代品.
本例效果圖:
**檔案:
unit unit1;窗體檔案:inte***ce
uses
windows, messages, sysutils, variants, classes, graphics, controls, forms,
dialogs, stdctrls;
type
tform1 = class(tform)
scrollbox1: tscrollbox;
button1: tbutton;
button2: tbutton;
button3: tbutton;
button4: tbutton;
procedure formcreate(sender: tobject);
procedure formdestroy(sender: tobject);
procedure button1click(sender: tobject);
procedure button2click(sender: tobject);
procedure button3click(sender: tobject);
procedure button4click(sender: tobject);
end;
var form1: tform1;
implementation
var bg1,bg2: tbitmap;
procedure tform1.formcreate(sender: tobject);
begin
bg1 := tbitmap.create;
bg2 := tbitmap.create;
bg1.loadfromresourcename(hinstance, 'bitmap1');
bg2.loadfromresourcename(hinstance, 'bitmap2');
end;
procedure tform1.formdestroy(sender: tobject);
begin
bg1.free;
bg2.free;
end;
procedure tform1.button1click(sender: tobject);
begin
with scrollbox1 do
begin
bevelkind := bksoft;
bevelouter := bvraised;
borderstyle := bsnone;
autoscroll := false;
end;
end;
procedure tform1.button2click(sender: tobject);
begin
self.brush.bitmap := bg1;
self.refresh;
end;
procedure tform1.button3click(sender: tobject);
begin
scrollbox1.brush.bitmap := bg2;
scrollbox1.refresh;
end;
procedure tform1.button4click(sender: tobject);
begin
if self.brush.bitmap = bg1 then
begin
self.brush.bitmap := bg2;
scrollbox1.brush.bitmap := bg1;
end else begin
self.brush.bitmap := bg1;
scrollbox1.brush.bitmap := bg2;
end;
self.refresh;
scrollbox1.refresh;
end;
end.
object form1: tform1left = 0
top = 0
caption = 'form1'
clientheight = 195
clientwidth = 364
color = clbtnface
font.charset = default_charset
font.color = clwindowtext
font.height = -11
font.name = 'tahoma'
font.style =
oldcreateorder = false
oncreate = formcreate
ondestroy = formdestroy
pixelsperinch = 96
textheight = 13
object scrollbox1: tscrollbox
left = 32
top = 32
width = 185
height = 137
taborder = 0
endobject button1: tbutton
left = 240
top = 32
width = 105
height = 25
caption = #28378#21160#31665#26679#24335
taborder = 1
onclick = button1click
endobject button2: tbutton
left = 240
top = 69
width = 105
height = 25
caption = #31383#20307#32972#26223
taborder = 2
onclick = button2click
endobject button3: tbutton
left = 240
top = 106
width = 105
height = 25
caption = #28378#21160#31665#32972#26223
taborder = 3
onclick = button3click
endobject button4: tbutton
left = 240
top = 143
width = 105
height = 25
caption = #20114#25442#32972#26223
taborder = 4
onclick = button4click
endend
模擬乙個js new乙個物件的過程
function person person.prototype.getname function function createobj var a createobj person console.log a 上述 createobj 模擬了js new乙個物件的過程,從該函式的 中可以清晰的看到...
編寫乙個移動的遊戲背景
教程目錄 1.小遊戲展示 3.創作乙個移動的背景 4.讓阿菌煽動翅膀 5.讓阿菌模擬重力下墜 6.讓阿菌可以摸魚 7.編寫遊戲開始與結束 8.編寫 boss 劇情 9.部署到伺服器,在手機玩耍 進入工程專案後就可以開始開發了,首先我們把遊戲所用到的等資源檔案放到assets目錄中 然後我們設定遊戲畫...
兩個棧模擬乙個佇列 兩個佇列模擬乙個棧
解題思路 插入操作在stack1中進行,刪除操作在stack2中進行,如果stack2為空,則將stack1中的所有元素轉移到stack2中。include include includeusing namespace std template class cqueue 建構函式 template ...