Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8133271
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T09:33:13+00:00 2026-06-06T09:33:13+00:00

I’ve discovered how to disable the OK button in my Windows Mobile application (by

  • 0

I’ve discovered how to disable the “OK” button in my Windows Mobile application (by setting ControlBox to false).

The problem I had was that it was possible for me to close my application by pressing this “OK” button, but the FormClosing, FormClosed events were not fired, and most worrying, the form’s Dispose() method was not called either. This made it quite difficult to clean up things like threads and other resources.

Now that I can force the user to use my own “Quit” button, those methods all get executed as I would expect.

Question: why does the “OK” button in a Windows Mobile application close the application while bypassing the methods I mentioned?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T09:33:16+00:00Added an answer on June 6, 2026 at 9:33 am

    When you wrote the code for the FormClosing and FormClosed events, did you remember to wire the actual form up to use these?

    I have a few Windows Mobile applications that I maintain, and they call the methods I created for them.

    I often forget to set the Controls to use the code that I write for them, so that was the first thing I thought of.

    EDIT: I do not use Microsoft’s OK button, but instead make use of a Menu that has an EXIT Menu Item.

    Wm5 in GUI

    I also turn off the Soft Input Panel (SIP) and Task Bar by P/Invoking the “coredll” file in the Program.cs file before my main program executes.

    That may be a solution for you. If so, this should be all of the code I use for that. Be sure to test it, and if something is missing, let me know and I’ll update it.

    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);
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a
I have a text area in my form which accepts all possible characters from
I am currently running into a problem where an element is coming back from
I need a function that will clean a strings' special characters. I do NOT

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.