Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
C

CDuddley

@CDuddley
About
Posts
14
Topics
5
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Array Question...
    C CDuddley

    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 pt:(%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

    C / C++ / MFC database graphics data-structures question

  • Simple question
    C CDuddley

    Are you writing a chess engine? -CDudd

    C / C++ / MFC question debugging beta-testing help

  • Collection Class Question
    C CDuddley

    I've been trying for about an hour or so and I'm royally stuck. Basically I've got a class CShapePt. The program is like a mini paint utility. Whenever the user clicks on the client area it takes the point clicked. Then the next time he/she clicks it draws a line between the two places. The Array it was using was in the MainFrame Header file. I'm not exactally sure how to put the CShapePt object into the MainFrame header file so that the device context can access it. How do you do those code highlighter things? If you need some code to help you see what I'm having trouble explaining I'll be glad to put some snippets on here. Thanks. -CDudd

    C / C++ / MFC c++ data-structures question

  • Collection Class Question
    C CDuddley

    Sorry I meant to create 100 Stuffs not CStuffs. -CDudd:-O

    C / C++ / MFC c++ data-structures question

  • Collection Class Question
    C CDuddley

    I need a CStuff class to use all the functions of CObList so I can create a list of 100 CStuff objects. -CDudd No offense taken, your right I don't quite understand CObList...yet, but it's just one class others I know how to use. Since I don't know anything at all about STL I don't use it. ;)

    C / C++ / MFC c++ data-structures question

  • Collection Class Question
    C CDuddley

    Well for a class to use the CObList it has to be derived from CObList. So, if I made a CStuff class how would I derive and, use it to make it like an array? -CDudd I don't know how to use STL so that is why I don't use it. :)

    C / C++ / MFC c++ data-structures question

  • Collection Class Question
    C CDuddley

    Say I have an array Stuff[100] how would I make that into a collection class I'm having trouble understanding this. I need to derive it from the CObList in MFC. Thanks for your time guys. -CDudd:)

    C / C++ / MFC c++ data-structures question

  • Creating Styles...
    C CDuddley

    How do you handle them I guess is what I was wondering. Say you have an enumeration. enum { ID_STYLE1 = 0, ID_STYLE2 = 1, ID_STYLE3 = 2 }; How do you handle the those styles in a function with the bitwize OR and AND ops? Thanks for the inputs in advance. -CDuddley

    C / C++ / MFC wpf question

  • Creating Styles...
    C CDuddley

    How would you create and implement styles into your own custom class? Thanks for you replies in advance. -CDuddley

    C / C++ / MFC wpf question

  • Destructor Question...
    C CDuddley

    How do you know when an object is going to destruct? Provided you don't implicitly call the destructor. Thanks in advance. -CDudd

    C / C++ / MFC question

  • Question about CPoint objects...
    C CDuddley

    You're awesome I got the exercise working without a hitch! Thanks a ton man. -CDudd

    C / C++ / MFC c++ help question data-structures tutorial

  • Question about CPoint objects...
    C CDuddley

    Thanks a bunch for the post. I was having trouble with the fact that if a random point was greater than the given point the point would be negative when I took the difference. I forgot all about the euclidian distance formula thanks a ton! I'll try to get the test program working now! Thanks again, CDudd

    C / C++ / MFC c++ help question data-structures tutorial

  • Question about CPoint objects...
    C CDuddley

    I have tried that. I'm not really sure where to go from there. Another hint please? I'm not trying to do 'anything' I'm just trying to learn. Thanks for the quick post. -CDudd

    C / C++ / MFC c++ help question data-structures tutorial

  • Question about CPoint objects...
    C CDuddley

    Hi I'm new to this forum, but I think it's pretty cool. I had a question about CPoint object. I need to be able to randomly generate an array of them. Which I got that far, but my problem was when the user entered a point, and I was supposed to tell the program to find the closest point in the array. Do any of you know how to do that? I tried using like the '<' compare operator but the CPoint class doesn't have that operator. Don't worry I'm not trying to get free homework (I'm using Introduction to MFC with Visual C++ to learn MFC) or anything I just don't understand and I would like to understand it. Thanks in advance for your help. -CDudd

    C / C++ / MFC c++ help question data-structures tutorial
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups