|
How do you declare MGetPixel?
|
|
|
|
|
The DLL is not causing the problem, I believe it is my declaration. The maker of the DLL said to
LINK WITH GETPROCADDRESS
CALL THEM LIKE REGULER WINAPI (same params)
So MGetPixel should have the same parameters as GetPixel.
|
|
|
|
|
Even if the function declaration is correct, it's not going to work if you call
FreeLibrary(hinstLib) after GetProcAddress(...).
Mark
Mark Salsbery
Microsoft MVP - Visual C++
This episode brought to you by the letter Z
|
|
|
|
|
Ok, I found my problem, Im defining my import wrong. I actually read the runtime error and it said I'm defining my function one way and the actual function is defined in a different way. How would I define a GetPixel function. HE said to declare it as any other WINAPI.
|
|
|
|
|
vegito616 wrote: How would I define a GetPixel function. HE said to declare it as any other WINAPI.
What you had was fine for getting a pixel value from a source DC.
Windows APIs use the WINAPI calling convention:
typedef COLORREF WINAPI (*MYPROC)(HDC, int, int);
where WINAPI == __stdcall
Mark
Mark Salsbery
Microsoft MVP - Visual C++
This episode brought to you by the letter Z
|
|
|
|
|
Hello,
Here's my problem:
I have an ActiveX control which has the functionality of a video player. After integrating it in my MFC dialog, when I play the video, if I drag the dialog out from the screen, or maximize it, or drag some other dialog over it, the ActiveX control doesn't redraw its child windows properly.
More exactly, it's about two DirectX child windows which are created for playing the video. One is a DirectX output window and one is the video overlay. Instead redrawing them corectly (video frames playing) I get the area filled with the MFC dialog's background. Setting Clip Siblings to true in the MFC dialog's properties doesn't help much. Indeed, I don't have the area filled with the background but the redraw of the ActiveX windows isn't still made properly (it's a mess .. background mixed with video or something else.. )
I managed to get the handles of the two DirectX windows and tried various solutions starting from calling Invalidate for the entire control to WinAPI calls to RedrawWindow on the handles (and others). Nothing seems to make the video output windows repaint themselves after being covered with something else.
I need to mention that I don't have any experience with DirectX or with ActiveX/COM besides using controls.
If someone can give me a hint for a solution many many thanks in advance.
|
|
|
|
|
Is the ActiveX control written by you?
My first try would be to disable the erase background and paint events in the MFC dialog, and see if the control draws properly... even that your MFC dialog will look horrible. If the problem was that your dialog ruins the video playing, then you can try to set the flag for clip children (not clip siblings).
Can you tell us if the ActiveX control is using DirectX overlay for playing video?
Regards,
|
|
|
|
|
No, the ActiveX isn't written by me.
I have already tried to disable the WM_ERASEBKGND message for the dialog and the only thing changed is indeed that the dialog looks horrible. The ActiveX control has the same problem. Adding the disabling WM_PAINT makes the dialog fully transparent - and still no proper redraw in the video control. (I've let only the control at this moment on the dialog, which is a modeless one launched from the main application dialog)
My mistake, sorry, I wrote the first post in a hurry, the Clip Children was the property I set and doesn't make much difference, not the Clip Siblings.
Finally, yes, the control is using DirectX overlay, is the problem there ?
Thank you for your interest
|
|
|
|
|
Have you tried to see if other applications using DirectX overlay have a similar problem? Could be a graphics card / driver / driver settings problem.
I could try the ActiveX control if you send me a copy and if it doesn't have some licensing issue. For now, I can't think of a specific reason for your problem. It would be much easier to try it myself.
Best wishes,
|
|
|
|
|
The control is open source, so I don't see any licensing problems. I know almost nothing about COM/ActiveX development like I said in the first post. If I did I would have taken a look myself inside it's code.
I'll mail it to you on the address specified in the link in your signature if it is ok (please let me know). As far as I know, I think there are video players that use DirectX overlay. I don't know one exactly but I don't remember seeing any player to "behave" in this way.
Again, many thanks for the answer.
|
|
|
|
|
Yes, you can use that email address. If you'd like you can simply send the location where I can find the open-source code for the control. I'll create a sample test project and try to reproduce the behaviour you've been describing.
Regards,
|
|
|
|
|
Can someone provide links to Windbg apart from microsoft documentation?
|
|
|
|
|
|
Thanks for telling me that. But i'm looking for links which provide more info on it in terms of hand on.
|
|
|
|
|
|
That link was provided to him several days ago here. He's apparently not interested in help.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
"Debugging Applications for .NET and Windows" by John Robbins, published by Microsoft Press.
|
|
|
|
|
MSDN states that sending a message is done directly to a message windows procedure rather than message queue. If that is true then is it true that GetMessage/PeekMessage is valid only for messages that are placed into message queue by postmessage.
Also if we want to direct a message to another process will both PostMessage/SendMessage work. What is the difference?
|
|
|
|
|
from MSDN:
The SendMessage function sends the specified message to a window or windows. It calls the window procedure for the specified window and does not return until the window procedure has processed the message.
The PostMessage function places (posts) a message in the message queue associated with the thread that created the specified window and returns without waiting for the thread to process the message.
The WindowProc function is an application-defined function that processes messages sent to a window. The WNDPROC type defines a pointer to this callback function. WindowProc is a placeholder for the application-defined function name.
The DispatchMessage function dispatches a message to a window procedure. It is typically used to dispatch a message retrieved by the GetMessage function.
|
|
|
|
|
In addition to what Michael posted, both APIs are adding messages to the thread's message queue, thus can be retrieved using GetMessage() and PeekMessage(). As MSDN says, on Vista there's a small exception for this behaviour:
"Microsoft Windows Vista and later.
...
If the specified window was created by the calling thread, the window procedure is called immediately as a subroutine.
..."
Best regards,
|
|
|
|
|
What about the other part of the question
Also if we want to direct a message to another process will both PostMessage/SendMessage work. What is the difference?
|
|
|
|
|
Do you understand English? PostMessage() returns without waiting for the thread to process the message. SendMessage() does not return until the window procedure has processed the message. PostMessage() is a non-blocking call. SendMessage() is a blocking call. Regardless of Microsoft's implementation details, both calls go to the same place -- the window procedure of the window to which you are sending (or posting) the message.
|
|
|
|
|
hi Tom,
did u get the answer for your question,
"if we want to direct a message to another process will both PostMessage/SendMessage work?"
If so, can you reply that to me?
I dont think postmessage/sendmessage works across processes.
it that right?
Thanks in advance.
cheers....!
Balaji
|
|
|
|
|
tom groezer wrote: MSDN states that sending a message is done directly to a message windows procedure rather than message queue.
Hi again,
It seems others tend to paste MSDN snippets, however I'll try to explain it as I understand it. Lets just hope that I understand it correctly
Its quite complicated... and this is only a summary.
SendMessage() ... It will completely bypass the message que and ultimately call the window Proc directly. The message is never placed into the message que. Instead it is placed into a seperate FIFO stack of "nonqueued messages" which is technically not the normal message que.
The following functions generate nonqueued messages:
SendMessage, SendMessageCallback, SendMessageTimeout, SendNotifyMessage, BroadcastSystemMessage, BroadcastSystemMessageEx... maybe more I dunno.
PostMessage()... always places the message into the standard windows message que and returns immediately.
tom groezer wrote: If that is true then is it true that GetMessage/PeekMessage is valid only for messages that are placed into message queue by postmessage.
GetMessage() and PeekMessage() checks for both queued and nonqueued messages. Meaning regardless of whether they are sent by SendMessage() or PostMessage() you can filter them.
tom groezer wrote: Also if we want to direct a message to another process will both PostMessage/SendMessage work. What is the difference?
You should use PostMessage(). If you use SendMessage() and the other application is blocked... your SendMessage() will never return. But there are alternatives... SendMessageTimeout() and such.
Best Wishes,
-Randor (David Delaune)
|
|
|
|
|
David, in my opinion, your interpretation does not make any sense. Why? Because when SendMessage is used across thread boundaries, it cannot be processed in the sender's thread, thus... must be queued, and processed by the receiving window's thread, whenever it is reached. That's why SendMessage may hang if the receiver thread (other than sending one) is busy... not processing queued messages. If fact, I can tell you from experience that it happen once to redraw a window, but to return the wrong value from the window procedure, thus the paint message was not removed from the queue. In that case, any other thread using SendMessage to communicate with this window was blocked, not only the thread that created the window.
Your explaination with a secondary FIFO doesn't hold, because a thread's context can't change "suddenly". If there is a message queue (also FIFO) which GetMessage() and PeekMessage() are using, when and how a secondary FIFO can be processed? No OS would suspend a thread's execution while processing a message from the queue, or even while waiting for a new message, and "suddenly" call a window procedure with a message sent through SendMessage! Remember, I'm not talking here about sending a message to a window belonging to the same thread where the call is made.
Indeed, when the window belongs to the same thread, it makes perfect sense to call the window procedure immediatelly, because the developer would expect that SendMessage() returns only after the message is processed, so... the thread execution depends on the processing of that message, before any other message already existing in the queue at that point in time. I don't even understand why MSDN says that such behaviour is for "Vista or later", because, when I think about it,... it cannot be otherwise.
Regards,
|
|
|
|