|
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.
|
|
|
|
|
You'll get those heap corruption messages in Debug only because in debug the CRT ( C RunTime library ) is checking up on you and picking up the mismatch between malloc and delete . The Debug CRT new adds extra info to the allocation to indicate what sort of allocation it is, i.e. you did it or it's internal to the CRT or thread specific or whatever. When you do the delete, it checks this info to make sure it matches but because you called malloc the extra info didn't get initialised and it's either wrong or missing. In Release the extra info and checking is cut for performance so you don't get the errors.
Conclusion: For a happy life you really do need to match malloc with free and new with delete
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
Try to post the relevant code.
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 give the following advice about once a month (more recently); it often helps me track down the nastier heap errors:
Try enabling the page heap[^] for your process. Follow these steps:
1. Download and install WinDBG[^].
2. Select “Start”->“All Programs”->“Debugging Tools for Windows”->“Global Flags”.
3. Select the “Image File” tab.
4. In the “Image: (TAB to refresh)” edit control enter the name of your app then press TAB. Just the name with the extension; not the full path.
5. Tick the following:
- “Enable page heap”
- “Enable heap tail checking”
- “Enable heap free checking”
- “Enable heap parameter checking”
- “Enable heap validation on call”
- “Create user mode stack trace database”
6. Press “Apply”.
7. Debug your application. Any debugger will do but with WinDBG you have access to the stack traces of allocations via the !heap –p –a command, for example. When a heap problem is detected a breakpoint will be generated.
8. When done un-tick all the options you ticked, press “Apply” then dismiss GFlags. This step is important as if it’s skipped all applications named as entered in step 4 will run with the page heap enabled.
Note that when using the page heap your application will run much slower than normal and consume way more memory. It’s good to have a beefy machine to do such tests; and such tests should be ran regularly on all applications you develop as part of regular testing activities. If I find a part of my application that’s too slow with the page heap enabled I optimize the memory allocation in that region.
Steve
|
|
|
|