Author Topic: using flash player in a window  (Read 7768 times)

ToutEnMasm

  • Member
  • *****
  • Posts: 1189
    • EditMasm
using flash player in a window
« on: February 19, 2014, 07:56:29 PM »
Hello,
I try to do this with masm.
I am at the start point,that is a successful connection to the IShockwaveFlash interface.
I don't know if the best way is to implement the Ioleclientsite interface or to use atl.
Some good samples will be of good help.
ToutEnmasm
Fa is a musical note to play with CL

ragdog

  • Member
  • ****
  • Posts: 610
Re: using flash player in a window
« Reply #1 on: February 19, 2014, 08:13:10 PM »
Hi

I use a flash player with AtlAxWin but with  IShockwaveFlash interface have i not see any example


GoneFishing

  • Member
  • *****
  • Posts: 1071
  • Gone fishing
Re: using flash player in a window
« Reply #2 on: February 19, 2014, 09:06:30 PM »
You may explore the internal working of ANY OCX control with the help of   OCX Container by Japheth.
I think it's the only (and  the best) ShockwaveFlash Player asm example  for you
Enjoy it :t

[EDIT]:
A little tutorial on how to use it:
- Menu Edit -> Insert Control ...
- Scroll down in the list of available controls, find the Shockwave Flash Object , double-click it
- Menu Options -> TypeInfo ... -> double-click IShockwaveFlash
- Scroll down to LoadMovie method -> RMB click -> Execute
- Fill in the parameters (I used "http://astro.unl.edu/naap/motion3/animations/sunmotions.swf" as url) and press Execute

P.S.: wanna more amazing Astronomy Simulations and Animations ?
« Last Edit: February 19, 2014, 11:21:24 PM by vertograd »

ToutEnMasm

  • Member
  • *****
  • Posts: 1189
    • EditMasm
Re: using flash player in a window
« Reply #3 on: February 20, 2014, 01:15:54 AM »

Thanks for answers.
The sample with the ocx container made the job.
Fa is a musical note to play with CL

ToutEnMasm

  • Member
  • *****
  • Posts: 1189
    • EditMasm
Re: using flash player in a window
« Reply #4 on: February 22, 2014, 05:11:48 AM »

ATL do the same in a very simple way
Code: [Select]
Invoke CoInitialize,NULL            ;Ex,NULL,NULL
invoke OleInitialize,NULL
;---------------------dynamic load----------------------------
invoke SearchAdresse,SADR("atl.dll"),addr hAtl ,addr ADRAtlAxDialogBoxW
invoke AtlAxWinInit
invoke GetModuleHandle, NULL
mov hInstance,eax
;---------- full path of the flash player file ----------------
invoke lstrcpy,addr ModulePath,SADR("C:\Temp\sunmotions.swf")
;***** ModulePath = full path of a file usable with any kind of control *********
;***** can be a html file,a .swf (flash player file).... ******************
invoke CreateWindowEx,WS_EX_OVERLAPPEDWINDOW ,SADR("AtlAxWin"),addr ModulePath,\
WS_OVERLAPPEDWINDOW,0,0,730,550,NULL,NULL,hInstance,NULL
mov Hfenetre,eax
;get the window events
invoke SetWindowLong,Hfenetre,GWL_WNDPROC,EventWnd
mov lpWindows,eax
INVOKE  ShowWindow,Hfenetre, SW_SHOWNORMAL
INVOKE  UpdateWindow,Hfenetre
;invoke PostMessage,Hfenetre,WM_COMMAND,1001,0
;----------------------------------------------------------------------
;invoke AtlWaitWithMessageLoop,Hfenetre
invoke waiting_loop

I have tried to get an interface to resize the window (for example) but could only get the Iunknown.
Any idea how to use the Iunknown ?
Quote
   invoke AtlAxGetControl,Hfenetre,addr ppvIUnknown
   IUnknown QueryInterface,addr IID_IUnknown,addr ppvIUnknown

Fa is a musical note to play with CL

GoneFishing

  • Member
  • *****
  • Posts: 1071
  • Gone fishing
Re: using flash player in a window
« Reply #5 on: February 22, 2014, 05:16:57 AM »
Code: [Select]
IUnknown QueryInterface,addr IID_Whatever, addr ppvIWhatever
Seems like  ATL makes using OCX controls simple but it's more C++ way of coding   

ToutEnMasm

  • Member
  • *****
  • Posts: 1189
    • EditMasm
Re: using flash player in a window
« Reply #6 on: February 23, 2014, 03:37:51 AM »
This way use also ATL ,IShockwaveFlash and offer more features.

Init:
Quote
   invoke CoInitializeEx,NULL,COINIT_APARTMENTTHREADED            ;Ex,NULL,NULL
   invoke OleInitialize,NULL
   invoke AtlAxWinInit      

 create a normal window,Hwnd
