我有图片盒的问题。我正在创建游戏启动器,当我点击图片框(按钮的角色)时,我想将表格背景图像更改为不同的图像。没关系,但是图片框有透明的背景颜色,所以图片框的背景依赖于Form bg图像。这是我的问题 - 图片框的背景更改晚于Form bg img。
我该如何解决这个问题?
点击之前:http://postimg.org/image/pubpcm6wd/ 间期(问题):http://postimg.org/image/zf4fa97hj/(我只能看到它几毫秒)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Runtime.InteropServices;
using System.Diagnostics;
using System.Net;
namespace posteruslauncher
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
domu.Visible = false;
}
//Pohyb okna
[DllImport("user32.dll")]
public static extern bool ReleaseCapture();
[DllImport("user32.dll")]
public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);
public const int WM_SYSCOMMAND = 0x0112;
public const int SC_MOVE = 0xF010;
public const int HTCAPTION = 0x0002;
private void Form1_MouseDown(object sender, MouseEventArgs e)
{
//Po kliknutí možno hýbat s launcherem
ReleaseCapture();
SendMessage(this.Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0);
}
//DOMŮ - BUTTON
private void domu_MouseEnter(object sender, EventArgs e)
{
domu.BackgroundImage = ((System.Drawing.Image)(Properties.Resources.domu2));
}
private void domu_MouseLeave(object sender, EventArgs e)
{
domu.BackgroundImage = posteruslauncher.Properties.Resources.domu1;
}
private void domu_Click(object sender, EventArgs e)
{
novinky.Visible = true;
domu_clicked.Visible = true;
domu.Visible = false;
this.BackgroundImage = posteruslauncher.Properties.Resources.background;
}
// NOVINKY - BUTTON
private void novinky_MouseEnter(object sender, EventArgs e)
{
novinky.BackgroundImage = posteruslauncher.Properties.Resources.novinky2;
}
private void novinky_MouseLeave(object sender, EventArgs e)
{
novinky.BackgroundImage = posteruslauncher.Properties.Resources.novinky1;
}
private void novinky_Click(object sender, EventArgs e)
{
domu.Visible = true;
domu_clicked.Visible = false;
novinky.Visible = false;
this.BackgroundImage = posteruslauncher.Properties.Resources.background_novinky;
}
}
}
答案 0 :(得分:0)
我建议使用SuspendLayout()和ResumeLayout()暂时挂起布局以自绘图。我不确定你的语言是什么,但这是一个例子:
private void novinky_Click(object sender, EventArgs e)
{
this.SuspendLayout();
domu.Visible = true;
domu_clicked.Visible = false;
novinky.Visible = false;
this.BackgroundImage = posteruslauncher.Properties.Resources.background_novinky;
this.ResumeLayout();
}