Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Animated GIF in VB and......

Posted on 2002-03-26
17
Medium Priority
?
420 Views
Last Modified: 2008-02-07
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
0
Comment
Question by:roverm
  • 6
  • 5
  • 3
  • +2
17 Comments
 
LVL 22

Expert Comment

by:rspahitz
ID: 6897843
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
 
LVL 15

Accepted Solution

by:
ameba earned 1200 total points
ID: 6898041
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
 
LVL 28

Expert Comment

by:Ark
ID: 6898459
Probably, you also need set your picturebox windows style to WS_EX_MDICHILD (ORed with old style)

Cheers
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 12

Author Comment

by:roverm
ID: 6898566
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
 
LVL 15

Expert Comment

by:ameba
ID: 6898579
>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
 
LVL 28

Expert Comment

by:Ark
ID: 6898583
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
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6900585
hearing...
0
 
LVL 12

Author Comment

by:roverm
ID: 6901890
Hi all,

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

D'Mzzl!
Mark
0
 
LVL 12

Author Comment

by:roverm
ID: 6903563
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
 
LVL 15

Expert Comment

by:ameba
ID: 6903593
>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
 
LVL 12

Author Comment

by:roverm
ID: 6903656
Nope, don't have the source :-( Good idea tho!
0
 
LVL 15

Expert Comment

by:ameba
ID: 6903684
Find something with source, maybe "AniCtrl.zip"
http://www.mvps.org/vb/index2.html?samples.htm
0
 
LVL 12

Author Comment

by:roverm
ID: 6908735
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
 
LVL 15

Expert Comment

by:ameba
ID: 6909014
Thank you for so many points  :-)
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6909116
Thanks to you roverm, as always, you are welcome anytime with or without points!!
0
 
LVL 12

Author Comment

by:roverm
ID: 6909175
>> Thank you for so many points  
I've got WAAAAAAAAAAY too much of them..... LOL

Richie: You earned them!

D'Mzzl!
RoverM
0
 
LVL 28

Expert Comment

by:Ark
ID: 6909368
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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

926 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question