Click here to Skip to main content
15,911,035 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Need to know when a user logs off or switches to another user Pin
16-Mar-02 17:18
suss16-Mar-02 17:18 
GeneralRe: Need to know when a user logs off or switches to another user Pin
16-Mar-02 17:22
suss16-Mar-02 17:22 
GeneralRe: Need to know when a user logs off or switches to another user Pin
Andres Manggini17-Mar-02 3:44
Andres Manggini17-Mar-02 3:44 
GeneralRe: Need to know when a user logs off or switches to another user Pin
Michael P Butler17-Mar-02 4:15
Michael P Butler17-Mar-02 4:15 
GeneralRe: Need to know when a user logs off or switches to another user Pin
17-Mar-02 4:50
suss17-Mar-02 4:50 
GeneralRe: Need to know when a user logs off or switches to another user Pin
Andres Manggini17-Mar-02 5:01
Andres Manggini17-Mar-02 5:01 
GeneralRe: Need to know when a user logs off or switches to another user Pin
17-Mar-02 5:18
suss17-Mar-02 5:18 
GeneralArray Question... Pin
CDuddley16-Mar-02 13:55
CDuddley16-Mar-02 13:55 
I'm trying to write an undo feature for a drawing program. I have an array of CPoint's called ShapePts[100]. I made another array of CPoint's Undo[100]. When the program deletes a point it finds the closest point to the mouse. So, I was thinking just store the point in another array before it gets deleted.

/* This is the MainFrame.h declaration */
CPoint Undo[100];
int nUndo;


void CMainFrame::OnLButtonDown (UINT nFlags,
CPoint MousePt)
{
int ShortDist;

if (nFlags & MK_SHIFT)
{
// Shift key down. So delete closest point.
if (nPts > 0) // - only if have one
{
// Step: Find point closest to MousePt
Pos = ClosestPoint (MousePt,ShapePts,nPts, ShortDist); <-- returns int
Undo[nUndo] = ShapePts[nPts]; // nPts and nUndo were initialized to
// zero in MainFrame contructor

// Step: Shift points down one array component index
for (int i = Pos + 1; i < nPts; i++)
{
ShapePts[i-1] = ShapePts[i];
}

nPts--; // adjust count
} // end if
}
else
{
if (nPts >= 99) // array full
return; // do nothing
else
{
ShapePts[nPts] = MousePt;
nPts++;

CString s;
s.Format("Last ptFrown | :( d, %d)",MousePt.x, MousePt.y);
myStatusBar.SetText (s,1,SBT_NOBORDERS);
}
}
Invalidate();
}




void CMainFrame::OnRButtonDown (UINT nFlags, CPoint MousePt)
{
CPoint ScreenPt;
int ShortestDist, i;

// Step 1: Find position of closest pt in array
Pos = ClosestPoint (MousePt, ShapePts, nPts, ShortestDist);

if(nFlags & MK_SHIFT)
{
ShapePts[nPts] = Undo[nUndo];
nPts++;

for(i = 0; i < nUndo; i++)
{

Undo[i-1] = Undo[i];
}

nUndo--;
}
else
{


SetCapture();



// Step 2: Move the cursor to that position
ScreenPt = ShapePts[Pos];
ClientToScreen (&ScreenPt);
SetCursorPos (ScreenPt.x, ScreenPt.y);
}
}



Where am I going wrong. If you need more info please let me know.

-CDudd
GeneralRe: Array Question... Pin
Christian Graus16-Mar-02 14:05
protectorChristian Graus16-Mar-02 14:05 
GeneralRe: Array Question... Pin
Tim Smith16-Mar-02 14:14
Tim Smith16-Mar-02 14:14 
QuestionHow to save RTF or DOC file without CRichEdit ? Pin
Wizard_0116-Mar-02 10:37
Wizard_0116-Mar-02 10:37 
AnswerRe: How to save RTF or DOC file without CRichEdit ? Pin
Shog916-Mar-02 12:36
sitebuilderShog916-Mar-02 12:36 
AnswerRe: How to save RTF or DOC file without CRichEdit ? Pin
Michael P Butler17-Mar-02 4:21
Michael P Butler17-Mar-02 4:21 
GeneralRegex! Pin
Cam16-Mar-02 10:31
Cam16-Mar-02 10:31 
GeneralRe: Regex! Pin
Tim Smith16-Mar-02 12:06
Tim Smith16-Mar-02 12:06 
GeneralSuppress user input Pin
16-Mar-02 10:25
suss16-Mar-02 10:25 
GeneralRe: Suppress user input Pin
Morozov Alexey16-Mar-02 20:08
Morozov Alexey16-Mar-02 20:08 
GeneralShow/hide toolbars Pin
Stew16-Mar-02 10:04
Stew16-Mar-02 10:04 
GeneralRe: Show/hide toolbars Pin
Derek Waters17-Mar-02 12:28
Derek Waters17-Mar-02 12:28 
GeneralFrequency Generator Pin
Peter Liddle16-Mar-02 9:21
Peter Liddle16-Mar-02 9:21 
GeneralOCR Pin
16-Mar-02 7:24
suss16-Mar-02 7:24 
GeneralMultithread question repost...... Pin
16-Mar-02 7:06
suss16-Mar-02 7:06 
GeneralRe: Multithread question repost...... Pin
Michael Dunn16-Mar-02 7:41
sitebuilderMichael Dunn16-Mar-02 7:41 
GeneralRe: Multithread question repost...... Pin
Morozov Alexey16-Mar-02 20:15
Morozov Alexey16-Mar-02 20:15 
QuestionHow do i get a handle from Desktop ? Pin
CryoGate16-Mar-02 4:51
CryoGate16-Mar-02 4:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.