put this code in a WM_COMMAND
Code: [Select]
.if eax == 1001
invoke CoCreateInstance,addr CLSID_ShockwaveFlash,NULL,CLSCTX_ALL,\
addr IID_IShockwaveFlash,addr ppvIShockwaveFlash
.if ppvIShockwaveFlash == 0
jmp finatl
.endif
invoke AtlAxAttachControl,ppvIShockwaveFlash,hwnd,addr ppvIUnknown
invoke CreateSingleBstr,SADR("C:\Temp\sunmotions.swf")
mov ebx,eax
IShockwaveFlash LoadMovie,NULL,ebx
invoke SysFreeString,ebx
.endif

Quote
   .ELSEIF uMsg == WM_CLOSE ;return zero
      .if ppvIUnknown != 0
         IUnknown Release
      .endif
      .if ppvIShockwaveFlash != 0
         IShockwaveFlash Release
      .endif

Fa is a musical note to play with CL

ToutEnMasm

  • Member
  • *****
  • Posts: 1189
    • EditMasm
Re: using flash player in a window
« Reply #7 on: March 01, 2014, 04:47:10 AM »
Making an execute file with a .swf file
-- The .swf is put on RCDATA resource
Quote
500 RCDATA DISCARDABLE "sunmotions.swf"
we use the upper code and add a IPersistStreamInit interface
Quote
invoke CoCreateInstance,addr CLSID_ShockwaveFlash,NULL,CLSCTX_ALL,\
      addr IID_IShockwaveFlash,addr ppvIShockwaveFlash
invoke AtlAxAttachControl,ppvIShockwaveFlash,hwnd,addr ppvIUnknown
IShockwaveFlash QueryInterface,addr IID_IPersistStreamInit,addr ppvIPersistStreamInit
invoke CreateStream
IPersistStreamInit Load,ppvIStream
The Istream need to point on a header followed by the .swf data file.
Quote
FLASH_STREAM_HEADER   STRUCT DEFALIGNMASM
   m_dwSignature DWORD ?
   m_dwDataSize DWORD ?
FLASH_STREAM_HEADER      ENDS

Code: [Select]
CreateStream PROC uses esi edi ebx
Local fsh:FLASH_STREAM_HEADER
Local uli:QWORD,abuffer[200]:BYTE
Local  retour:DWORD,Hglobafixed,Hglobalmov,hResource,dwResourceDataSize,pres,pHglobal
         mov retour,1
invoke FindResource,hInstance,500,RT_RCDATA
mov hResource,eax
invoke SizeofResource,hInstance,hResource
mov dwResourceDataSize,eax
invoke LoadResource,hInstance,hResource
mov Hglobafixed,eax
invoke LockResource,eax
mov pres,eax
mov edx,dwResourceDataSize
add edx,sizeof fsh
;round
add edx,32
and edx,0FFFFFFF0h
invoke GlobalAlloc,GHND or GMEM_NODISCARD ,edx
mov Hglobalmov,eax
invoke CreateStreamOnHGlobal,Hglobalmov,TRUE,addr ppvIStream
;fill the FLASH_STREAM_HEADER
mov fsh.m_dwSignature,055665566h
PuPo fsh.m_dwDataSize,dwResourceDataSize
;-------- one method to create the data = fsh+.swf data file -----------------
comment µ
invoke GlobalLock,Hglobalmov
mov edi,eax
;copy the header
lea esi,fsh
mov ecx,sizeof fsh
rep movsb
;copy the data the .swf file
mov esi,pres
mov ecx,dwResourceDataSize
rep movsb
µ
;----- second method -----------------
IStream Write,addr fsh, sizeof fsh, NULL
IStream Write,Hglobafixed,dwResourceDataSize,NULL
;-------- Stream pointer at the start of data ----
mov DWORD ptr[uli+4],0
mov DWORD ptr[uli],0
IStream Seek,uli,STREAM_SEEK_SET, NULL

 FindeCreateStream:
         mov eax,retour
 ret





Fa is a musical note to play with CL

dedndave

  • Member
  • *****
  • Posts: 8823
  • Still using Abacus 2.0
    • DednDave
Re: using flash player in a window
« Reply #8 on: March 01, 2014, 03:02:21 PM »
someplace, i saw a tool that could be used to "de-compile" SWF files
you might search around, if you are interested

ragdog

  • Member
  • ****
  • Posts: 610
Re: using flash player in a window
« Reply #9 on: September 05, 2014, 06:11:47 AM »

ToutEnMasm

  • Member
  • *****
  • Posts: 1189
    • EditMasm
Re: using flash player in a window
« Reply #10 on: September 19, 2014, 03:42:50 AM »
For those who just want to put a .swf in an execute,here the source code.
Modify the name zodiac in the .rc   and recompile (vc express 2010)
Code: [Select]
500 RCDATA DISCARDABLE "zodiac.swf"
Other includes http://masm32.com/board/index.php?topic=563.msg4563#msg4563


I have added a second soluce to do it,The code is already compiled in an object file,and there is just to compile the modified resource .rc
You need zero include (resource.h is in the zip)

« Last Edit: September 19, 2014, 04:38:12 PM by ToutEnMasm »
Fa is a musical note to play with CL