Animated GIF in VB and......

Hi all,

I want to integrate an animated gif into my application.
No problem there, just use a webbrowser control....
That won't work, because I want to show the ANIGIF in a MDIForm. So in the grayed background.

To get ANY picture onto the background of a MDIForm I placed a picturebox on another form, placed the gif in the picture box and then at MDIForm_Load I used the SetParent API to get the picture in the background location I want. That is no problem.
EXCEPT that the picture is ALWAYS on top of everything ! So if I open a childform, the childform is displayed beneath the picture !

So this question is really about two things:

1. How can I can the/any picture in the background of a MDIForm, any location I choose and keep it in the background (like ZOrder = 0).
2. The same for an animated GIF.

Thanks!

D'Mzzl!
RoverM
LVL 12
rovermAsked:
Who is Participating?
 
amebaConnect With a Mentor Commented:
2 easy steps:
     '1. find handle to the MDI Client Area
     mClientHwnd = FindWindowEx(Me.hWnd, 0, "MDIClient", vbNullString)

     '2. make your picturebox child of client mdi area
     SetParent picCnt.hWnd, mClientHwnd

Ref.:
"Create Background form in MDI client area"
http://www.geocities.com/ameba_vb/temp/mdibkform.html

"MdiBack.zip" sample http://www.mvps.org/vb/index2.html?samples.htm
0
 
rspahitzCommented:
Hey, Mark.
I've run across this, too.
As best as I can tell, the MDI form only allows controls on it that can be "aligned" such as pictureboxes.  Once added, they consume a certain amount of the work area which cannot be used by anything else.

When you add an MDI child form, it is not really going "behind" the controls but rather is going "out of bounds" and therefore generates scrollbars.  If it's possible to overcome this, I'd like to know too, so I'll be sticking around to hear what others have to say.
0
 
ArkCommented:
Probably, you also need set your picturebox windows style to WS_EX_MDICHILD (ORed with old style)

Cheers
0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

 
rovermAuthor Commented:
Bruno,

Thanks ! I downloaded the examples and that seemed to do the trick ! I will try it tonight in my project.
But now for the animated gif....

Rob,

Yes, I know. That's how I am doing it now. Using the SetParent API will prevent from letting the scrollbars appear, so no problem there. But Bruno's example will put the picture to the background, so that's one problem solved...

Ark,
How ?

Thanks all!

Mark
0
 
amebaCommented:
>Bruno's example will put the picture to the background.

Well, not totally in background, minimized forms will be covered.  That is why my example leaves some space at the bottom for one row of minimized forms.

Bruno
0
 
ArkCommented:
Hi

Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long

Const GWL_STYLE = (-16)
Const GWL_EXSTYLE = (-20)
Const WS_CHILD = &H40000000
Const WS_CLIPSIBLINGS = &H4000000
Const WS_CLIPCHILDREN = &H2000000
Const WS_EX_MDICHILD = &H40&

  lStyle = GetWindowLong(ChildhWnd, GWL_STYLE)
  lStyle = lStyle Or WS_CHILD Or WS_CLIPSIBLINGS Or WS_CLIPCHILDREN
  Call SetWindowLong(ChildhWnd, GWL_STYLE, lStyle)
  lStyle = GetWindowLong(ChildhWnd, GWL_EXSTYLE)
  lStyle = lStyle Or WS_EX_MDICHILD
  Call SetWindowLong(ChildhWnd, GWL_EXSTYLE, lStyle)

'Not sure you need all these stiles, but try them

Cheers
0
 
Richie_SimonettiIT OperationsCommented:
hearing...
0
 
rovermAuthor Commented:
Hi all,

Sorry, didn't have the change to try any of this last night, hopefully tonight.

D'Mzzl!
Mark
0
 
rovermAuthor Commented:
Ok:

Bruno, your method is working fine. The picture stays in the background now.

I used an OCX (thanks Richie) for the animation and placed it on the MDI background the same way. Works fine also.

Just one more thing: I don't like using an OCX because then I have to distribute it as well.
Can it be done using classes/modules/api's ?

Thanks!

D'Mzzl!
RoverM

0
 
amebaCommented:
>I don't like using an OCX
If you have OCX source, you can make it private - just add all files to your project.
0
 
rovermAuthor Commented:
Nope, don't have the source :-( Good idea tho!
0
 
amebaCommented:
Find something with source, maybe "AniCtrl.zip"
http://www.mvps.org/vb/index2.html?samples.htm
0
 
rovermAuthor Commented:
Bruno,
Thanks! Your code did it.

For the animation control I am using Richie's OCX. However, since Bruno also provided the link for the code of the OCX I am rewarding him with the full points.
I didn't want to use the OCX because then I had to distribute it as well, but I have to distribute another OCX (INet) anyways.

Richie:
Please collect your points here:
http://www.experts-exchange.com/questions/Q.20283402.html

Thank you both !

D'Mzzl!
Mark
0
 
amebaCommented:
Thank you for so many points  :-)
0
 
Richie_SimonettiIT OperationsCommented:
Thanks to you roverm, as always, you are welcome anytime with or without points!!
0
 
rovermAuthor Commented:
>> Thank you for so many points  
I've got WAAAAAAAAAAY too much of them..... LOL

Richie: You earned them!

D'Mzzl!
RoverM
0
 
ArkCommented:
Hi
For AniGif source take a look at http://www.freevbcode.com/ShowCode.Asp?ID=758 (I developed it for GIF87 format, so for new GIF89 it may work not correct).
Also, you may use IE object for shdocwv.dll. Open it with scroll = no, load gif file and make it child to MDI window.

Cheers
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.