FormClosing
및 FormClosed
이벤트에 대한 코드를 작성할 때 실제 양식을 연결하여 사용했는지 기억해 둡니까?
필자는 내가 유지 관리하는 몇 가지 Windows Mobile 응용 프로그램을 가지고 있으며이를 위해 만든 메서드를 호출합니다.
내가 자주 작성한 코드를 사용하도록 컨트롤을 설정하는 것을 잊어 버렸다. 그래서 내가 생각한 첫 번째 것이었다.
편집 : Microsoft의 OK
버튼을 사용하지 않고 EXIT 메뉴 항목이있는 메뉴를 사용합니다.
나는 또한 내 주요 프로그램을 실행하기 전에 Program.cs
파일에서 "coredll"파일을 호출/P에 의해 소프트 입력 패널 (SIP) 및 작업 표시 줄을 끄십시오.
해결 방법이 될 수 있습니다. 그렇다면이 코드는 내가 사용하는 모든 코드 여야합니다. 그것을 테스트하고, 뭔가 빠진 것이 있으면 알려주면 그것을 업데이트 할 것입니다.
const string COREDLL = "coredll.dll";
[DllImport(COREDLL, EntryPoint = "FindWindowW", SetLastError = true)]
public static extern IntPtr FindWindowCE(string lpClassName, string lpWindowName);
[DllImport(COREDLL, SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int x, int y, int cx, int cy, uint uFlags);
private static Form1 objForm = null;
private static IntPtr _taskBar = IntPtr.Zero;
private static IntPtr _sipButton = IntPtr.Zero;
[MTAThread]
static void Main() {
ShowWindowsMenu(false);
try {
objForm = new Form1();
Application.Run(objForm);
} catch (Exception err) {
objForm.DisableTimer();
if (!String.IsNullOrEmpty(err.Message)) {
ErrorWrapper("AcpWM5 Form (Program)", err);
}
} finally {
ShowWindowsMenu(true); // turns the menu back on
}
}
private static void ShowWindowsMenu(bool enable) {
try {
if (enable) {
if (_taskBar != IntPtr.Zero) {
SetWindowPos(_taskBar, IntPtr.Zero, 0, 0, 240, 26, (int)WindowPosition.SWP_SHOWWINDOW); // display the start bar
}
} else {
_taskBar = FindWindowCE("HHTaskBar", null); // Find the handle to the Start Bar
if (_taskBar != IntPtr.Zero) { // If the handle is found then hide the start bar
SetWindowPos(_taskBar, IntPtr.Zero, 0, 0, 0, 0, (int)WindowPosition.SWP_HIDEWINDOW); // Hide the start bar
}
}
} catch (Exception err) {
ErrorWrapper(enable ? "Show Start" : "Hide Start", err);
}
try {
if (enable) {
if (_sipButton != IntPtr.Zero) { // If the handle is found then hide the start bar
SetWindowPos(_sipButton, IntPtr.Zero, 0, 0, 240, 26, (int)WindowPosition.SWP_SHOWWINDOW); // display the start bar
}
} else {
_sipButton = FindWindowCE("MS_SIPBUTTON", "MS_SIPBUTTON");
if (_sipButton != IntPtr.Zero) { // If the handle is found then hide the start bar
SetWindowPos(_sipButton, IntPtr.Zero, 0, 0, 0, 0, (int)WindowPosition.SWP_HIDEWINDOW); // Hide the start bar
}
}
} catch (Exception err) {
ErrorWrapper(enable ? "Show SIP" : "Hide SIP", err);
}
}
'확인'버튼이나 'X', 'IIRC'버튼을 누르면 응용 프로그램이 닫히지 않고 숨겨진 것입니다. 다시 실행하면 다시 가져옵니다. 위로. 나는 '확인'버튼이 대화창 창에만 표시되었다고 생각합니다. – Matt
IIRC <- 버튼은 실제로 앱 또는 앱의 현재 창을 닫습니다. –
"확인"버튼입니다. 내 응용 프로그램은 모달이 아닙니다. –