Jump to content
Sign in to follow this  
xcv

Camner Nak Tarik Form_paint Kat Dalam Coding

Recommended Posts

akum dan salam sejahtera... saya ader satu masalah kat sinie.. saya paintkan background kat form tuh.. nie utk compact frameworknyer... so sayer ader coding camneh..

private void menuTingkat_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
  {
  	e.Graphics.DrawImage(backGround,this.ClientRectangle,new Rectangle(0,0,this.backGround.Width,this.backGround.Height),GraphicsUnit.Pixel);
  }

saya dah boleh repaintkan background form maser form tuh load pertama kali.. tapik biler saya try tuka background (semasa program jalan) dengan tukarkan image backGround. Background tak tukar. Saya raser.. menuTingkat_Paint tuh tak dipanggil. Macam maner sayer nak tarik bender tuh?atau fungsi menuTingkat_Paint tuh? thanks...

Share this post


Link to post
Share on other sites

nak tengok function ko tu dipanggil, cube le letak messagebox satu.

sori, aku tak de c# kompiler la untuk ditest. aku da uninstall. free space aku mengecil sad.gif

Share this post


Link to post
Share on other sites

sowi kalau soalan aku mengelirukan.. camnie.. menuTingkat_Paint tuh funtion form punyer. Bukan sayer yang create. So biler form tue di load kali pertama function tuh boleh dijalankan. biler saya cuber nak paintkan sekali lagi dalam form yang samer.. sayer tak lih nak repaint. Description untuk fungsi Paint tuh ialah Occurs when controls need repainting. Contoh probleam camnie :

1)saya bukak form tuh.

2)gambar A dapat paint.

3) saya click button utk tukar gambar A tuh.cth tukar gambar B

sampai kat situ jer, sayer dah tak reti camner nak panggil menuTingkat_Paint tue. object sender nak letak per?System.Windows.Forms.PaintEventArgs e nak letak per? thanks...

Share this post


Link to post
Share on other sites

Jangan panggil event handler secara terus, itu perbuatan yg tak sihat.

Kita kena create event yg berkaitan. Dalam kes event Paint ni, sebenarnya benda yg kena dipanggil ialah menuTingkat.Invalidate() ..sejarah "invalidate" ni adalah dari zaman win32, dia mana utk ada function InvalidateRect yg fungsinya memberi tahu bhw paparan tersebut sudah tidak valid lagi, jadi event Repaint atau Paint akan dipanggil utk melukis balik paparan tu.

Share this post


Link to post
Share on other sites

emm. betul tu. lupe lak pasal Invalidate method laugh.gif ahaks

cube tambah lepas ko klik button tu..

this.Invalidate()

Share this post


Link to post
Share on other sites

oho.. thanks.. aku akan cuba. Thanks bebanyak.. nanti aku bagitau result dier... smile.gif err.. tambahan... Invalidate() nih akan panggey sumer function form tuh ea? <-- tul ker tak ayat aku... ker Paint jer? Load dan sebagainyer tak ea?

Edited by xcv

Share this post


Link to post
Share on other sites

oho.. thanks.. aku akan cuba. Thanks bebanyak.. nanti aku bagitau result dier...  smile.gif err.. tambahan... Invalidate() nih akan panggey sumer function form tuh ea? <-- tul ker tak ayat aku... ker Paint jer? Load dan sebagainyer tak ea?

macam 1kHz tu cakap. pastu yang kod aku bagi tu, die akan 'invalidate' form (this). mase method ni di panggil, then die akan menyebabkan paint message (biasenye OnPaint) dipanggil untuk kontrol tersebut (in this case, form a.k.a this). sebab tu la die kate "Occurs when controls need repainting". cube dulu k happy.gif

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...