|
Ok, ive just created a CDC for the screen, done a little drawing, but want to get rid of my drawing...is it possible to inform a region/rect of the screen that it should repaint?
| Website: http://www.onyeyiri.co.uk
| Sonork: 100.21142 : TheEclypse
| "If a dolar was a chicken would the chicken be evil?"
|
|
|
|
|
One solution is InvalidateRect().
Kuphryn
|
|
|
|
|
thanks, works great
| Website: http://www.onyeyiri.co.uk
| Sonork: 100.21142 : TheEclypse
| "If a dolar was a chicken would the chicken be evil?"
|
|
|
|
|
see: InvalidateRect, RedrawWindow
|
|
|
|
|
I was looking for a way to determine if one polygon is contained in another. I need it to work with float points (instead of integers). I need this to be fast, so a system api would be great.
I've looked at the CRgn class, but it is integer based. I've looked at some of the openGL glu methods, but my lack of familiarity with them has led to much confusion.
Is there some api out there that does this? Of am I going to have to re-invent this wheel?
Thanks in advance!
shao_lo@eudoramail.com
|
|
|
|
|
You can use CRgn::CombineRgn and not have to worry about floats or ints. Just create two regions that represent the polygons. Let's say that rgnInner is the region that should be contained within rgnOuter. Then create a third region using CombineRgn(&rgnInner, &rgnOuter, RGN_DIFF). This gives you the region consisting of the areas of rgnInner that are not contained in rgnOuter. If the return value is NULLREGION, that means that rgnInner is fully contained within rgnOuter.
|
|
|
|
|
There is no API for doing what you want that I know of and if there is please (please) let me know. The one reply I saw to your inqirey looked more like clipping one region to another region. But according to your qestion you want to determine if one polygon is in-side of anouther polygon. I do not know of any algorithm that can solve your problem.
Trust in the code Luke. Yea right!
|
|
|
|
|
Hello,
whats the difference between unlink and remove ?
-Dominik
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
|
|
|
|
|
The end result appears to be the same. remove() did mention something about ANSI, however.
|
|
|
|
|
unlink() is the POSIX standard function for file deletion, remove() is the ANSI C function. They may behave differently on directories.
|
|
|
|
|
I've been working on a little app for use with wireless keyboards that don't have num/cap/scroll lock lights. It's just a small app that always sits on top and tells you if any of those locks are on.
I've implemented a global hook ok for the keyboard and the application can recieve messages from the hook when it has and hasn't got focus. The problem I'm having is I want it to update 3 little icons in CStatic controls on the app that represent cap/num/scroll lock. This works fine when the app has focus but when it loses focus it no longer repaints the icons. The app is still getting the messages because It can display a messagebox for me but it's just not updating the icons.
I've looked though the MSDN I've used loads of functions to force the redraw but nothing seems to work. I've probably just missed the easyest one that works so any sujecstions will be great.
Thanks
Darren
|
|
|
|
|
Call Invalidate() and see if that forces a repaint.
Kuphryn
|
|
|
|
|
You'll probably have to do UpdateWindow() too.
"Do unto others as you would have them do unto you." - Jesus
"An eye for an eye only makes the whole world blind." - Mahatma Gandhi
|
|
|
|
|
Hi,
I have a SDI application with a editbox in the toolbar, now i want give the editbox another background color. Can someone help me with this?
I have tried to put a WM_CTLCOLOR handler in CAppView and in CMainFrame, but i don't receive the WM_CTLCOLOR message.
Thanks,
Willem
|
|
|
|
|
I believe you'll need to derive a class from CEdit. In that class, handle the WM_CTLCOLOR message.
|
|
|
|
|
Thanks!
The editbox works, but how can i add a messagehandler? The "Add Message Handler" menu is not there.
I have tried this.
BEGIN_MESSAGE_MAP(CStatusEditBox, CEdit)<br />
ON_WM_CTLCOLOR()<br />
END_MESSAGE_MAP()
I get the following compiler error:
'GetMessageMap' : member function not declared in 'CStatusEditBox'
|
|
|
|
|
Did you use ClassWizard to derive CStatusEditBox from CEdit? The error message you got about GetMessageMap() was because the DECLARE_MESSAGE_MAP macro was missing from the CStatusEditBox class. You can add it manaully, but it's usually better to let ClassWizard do this, and more, for you.
|
|
|
|
|
I have a very strange bug that I have been unable to track down. I am using a CString extension class called CStringEx. I am simply looping through the string looking for \n for wrapping purposes. Once I reach a certain portion of the loop, I get a memory error and the program crashes.
Now... here is the strange part. While stepping through the code in debug mode, the error DOES NOT HAPPEN. So then I put TraceWin code in the loop so I can see what's going on. Again, in a normal run, the error happens everytime. Then, in an effort to see of the portion of the string I an working with is causeing errors, I perform a CString.Mid() within the loop and output the results. PRESTO, the error stops!! WTF?!? Nothing else in the code has changed. I then pull the trace code out and just do a Mid() to a temp var in the loop. ERROR IS GONE! The simple act of performing a Mid() on the var has stopped the error.
I could keep this hack in the code, but I would rather not. Does anyone have any ideas what could cause a Mid() to stop a memory error from occuring? Is this an allocation issue with CString?
Any insight on this would be greatly appreciated.
The code in question is below:
<br />
void WordWrap( CStringEx &String, int intWrapSize )<br />
{<br />
FSTRACE("WordWrap(): start\n");<br />
<br />
CString strTemp;<br />
<br />
int intSpace = 0;<br />
int intLineSize = intWrapSize;<br />
int intStart = intLineSize;<br />
int intLastStart = 0;<br />
int intFindLF = String.Find("\n");<br />
<br />
while ( TRUE )<br />
{<br />
if ( (intSpace = String.Find(" ", intStart)) != -1 )<br />
{<br />
FSTRACE("WordWrap(): intSpace = %d\n", intSpace);<br />
<br />
intFindLF = String.Find("\n", intLastStart);<br />
FSTRACE("WordWrap(): intFindLF = %d\n", intFindLF);<br />
<br />
if (intFindLF > intSpace || intFindLF == -1)<br />
{<br />
String.Insert(intSpace + 1, "\r\n");<br />
FSTRACE("WordWrap(): insert crlf @ %d\n", intSpace + 1);<br />
<br />
intLastStart = intSpace + 4;<br />
intStart = (intSpace + intLineSize) + 3;<br />
}<br />
else if (intFindLF != 0)<br />
{<br />
intLastStart = intFindLF + 2;<br />
FSTRACE("WordWrap(): intLastStart = %d\n", intLastStart);<br />
<br />
intStart = intFindLF + intLineSize;<br />
FSTRACE("WordWrap(): intStart = %d\n", intStart);<br />
<br />
}<br />
else<br />
{<br />
intStart = intFindLF + intLineSize;<br />
FSTRACE("WordWrap(): intStart = %d\n", intStart);<br />
}<br />
}<br />
else<br />
{<br />
FSTRACE("WordWrap(): while - break\n", intSpace);<br />
break;<br />
}<br />
<br />
strTemp = String.Mid(intLastStart, intStart);<br />
FSTRACE("WordWrap(): --------------------------\n");<br />
}<br />
<br />
FSTRACE("WordWrap(): returning\n");<br />
return;<br />
}<br />
<br />
|
|
|
|
|
Can you provide a code snippet on how you are calling the function?
Have you tried using just a CString object to see what happens?
|
|
|
|
|
Sure. All of the code is contained within and email parsing program. The plain text body requires formating that is handled through this function (as you can see from the trace code, I traced the error as far back as I could):
<br />
BOOL FormatBodyText(CStringEx &strBodyText, CAttributes *Attrib)<br />
{<br />
FSTRACE("Starting FormatBodyText...\n");<br />
<br />
WordWrap(strBodyText, Attrib->m_intWrapSize);<br />
FSTRACE("did word wrapping...\n");<br />
<br />
ParseForLinks(strBodyText, Attrib->m_strHrefReplace, Attrib->m_strMailtoReplace);<br />
FSTRACE("did parseForLinks...\n");<br />
<br />
if(Attrib->m_bDoHopLinks)<br />
ParseForHopLinks(strBodyText, Attrib);<br />
<br />
return true;<br />
}<br />
The function is called like this:
<br />
FormatBodyText(MsgQry->m_strBodyText, Attrib);<br />
MsgQry is a pointer to a class containing the various parts of the email message.
Attrib is a pointer to a class containing the program's attributes.
Thanks again
|
|
|
|
|
Have you narrowed it down to a CString object formatted in a particular way? I tried it with a few "dummy" strings and it did not crash. I'm not sure if it did what it was supposed to (logic), but it did not crash.
|
|
|
|
|
It only crashes on one particular string (email body text). There is nothing unusual about the body text at all. The code works perfectly on every other string I throw at it. I'm assuming that the string itself or the code is not the problem because the Mid() stopped the error and the error doesn't occur while stepping through the code.
Are there any known allocation issues with CStrings? What kind of memory movement does a Mid perform that would stop this from happening.
Another note of interest is that in order for the Mid to stop the error, it has to pull a substring from within the string. Performing a Mid(0,str.GetLength()) still causes the error. Performing a Mid(5,20) stops the error. *shrug*
|
|
|
|
|
Here is another strange point. After making the statement above about "performing a Mid(5,20)", I tried that exact number (I was just using those numbers as an example. I had up till this point, used the vars I had available in the loop). That didn't work! In order to make the error stop, I have to pull at least 48 chars in the mid:
<br />
strTemp = String.Mid(106, 48);<br />
It doesn't matter where in the string I start. Mid(1,48), Mid(1000,48). Just as long as I pull at least 48 chars from the string. Anything less, creates the error.
*big shrug*
|
|
|
|
|
Just a curiosity...
Does:
String.Replace("\n", "\r\n");
not work for some reason?
- Nitron
"Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb
|
|
|
|
|
I'm not simply replacing \n with \r\n. I'm wrapping a string at specified positions. If linewrap is set at 80, then I move to that pos in the line then look for the next space (don't want to wrap in the middle of a word), and insert a \r\n.
|
|
|
|