IT-Berater: Theo Gottwald (IT-Consultant) > Freebasic

FreeBASIC Movie Control

<< < (2/3) > >>

Juergen Kuehlwein:
Hey Pierre,

RenderFile is possible in IGraphBuilder and in IMediaControl - both work (32 bit unicode defined), Changing the syntax to "->lpvtbl->..." all over the code, doesn´t help either.


thanks for the code - how could i make it compile? I see you added your own (as a replacement ?)


José Roca:
You need to change #include to #include in the FB includes that use it.

Juergen Kuehlwein:

fortunately is only included one time. After changing it in to afx\ your code runs like a charm in 32 bit and 64 bit regardless, if unicode is defined or not! Taking a closer look you can get rid of at all by replacing 3 constants (oatrue, oafalse, ec_complete) with their values or redefining them in your code.

That arises the question, where is the difference making my code fail? At least i now have some working code i can start with.



José Roca:
Regardless of if UNICODE is defined or not, I always use unicode in my code by explicitily calling the "W" functions. I think that using ansi GUI's is a useless complication.

Since I wrote the code, I changed the AfxSafeRelease function to set the passed pointer to null. Therefore, pIMediaControl = NULL, etc., are no longer needed.

I advice you of always specify BYVAL or BYREF with the parameters. Otherwise, the compiler will fail to compile and report errors when using an switch like -w pedantic. Reusable code must be written to work with all the available compiler preferences.

I would suggest to use wce.cbWndExtra = SIZEOF(HANDLE) instead of wce.cbWndExtra = 8. This way, cbWndExtra will be 4 bits with 32-bit and 8 bits with 64 bits.

Beware of using UINTEGER or INTEGER with variables that alwyas should be DWORD or LONG.

--- Code: ---DIM wstyle    as UINTEGER
DIM xstyle    as UINTEGER
DIM fixedsize as UINTEGER
DIM wflag     as UINTEGER
DIM hflag     as UINTEGER
DIM cx        AS uinteger                             'x
DIM cy        AS uinteger                             'y
DIM p         AS uinteger                             'percentage
DIM w         AS uinteger                             'width
DIM h         AS uinteger                             'height

--- End code ---

I never use them. Because they don't behave like in C++, it can lead to confussions and mistakes when traslating code.

Juergen Kuehlwein:

i got it! I was so close and i was so blind, there were more than enough clues - memory corruption due improper allocation of control´s private data.

Translating from PB to PB i made a fatal error, it must be:

--- Code: ---c = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, SIZEOF(movie_data))      'allocate memory for data

--- End code ---

In FB "sizeof(@c)" returns the size of a pointer, in PB it returns the the size of the type the pointer points to...



[0] Message Index

[#] Next page

[*] Previous page

Go to full version