|
Have you set the include directories and lib directories of the Platform SDK 2003 in the msdev->Tools->Options->Directories->Include file ???
|
|
|
|
|
Thanks for your reply. I got it to compile after installing Platform SDK Feb 2003 which is compatible with VS C++ 6.
Below is the updated function.
Is it correct? Would it leak any resources?
How should I clean up bitmap_output after use?
<br />
void CopyToBitmap(CWMPPlayer4& player, CBitmap& bitmap_output)<br />
{<br />
CClientDC player_dc(&player);<br />
CRect player_rc;<br />
player.GetClientRect( player_rc );<br />
CSize player_sc(player_rc.Width(), player_rc.Height());<br />
bitmap_output.CreateCompatibleBitmap(&player_dc, player_sc.cx, player_sc.cy);<br />
<br />
CDC* dc_p = this->GetDC();<br />
CDC bitmap_dc;<br />
bitmap_dc.CreateCompatibleDC( dc_p );<br />
CBitmap *prev_bitmap_p = bitmap_dc.SelectObject( &bitmap_output );<br />
PrintWindow( player.m_hWnd, (HDC)bitmap_dc, PW_CLIENTONLY );<br />
bitmap_dc.SelectObject( prev_bitmap_p );<br />
ReleaseDC( dc_p );<br />
}
|
|
|
|
|
C. Tam wrote: How should I clean up bitmap_output after use?
This code is ok. No need to cleanyp the bitmap_output. the destrucor of the CBitmap will take care of it.
C. Tam wrote: CDC* dc_p = this->GetDC();
I think this code is not needed. You can use the player_dc itself.
|
|
|
|
|
I've updated the code to use player_dc as below. Thanks for inputs.
During testing, I've discovered that the app does not work all the time.
So far, it works on XPProSP2 hosted on MS Virtual PC 2004.
However, it doesn't work on XPProSP2 running on a real computer. The CBitmap's output is black.
How do I resolve this problem?
<br />
void CopyToBitmap(CWMPPlayer4& player, CBitmap& bitmap_output)<br />
{<br />
CClientDC player_dc(&player);<br />
CRect player_rc;<br />
player.GetClientRect( player_rc );<br />
CSize player_sc(player_rc.Width(), player_rc.Height());<br />
bitmap_output.CreateCompatibleBitmap(&player_dc, player_sc.cx, player_sc.cy);<br />
<br />
CDC bitmap_dc;<br />
bitmap_dc.CreateCompatibleDC( &player_dc );<br />
CBitmap *prev_bitmap_p = bitmap_dc.SelectObject( &bitmap_output );<br />
PrintWindow( player.m_hWnd, (HDC)bitmap_dc, PW_CLIENTONLY );<br />
bitmap_dc.SelectObject( prev_bitmap_p );<br />
}<br />
-- modified at 4:33 Wednesday 6th June, 2007
|
|
|
|
|
I found no reasond for this code to work. Did you debug? Its dosent work means any function failed?
How ever try the next option, WM_PRINTCLIENT
|
|
|
|
|
I've found a workaround for this problem as quoted below.
"During testing, I've discovered that the app does not work all the time.
So far, it works on XPProSP2 hosted on MS Virtual PC 2004.
However, it doesn't work on XPProSP2 running on a real computer. The CBitmap's output is black."
On a real computer's display control panel, reduces the levels of hardware acceleration controlled by device drivers.
By the way, when I run the app on a Windows 2000 machine, an error message is displayed (shown below) before it is shutdown.
"app.exe - Entry Point Not Found"
"The procedure entry point PrintWindow could not be located in the dynamic link library USER32.dll".
Could you show me how to display a more user friendly error message insteads of the one above?
|
|
|
|
|
C. Tam wrote: "The procedure entry point PrintWindow could not be located in the dynamic link library USER32.dll".
Definitly it will come because the Printwindow() function is suppported only in windows XP or a later OS. It will not work in windows 2000. As I said earlier, you can use the WM_PRINTCLIENT message for the same purpose. It will work in windows 95 also.
|
|
|
|
|
I've replaced the following line
PrintWindow(m_player.m_hWnd, (HDC)MemDc, PW_CLIENTONLY);
with
::SendMessage(m_player.m_hWnd, WM_PRINTCLIENT, (WPARAM)(HDC)MemDc, PRF_CHILDREN | PRF_CLIENT | PRF_ERASEBKGND | PRF_NONCLIENT); .
Unfortunately, it no longer copies the image.
How should I correct it?
|
|
|
|
|
May be a problem with the m_player window. Try passing the handle of another window and verify the image is correct or not.
|
|
|
|
|
Yes, you're right. It's the problem with the m_player window. I works on a CStatic window. Do you know why?
In the meantime, I've rolled back to PrintWindow API which will only work on Windows XP.
As I've mentioned before, when I run the app on a Windows 2000 machine, an error message is displayed (shown below) before it is shutdown.
"app.exe - Entry Point Not Found"
"The procedure entry point PrintWindow could not be located in the dynamic link library USER32.dll".
Is it possible replace the above message with my own custom one?
|
|
|
|
|
C. Tam wrote: Do you know why?
May be the m_player window is not using the usual paint messages to draw the window.
C. Tam wrote: Is it possible replace the above message with my own custom one?
You can if you dynamically load this function. For this first declare the function as below
typedef BOOL ( WINAPI *MyPrintWindow)(IN HWND hwnd, IN HDC hdcBlt, IN UINT nFlags);
Then
To check whether the function is available or not, you an do like this,
HMODULE hUser32Module = LoadLibrary( _T("User32.dll"));<br />
MyPrintWindow p = (MyPrintWindow)GetProcAddress( hUser32Module, "PrintWindow");<br />
if( p == 0 )<br />
{<br />
AfxMessageBox( _T("Your custom message here"));<br />
return;<br />
}
And if you want to call the printwindow function,
p( m_player.m_hWnd, (HDC)MemDc, PW_CLIENTONLY);
|
|
|
|
|
C. Tam wrote: Unfortunately, I've noticed this function fails to work when it is invoked by a timer and the source window area is obscured by another application.
If there's aother window on top of the one you are copying pixels from then you're going to get
the pixels of the obscurring window. Is this what's happening?
If you want this to work you'll need to keep a bitmap copy of the window's contents so when you
receive a timer event you can use that bitmap instead of scraping the screen.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
The anwser is Yes to your question "If there's aother window on top of the one you are copying pixels from then you're going to get the pixels of the obscurring window. Is this what's happening?"
Thanks for your reply, on the point of using the bitmap copy instead of scraping the screen.
|
|
|
|
|
This is probably a very simple question, but I'm new to ATL.
Is it possible to mix code that uses the MFC library with code that uses the ATL library?
I've tried a simple example, but it won't compile. I get the following error:
1>c:\program files\microsoft visual studio 8\vc\atlmfc\include\cstringt.h(2508) : error C2872: 'ULONG_PTR' : ambiguous symbol
1> could be 'c:\program files\microsoft platform sdk\include\basetsd.h(123) : __w64 unsigned long ULONG_PTR'
1> or 'c:\documents and settings\tribble\my documents\vc32\test\debug\dte80a.tlh(463) : EnvDTE::ULONG_PTR'
1> c:\program files\microsoft visual studio 8\vc\atlmfc\include\cstringt.h(2505) : while compiling class template member function 'bool ATL::CStringT<BaseType,StringTraits>::CheckImplicitLoad(const void *)'
1> with
1> [
1> BaseType=char,
1> StringTraits=StrTraitMFC_DLL<char>
1> ]
1> c:\program files\microsoft visual studio 8\vc\atlmfc\include\afxstr.h(83) : see reference to class template instantiation 'ATL::CStringT<BaseType,StringTraits>' being compiled
1> with
1> [
1> BaseType=char,
1> StringTraits=StrTraitMFC_DLL<char>
1> ]
|
|
|
|
|
Yes. It is possible to mix ATL and MFC but it can be very tricky. It's a few years since I did any of this, ATL 3.0 and MFC 4.2 in those days. It worked best if you approached it from the ATL point of view. As in start with an ATL based app and add MFC code to it rather than the other way around.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
I mix them all the time: if I use MFC I use ATL too. I've never had any trouble.
Steve
|
|
|
|
|
Hi
I am quite new to MFC. Well i have two radio buttons over the form . For each radio button i have written function like under OnRadio1() and OnRadio2(). Its basically when i select one ...all the edit control which are not used gets deactivated. So i have written code for it.
The only problem i am facing is that now i have to add event handler. So what should i select BN_CLICKED, BN_DBCLICKED, BN_KILLFOCUS etc Well i dont think i could use BN_CLICKED n all as it is radio button...
So could any one help me out in this simple problem...
I am stucked at the moment. And need to get on with it...So any quick reply would help me out in continuing with my work...
Waiting for reply
Thanks
|
|
|
|
|
A radio button is a button, of course. It differs from the 'usual' push-like buttons by its BS_RADIOBUTTON style.
So you can use BN_CLICKED message;
// inside BEGIN_MESSAGE_MAP and END_MESSAGE_MAP pair
ON_BN_CLICKED(IDC_RADIO1, OnRadio1)
ON_BN_CLICKED(IDC_RADIO2, OnRadio2)
--
=====
Arman
|
|
|
|
|
OK gr8....thanx for clearing my doubt...
|
|
|
|
|
Hello everybody ..
If you can I need a code to search in a text file ....
I need it to search of word which contin of 3 word and than calcalute the number of the word..
can you help me I try with 2-dimansion array but I cant write it ...
what I can use to write it ....
sorry for my bad english
plase help me as soon as you can ...
non light
|
|
|
|
|
non light wrote: I need it to search of word which contin of 3 word and than calcalute the number of the word..
can you help me I try with 2-dimansion array but I cant write it ...
I cannot understand what are you searching for...
You really need to make a further effort with your English or, alternatively, post and example of what are you trying to do.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
for example I have a file which have a sentese or a list of word . And in this file there is thre-letter word (for example -new-how-old...) and I want the program to find this word...
I hope you understand me ....
|
|
|
|
|
You could probably do this with one of the regular expression articles here - do a search for "deelx" and take a look at it.
|
|
|
|
|
thank you so much but I do not understand ...
your code is so complucate and I stel in my first step in programming
can you give me a simple code
thank you
|
|
|
|
|
non light wrote: your code is so complucate and I stel in my first step in programming
That's because you're asking how to do a complex task. If you don't understand it, take a step back and do something more simple. I recommend the book 'teach yourself C++ in 24 hours'. Work through that, make sure you understand it all, then move on to something more complex.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|