|
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 )
|
|
|
|
|
non light wrote: I hope you understand me
Yes, now it is clear.
If you wants to keep things simple, the probably you have to:
(1) read the whole file in memory.
(2) search the memory for the three words pattern (you can search for the hyphen, using, for instance, <code>strchr</code>).
The above is a simple approach, feasible for small text files.
If you have troubles on the details of the depicted steps, don't ask to post your doubts.
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.
|
|
|
|
|
|
I am writting a button control from scratch in pure C + Win32. I have a structure as under
<br />
typedef struct tagBUTTONINFO<br />
{<br />
TCHAR * szText;<br />
int iLenght;<br />
COLORREF backColor<br />
} BUTTONINFO, * PBUTTONINFO;<br />
Now on each WM_NCCREATE, I use malloc() to allocate a BUTTONINFO and set its address in USERDATA of the HWND of the window. In each WM_SETTEXT, I allocate space for the text and set in the PBUTTONINFO->szText. On WM_NCDESTROY, I deallocate the space for BUTTONINFO and the BUTTONINFO::szText as well. But in debug sessions, I get Heap Corruption Error Message. Whats wrong?
However, if you use new and delete keywords for the same tasks, no such problem occurs... whats wrong and where?
Polite Programmer
More Object Oriented then C#
|
|
|
|
|
The biggest difference is that new calls the constructor for the object being allocated, while malloc() only allocates memory. Even though you may not define one, a simple struct has a default constructor provided by the compiler. I believe the default constructor under debug initializes the allocated memory to zero. This is probably setting your structure to a 'good' initial state (pointers get initialized to NULL ). With malloc() , that initialization isn't happening.
Software Zen: delete this;
|
|
|
|
|
But the constructor is not needed to dot that because after executing the malloc(), I immediatly call ZeroMemory like this.
PBUTTONINFO pButtonInfo = (PBUTTONINFO) malloc (sizeof (BUTTONINFO));<br />
ZeroMemory ((LPVOID) pButtonInfo, sizeof (BUTTONINFO));
Polite Programmer
More Object Oriented then C#
|
|
|
|
|
One more thing, The GlobalAlloc() and GlobalFree() also act the similar way as the malloc() does.
Polite Programmer
More Object Oriented then C#
|
|
|
|
|
Hmm. Myself, I always prefer the new /delete approach over malloc() /free() , because these sorts of issues don't tend to arise as often.
There isn't a significant difference between the performance of the two approaches. Is there any particular reason you're using malloc() ?
Software Zen: delete this;
|
|
|
|
|
Because he wants to use pure C.
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.
|
|
|
|