응용 프로그램에서 작업 할 때 해당 프로젝트에 대한 첫 번째 사용자 컨트롤을 추가하기로 결정했습니다. 나는 그것을 잘 만들었지 만 도구 상자에서 기본 양식으로 드래그하면 오류 메시지가 나타납니다.
내가 무엇을하든 그것을 고치지 않는 것 같습니다. 코드를 통해 추가해 보았지만 전혀 나타나지 않을 것입니다.
온라인으로 문제를 살펴보면서 나는 작동하는 해결책을 찾을 수 없었거나 적어도 내가 따르고 이해할 수있는 해결책을 찾지 못했습니다.
도움을 주시면 감사하겠습니다. 더 많은 정보가 필요하면 추가해 드리겠습니다. 그러나 현재 나는 어떤 용도로든 추가 할 수있는 것이 무엇인지 모르겠습니다.
이 코드는 단순한 장난 바이러스를위한 것입니다. (계속해서 코드를 배우도록 영감을주세요 :)) 여기에 코드가 있습니다 ( 파일을 실행하지 마십시오. 결국 장난 바이러스입니다. 종료하는 유일한 방법은 alt +입니다. f4 ) :
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Imaging;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Simple_virus_V2
{
public partial class Form1 : Form
{
[DllImport("user32.dll")]
internal static extern IntPtr SetForegroundWindow(IntPtr hWnd);
[DllImport("user32.dll")]
internal static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
public Form1()
{
InitializeComponent();
timer1.Start();
timer2.Start();
Thread newthread = new Thread(progress);
newthread.Start();
}
Random rnd = new Random();
int noticewidth = 0;
bool changecursor = false;
private void progress() {
Thread.Sleep(1000);
changecursor = true;
Thread.Sleep(1000);
timer3.Start();
Thread.Sleep(5000);
noticewidth = Width;
}
int mouseflash = 0;
private void timer1_Tick(object sender, EventArgs e)
{
if (changecursor) {
if (mouseflash < 1000)
{
Bitmap cursor = new Bitmap(new Bitmap(pictureBox1.Image), 24, 24);
Cursor = new Cursor(cursor.GetHicon());
} else if (mouseflash < 1700) {
Bitmap cursor = new Bitmap(new Bitmap(pictureBox2.Image), 30, 30);
Cursor = new Cursor(cursor.GetHicon());
}
else {
mouseflash = 0;
}
mouseflash = mouseflash + rnd.Next(3,10);
}
header.Left = MousePosition.X - (header.Width / 2);
label2.Left = MousePosition.X - (label2.Width / 2);
label3.Left = label2.Left + 25;
panel1.Width = noticewidth;
this.Location = new Point(0,0);
panel1.Location = new Point(0, MousePosition.Y - 40);
this.WindowState = FormWindowState.Maximized;
TopMost = true;
Process currentProcess = Process.GetCurrentProcess();
IntPtr hWnd = currentProcess.MainWindowHandle;
if (hWnd != IntPtr.Zero)
{
SetForegroundWindow(hWnd);
ShowWindow(hWnd, int.Parse("9"));
}
Focus();
this.Width = Screen.PrimaryScreen.Bounds.Width * 3;
this.Height = Screen.PrimaryScreen.Bounds.Height * 2;
}
private void Form1_KeyPress(object sender, KeyPressEventArgs e)
{
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
/*
using (Form1 frm = new Form1()) {
if (frm.ShowDialog() == DialogResult.OK) {
}
}
*/
}
private void timer2_Tick(object sender, EventArgs e)
{
PictureBox pic = new PictureBox();
pic.Width = 1;
pic.Height = 1;
pic.BackColor = Color.Black;
pic.Location = new Point(rnd.Next(0, this.Width), rnd.Next(0, this.Height));
this.Controls.Add(pic);
}
private void timer3_Tick(object sender, EventArgs e)
{
/*
bartry bars = new bartry();
bars.Location = new Point(0, rnd.Next(0, 500));
Controls.Add(bars);
timer3.Interval = rnd.Next(100, 5000);
*/
}
}
}
감사
다른 게시물에 대한 답변을 시도한 후에도 아무도 작동하지 않았습니다. 새 프로젝트를 열고 내 코드를 실험 한 후에 해결책을 찾았습니다.
해결 방법 : 사용자 정의 컨트롤과 기본 양식에 동일한 "사용"참조가 있는지 확인하십시오!
이게 자명하다면 미안하지만 그렇게해야한다는 것을 몰랐습니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다