AppBar Form not positioning

  • Follow


Hi all,

I've got another perplexer.  I'm making a Bible Verse program that
docks to either the top or bottom of the desktop (My testing has it
docking at the bottom).  The Docking form is just a thin (4 pixels
high) bar that is used to detect the mouseover that pops up the other
(VerseForm) form that has the actual verse on it.  As you can see from
the code below (which is executed in the VerseForm Load event), I
register the form, check the position/area of the desktop, then SETPOS
to dock the VerseBar form.  Then at the end I use SetWinPos API to
position both the VerseBar and VerseForm forms.

The problem is, when this code executes in the IDE everything comes up
correctly, once it's compiled it pops up the forms in the upper left
quarter and not in full size...actually, it looks like the sizes given
as the default in development.  It's as though the SetWinPos APIs
don't complete before ending the startup processing, which leaves them
hanging up in the desktop instead of docking the one and positioning
the other just above it.  I've tried changing the second param, as
well as the flags (last) to other values, none of which altered the
result.

Prior to this I had trouble with them doing the same thing in the IDE
except when I stepped through the code.  To resolve that problem I had
to Show the VerseBar form before using SetWinPos.  It didn't make much
sense that I had to Show the form before it would position correctly,
but I figured I'd do what I needed to, to get it to work  <g>

Thanks for any insight,
Shell
P.S.  Watch for line wrapping!

Private Sub SetForm_AppBar()
Dim lResult As Long

    Load VerseBar
    BarData.cbSize = Len(BarData)
    BarData.hwnd = VerseBar.hwnd
    BarData.uCallbackMessage = WM_USER + 100
    lResult = SHAppBarMessage(ABM_NEW, BarData)
    
    If VerseOpt.opPos(0) Then BarData.uEdge = ABE_TOP _
        Else BarData.uEdge = ABE_BOTTOM
    BarData.rc.Left = 0
    BarData.rc.Top = 0
    BarData.rc.Right = glScreenWidth
    BarData.rc.Bottom = glScreenHeight
    lResult = SHAppBarMessage(ABM_QUERYPOS, BarData)
    
    If BarData.uEdge = ABE_TOP Then
        BarData.rc.Bottom = BarData.rc.Top + (VerseBar.Height \
glTwipsPerPixelY)
    Else
        BarData.rc.Top = BarData.rc.Bottom - (VerseBar.Height \
glTwipsPerPixelY)
    End If
    
    lResult = SHAppBarMessage(ABM_SETPOS, BarData)
    
    gvVersePos.Left = BarData.rc.Left
    gvVersePos.Right = BarData.rc.Right
    If BarData.uEdge = ABE_TOP Then
        gvVersePos.Top = BarData.rc.Bottom
        gvVersePos.Bottom = BarData.rc.Bottom + (Me.Height \
glTwipsPerPixelY)
    Else
        gvVersePos.Top = BarData.rc.Top - (Me.Height \
glTwipsPerPixelY)
        gvVersePos.Bottom = BarData.rc.Top
    End If
    Me.Visible = True
    Me.Show
    lResult = SetWindowPos(Me.hwnd, VerseBar.hwnd, gvVersePos.Left,
gvVersePos.Top, gvVersePos.Right - gvVersePos.Left, gvVersePos.Bottom
- gvVersePos.Top, SWP_NOACTIVATE)
    VerseBar.Show
    lResult = SetWindowPos(VerseBar.hwnd, HWND_TOP, BarData.rc.Left,
BarData.rc.Top, BarData.rc.Right - BarData.rc.Left, BarData.rc.Bottom
- BarData.rc.Top, SWP_NOACTIVATE)
End Sub

0
Reply drshell (102) 1/16/2007 5:15:48 AM

In response to the post:
 On Tue, 16 Jan 2007 05:15:48 GMT, Shell <drshell@mindspring.com>
stated...and I replied:

No one can help me with this?
0
Reply drshell (102) 1/17/2007 10:18:40 PM


In response to the post:
 On Wed, 17 Jan 2007 22:18:40 GMT, Shell <drshell@mindspring.com>
stated...and I replied:

>In response to the post:
> On Tue, 16 Jan 2007 05:15:48 GMT, Shell <drshell@mindspring.com>
>stated...and I replied:
>
>No one can help me with this?

Well, it's a slow process but I've figured out how to do certain
things with workarounds.  I'm not using the AutoHide registry due to
the limitation of one per edge, but I have a faked autohide form that
pops up a full form.

More later,
Shell

0
Reply drshell (102) 1/19/2007 8:20:11 AM

2 Replies
30 Views

(page loaded in 0.098 seconds)


Reply: