Solved

Animated GIF in VB and......

Posted on 2002-03-26
17
410 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 300 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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

830 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