Results 1 to 5 of 5
  1. #1
    5 Star Lounger
    Join Date
    Mar 2001
    Location
    New York, NY
    Posts
    922
    Thanks
    2
    Thanked 12 Times in 11 Posts

    System Controls (Word 02)

    We would like to disable the Exit/Close "X" of the System Controls for Word XP. I've been given some code that uses API calls to do this, but it works only on the open document of the MDI.

    Is there a good way to disable this System Control for the session in Word XP? Perhaps there is a policy that can be set to control this. (The DMS sometimes has trouble trapping the close when the X is used, and the document doesn't get checked back in correctly.)

    Thanks,
    Richard Barrett

  2. #2
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: System Controls (Word 02)

    I think it's best to put the remove code in the autoexec sub of a global template for VBA apps. Normal.dot will
    have to do if you don't have any other. You may also need to delay the execution so that Word has completely
    started before the coded executes. The API functions referenced below are NOT included in this post.

    <pre>Sub AutoExec()
    Application.ActiveWindow.SetFocus
    Application.OnTime When:=Now + TimeValue("00:00:03"), Name:="RemoveWordCloseButton"
    End Sub

    Sub RemoveWordCloseButton()
    Dim hMenu As Long
    Dim hWnd As Long
    Dim menuItemCount As Long
    Const MF_BYPOSITION = &H400
    Const MF_REMOVE = &H1000

    hWnd = FindWindow("OpusApp", vbNullString)
    hMenu = GetSystemMenu(hWnd, 0)
    If hMenu Then
    menuItemCount = GetMenuItemCount(hMenu)
    Call RemoveMenu(hMenu, menuItemCount - 1, MF_REMOVE Or MF_BYPOSITION)
    'Remove the control (system) menu separator line
    Call RemoveMenu(hMenu, menuItemCount - 2, MF_REMOVE Or MF_BYPOSITION)
    Call DrawMenuBar(hWnd)
    End If
    End Sub
    </pre>

    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  3. #3
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: System Controls (Word 02)

    A frequent topic of discussion. See if these threads help:

    Fake System Menu/Title Bar (2000+)
    Function Override Not Functioning (Word 2002)

  4. #4
    5 Star Lounger
    Join Date
    Mar 2001
    Location
    New York, NY
    Posts
    922
    Thanks
    2
    Thanked 12 Times in 11 Posts

    Re: System Controls (Word 02)

    Hi Kevin,

    Thanks for your reply. The code works well... but only if I'm using the single document interface (Show Windows in Taskbar = False). We use the MDI, and the code affects only the document that's open at the time it runs. New documents have the system control enabled (unless the original doc is closed first), and any documents which are opened also do not have the X disabled. This makes sense to me, unfortunately. I've placed the code in the AutoExec of a global template. I have another global template with a class module which I use to trap DocumentOpen and DocumentNew (among other) events. I suppose I could add this code for each new and each opened document. Any ideas on this?

    Thanks.
    Richard

  5. #5
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: System Controls (Word 02)

    Well, you do have a unique situation there. I've tested this as it might apply to our app as well, and yes indeed, if you turn on MDI and open a document the previously disabled BigX is now enabled. But the real trouble is this: if you make the doc dirty, then click the BigX, you're back to square one on how to trap the filesave prompt. Your "discovery" only emphasizes THE WORST problem with MS Word (from a developer's point of view). And I don't hear anyone, not even our beloved Woody or any MVP, ever mention it: there is no SystemControlMenuClose_Click event! It took a WMVP to say it, so there. You have to rely on a combination of the almost useless Application events (really only DocumentOpen and DocumentNew are useful) and the VBA Event Subs (without which we'd have no application, let alone an MS award winning application). This mess means you cannot write a Close and Save events trapping application in a com-addin without a global addin (.dot) with VBA code. I know people think I'm nuts, but I'd love to be proved wrong. So far, silence.

    Any chance you can convince the powers that be to use SDI instead? Of course, then you need to disable the check box in Options. BTW, how do you disable the ShowWindowsInTaskBar check box? Maybe there's a reg setting we can get at via a policy...
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •