2009-11-04 6 views
0

Windows Mobile 6의 백그라운드에서 응용 프로그램을 실행하는 즉시 응용 프로그램을 최소화 할 수 있습니까? 자동 실행 (예 : 자동 시작) 및 나중에 응용 프로그램을 보려는 경우 프로그램 메뉴 등에서 실행할 수있는 응용 프로그램을 최소화하고 싶습니다.응용 프로그램을 시작하자마자 최소화하는 방법은 무엇입니까?

일부 코드는 시도했지만 작동하지 않습니다. ! 이 (심지어이 코드가 작동하지 않습니다)을 다시 사용자에게 응용 프로그램을 표시하지 않습니다이 코드를 사용하여 나의 문제가 해결되지 않습니다 있지만

private void GUI_Load(object sender, EventArgs e) 
{      
    this.Hide(); 
    this.Visible = false; 
} 

와 두 번째 옵션은 기본 호출하는 것입니다, 계획을 최소화

전통 API (출처 : http://www.blondmobile.com/2008/04/windows-mobilec-how-to-minimize-your_5311.html)

private void GUI_Load(object sender, EventArgs e) 
{      
    this.HideApplication(); 
} 

[DllImport("coredll.dll")] 
static extern int ShowWindow(IntPtr hWnd, int nCmdShow); 

const int SW_MINIMIZED = 6; 

public void HideApplication() 
{ 
     ShowWindow(this.Handle, SW_MINIMIZED); 
} 

두 번째 코드는 프로그램의 다른 부분에서 작업을 수행,하지만로드 이벤트에서.

+0

두 번째 방법은로드 이벤트에서 작동하지 않습니다 작동하기 때문에 아직 그것을 최소화 할 수 없습니다. OnActivated 또는 OnShow에서 HideApplication을 호출 해 보았습니까? –

+0

그것은 작동, 나는 그것을 한 번만 숨길 수있는 varible을 사용해야한다고 생각합니다! – zHs

+0

아니요, OnActivated 이벤트가 작동하지 않으므로 타이머가 유일한 해결책입니다! – zHs

답변

2

생각 유일한 해결책은 System.Windows.Forms.Timer을 사용하고 폼이 완전히 초기화되지 않기 때문에 그것은

private void GUI_Load(object sender, EventArgs e) 
{       
// Initialize timer to hide application when automatically launched 
_hideTimer = new System.Windows.Forms.Timer(); 
_hideTimer.Interval = 0; // 0 Seconds 
_hideTimer.Tick += new EventHandler(_hideTimer_Tick); 
_hideTimer.Enabled = true; 
} 

// Declare timer object 
System.Windows.Forms.Timer _hideTimer; 
void _hideTimer_Tick(object sender, EventArgs e) 
{ 
    // Disable timer to not use it again 
    _hideTimer.Enabled = false; 
    // Hide application 
    this.HideApplication(); 
    // Dispose timer as we need it only once when application auto-starts 
    _hideTimer.Dispose(); 
} 

[DllImport("coredll.dll")] 
static extern int ShowWindow(IntPtr hWnd, int nCmdShow); 

const int SW_MINIMIZED = 6; 

public void HideApplication() 
{ 
     ShowWindow(this.Handle, SW_MINIMIZED); 
} 
관련 문제