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

    Checking Shift State (Any)

    Thought this might be helpful or interesting for anyone
    trapping the Word dialog subs (as I do). The code below
    executes at the start of each dialog sub (FileClose,
    FileOpen, etc.) to test the state of the shift key. If it's down
    when the dialog is invoked, the user gets to by-pass the
    firm dialogs and use the built-in Word dialogs. Handy for
    troubleshooting situations too.

    Simple, but handy.

    <pre>Const VK_SHIFT = &H10
    Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer

    Function UseWordMethod(strMsg As String) As String
    If GetKeyState(VK_SHIFT) And &H8000 Then
    ans = MsgBox(strMsg, vbYesNoCancel, "Use Word Dialog?")
    Select Case ans
    Case vbYes
    UseWordMethod = "Yes"
    Case vbNo
    UseWordMethod = "No"
    Case vbCancel
    UseWordMethod = "Cancel"
    End Select
    Else
    UseWordMethod = "No"
    End If
    End Function

    </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>

  2. #2
    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: Checking Shift State (Any)

    The document management police will be beating down your door any minute now. <img src=/S/wink.gif border=0 alt=wink width=15 height=15>

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

    Re: Checking Shift State (Any)

    Ah, so I've stolen something from them?

    You can also use the shift state check to get a lot more mileage out of your command and toolbar buttons.
    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>

  4. #4
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Checking Shift State (Any)

    Is there a reason for declaring your own constant instead of using the built-in vbKeyShift? Granted, the VB constant probably won't work in WordBasic, but only Chris and Howard seem to care. <img src=/S/evilgrin.gif border=0 alt=evilgrin width=15 height=15>
    Charlotte

  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: Checking Shift State (Any)

    No, and since the only reason you can think of is a relatively minor concern, I'll change the code to reflect your insight. Thanks!
    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
  •