I am writing a combo box control and want to add the scrolling effect to
the dropdown list.
Any help would be appreciated
Chris
MM
http://www.fullspectrum.com/deeth
Chris Seils wrote in message ...
Tom
In article <949uff$2...@dispatch.concentric.net>,
Sent via Deja.com
http://www.deja.com/
The trick is that the window being animated has to handle WM_PRINT (even
when it's hidden).
VB forms do not, so you have to subclass it and handle WM_PRINT yourself.
Here's a sample... pardon the ugliness, I just threw it together.
Make a form. Throw some random controls on it (just so it's not boring and
empty). Paste the following code into it:
Option Explicit
Private Sub Form_Load()
gOldWndProc = SetWindowLong(Me.HWnd, GWL_WNDPROC, AddressOf WndProc)
AnimateWindow Me.HWnd, 200, awBottomToTop Or awSlide
End Sub
Private Sub Form_Unload(Cancel As Integer)
SetWindowLong Me.HWnd, GWL_WNDPROC, gOldWndProc
End Sub
Make a code module. Paste the following code into it:
Option Explicit
Enum AnimateWindowFlags
awSlide = &H40000
awActivate = &H20000
awBlend = &H80000
awHide = &H10000
awCenter = &H10&
awLeftToRight = 1
awRightToLeft = 2
awTopToBottom = 4
awBottomToTop = 8
End Enum
Declare Function AnimateWindow Lib "user32.dll" (ByVal HWnd As Long, ByVal
DurationMS As Long, ByVal Flags As AnimateWindowFlags) As Long
Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA"
(ByVal HWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA"
(ByVal lpPrevWndFunc As Long, ByVal HWnd As Long, ByVal Msg As Long, ByVal
WParam As Long, ByVal LParam As Long) As Long
Public Const GWL_WNDPROC As Long = -4
Public Const WM_PRINT As Long = 791
Public Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x
As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal
hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long)
As Long
Public Const SRCCOPY = &HCC0020
Global gOldWndProc As Long
Function WndProc(ByVal HWnd As Long, ByVal Message As Long, ByVal WParam As
Long, ByVal LParam As Long) As Long
If Message = WM_PRINT Then
With Form1
.AutoRedraw = True
BitBlt WParam, 0, 0, .Width \ Screen.TwipsPerPixelX, .Height \
Screen.TwipsPerPixelY, .hDC, 0, 0, SRCCOPY
.AutoRedraw = False
End With
End If
WndProc = CallWindowProc(gOldWndProc, HWnd, Message, WParam, LParam)
End Function
My handling of WM_PRINT is about as lame as you can get, but it works for
the sample. Yours should be better!
MM
http://www.fullspectrum.com/deeth
In article <94b0i1$2...@dispatch.concentric.net>,
"Murphy McCauley" <Murp...@Concentric.NET> wrote:
> tca...@my-deja.com wrote in message <94aac0$4uk$1...@nnrp1.deja.com>...
> >Yeah know, I've tried using AnimateWindow before (it seems very
simple)
> >but I didn't have any luck. Don't know what was wrong... If you have
> >any luck yourself, post a little code to enlighten us all!
> >
> >Tom
>
> The trick is that the window being animated has to handle WM_PRINT
(even
> when it's hidden).
> VB forms do not, so you have to subclass it and handle WM_PRINT
yourself.
>
> Here's a sample... pardon the ugliness, I just threw it together.
Thanks! Cool stuff!
Tom