Win32를 사용하는 코드를 사용하려고합니다. 그러나이 오류가 발생합니다 :Win32가 존재하지 않습니다. 어떻게 선언하거나 참조 할 수 있습니까?
The Name 'Win32' does not exist in the current context.
무엇이 누락 되었습니까? 어떻게 Win32를 호출/선언합니까?
public class TransparentTextBox : TextBox
{
PictureBox pictureBox = new PictureBox();
public TransparentTextBox()
{
pictureBox.Dock = DockStyle.Fill;
this.Controls.Add(pictureBox);
}
protected override void WndProc(ref Message m)
{
base.WndProc(ref m);
switch (m.Msg)
{
case Win32.WM_PAINT:
Bitmap bmpCaptured =
new Bitmap(this.ClientRectangle.Width, this.ClientRectangle.Height);
Bitmap bmpResult =
new Bitmap(this.ClientRectangle.Width, this.ClientRectangle.Height);
Rectangle r =
new Rectangle(0, 0, this.ClientRectangle.Width,
this.ClientRectangle.Height);
CaptureWindow(this, ref bmpCaptured);
this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
this.BackColor = Color.Transparent;
ImageAttributes imgAttrib = new ImageAttributes();
ColorMap[] colorMap = new ColorMap[1];
colorMap[0] = new ColorMap();
colorMap[0].OldColor = Color.White;
colorMap[0].NewColor = Color.Transparent;
imgAttrib.SetRemapTable(colorMap);
Graphics g = Graphics.FromImage(bmpResult);
g.DrawImage(bmpCaptured, r, 0, 0, this.ClientRectangle.Width,
this.ClientRectangle.Height, GraphicsUnit.Pixel, imgAttrib);
g.Dispose();
pictureBox.Image = (Image)bmpResult.Clone();
break;
case Win32.WM_HSCROLL:
case Win32.WM_VSCROLL:
this.Invalidate(); // repaint
// if you use scrolling then add these two case statements
break;
}
}
질문 편집 및 해당 코드 추가 – Davorin
여기에서 유용하지 않으므로 답변을 삭제했습니다. 나는 많은 도움이되는 행운을 얻지 못하고있다. – David