2009-07-29 3 views

답변

2

여기에 코드 예제 :

public partial class Form1 : System.Windows.Forms.Form 
{ 
    private const long BUTTON_DOWN_CODE = 0xa1; 
    private const long BUTTON_UP_CODE = 0xa0; 
    private const long WM_MOVING = 0x216; 

    static bool left_button_down = false; 

    protected override void DefWndProc(ref System.Windows.Forms.Message m) 
    { 
     //Check the state of the Left Mouse Button 
     if ((long)m.Msg == BUTTON_DOWN_CODE) 
      left_button_down = true; 
     else if ((long)m.Msg == BUTTON_UP_CODE) 
      left_button_down = false; 

     if (left_button_down) 
     { 
      if ((long)m.Msg == WM_MOVING) 
      { 
       //Set the forms opacity to 50% if user is moving 
       if (this.Opacity != 0.5) 
        this.Opacity = 0.5; 
      } 
     } 

     else if (!left_button_down) 
      if (this.Opacity != 1.0) 
       this.Opacity = 1.0; 

     base.DefWndProc(ref m); 
    } 
} 
3

흥미롭게도, 당신이이 OnResizeBegin에서 할도 수 OnResizeEnd이 우선합니다 -이 모두 이동하고 양식을 크기 조정에 적용됩니다.

움직일 때만 불투명도를 변경하고 크기를 변경하지 않을 경우에는 알렉스의 대답이 좋습니다.

관련 문제