How to implement these graphics commands

In my MFC program which is MDI application with scrollable views, user
places
lines , rectangles, now I want to have delete , move command in my
application
But I can not derive the algorithm for the same. My linees are strored
in
CTypedPtrList<CObList, CLineString*> m_linestringList; in Document
class.
CLinestring is having CArray<CPoint,CPoint>  m_pointArray;
so rectangles ellipses are having similar kind of data storage. Now as
user choses move, then application should identify the line by clicking
on it and should be able to move as user draggs the mouse with left
button down. as left button is released the element should be placed at
the last location.
Here how should the mouse stick to the element (not on key points), how
should I recognise the closest element as there must be many elements
in the vicinity of the identified point like rectangles, ellipses.
THese elements should be located in their data storage too and updated.
in case delete it should be deleted.
lee

0
yang__lee (48)
4/7/2006 12:29:39 PM
vc.mfc 33608 articles. 0 followers. Follow

3 Replies
409 Views

Similar Articles

[PageSpeed] 38

yang__lee@ausi.com wrote:
> In my MFC program which is MDI application with scrollable views, user
> places
> lines , rectangles, now I want to have delete , move command in my
> application
> But I can not derive the algorithm for the same. My linees are strored
> in
> CTypedPtrList<CObList, CLineString*> m_linestringList; in Document
> class.
> CLinestring is having CArray<CPoint,CPoint>  m_pointArray;
> so rectangles ellipses are having similar kind of data storage. Now as
> user choses move, then application should identify the line by clicking
> on it and should be able to move as user draggs the mouse with left
> button down. as left button is released the element should be placed at
> the last location.
> Here how should the mouse stick to the element (not on key points), how
> should I recognise the closest element as there must be many elements
> in the vicinity of the identified point like rectangles, ellipses.
> THese elements should be located in their data storage too and updated.
> in case delete it should be deleted.
> lee
> 

The DRAWCLI MFC sample program shows how to do these things.

-- 
Scott McPhillips [VC++ MVP]

0
Scott
4/7/2006 1:14:27 PM
Your items should be able to tell you if the mouse is on them or not.
If you are doing this in an object oriented way, then all your shapes should
inherit for the same base class and that should have a method like

BOOL HitTest(const CPoint &point);

when the user clicks the left mouse button to select an item you can loop
through your object in the zorder from top to bottom, and call each one's
HitTest until one returns true.
Your LButtonDown handler should also keep track of where the user clicked.
And when you get mouse move message you can move your graphic item by the
offset of the two values.

void CMyWnd::OnLButtonDown(nFlags, Point)
{
    m_LastPoint = Point;
    //get selected object would loop through the items and find the one that
got hit
    m_SelectedObject = GetSelectedObject(Point);
}

void CMyWnd::OnMouseMove(nFlags,Point)
{
    if (nFlags & MK_LBUTTON)
    {
        CPoint Diff = Point - m_LastPoint;
        m_SelectedObject->Move(Diff);
        m_LastPoint = Diff;
    }
}

AliR.

<yang__lee@ausi.com> wrote in message
news:1144412979.185944.86950@u72g2000cwu.googlegroups.com...
> In my MFC program which is MDI application with scrollable views, user
> places
> lines , rectangles, now I want to have delete , move command in my
> application
> But I can not derive the algorithm for the same. My linees are strored
> in
> CTypedPtrList<CObList, CLineString*> m_linestringList; in Document
> class.
> CLinestring is having CArray<CPoint,CPoint>  m_pointArray;
> so rectangles ellipses are having similar kind of data storage. Now as
> user choses move, then application should identify the line by clicking
> on it and should be able to move as user draggs the mouse with left
> button down. as left button is released the element should be placed at
> the last location.
> Here how should the mouse stick to the element (not on key points), how
> should I recognise the closest element as there must be many elements
> in the vicinity of the identified point like rectangles, ellipses.
> THese elements should be located in their data storage too and updated.
> in case delete it should be deleted.
> lee
>


0
AliR3470 (3235)
4/7/2006 6:27:22 PM
Maybe you could provide a droplist with names/labels of all the 
drawing elements on screen... and then based on user's choice, select 
the corresponding shape and all it to be moved around.

Or perhaps have each element occupy a different 'layer'... allowing 
elements on the same layer to be moved together. You can place the 
layers in  a stack-like arrangement... like it is in Adobe Photoshop.



Hope this helps...
-- 
cheers
Adeel 


0
Adeel
4/7/2006 6:48:02 PM
Reply:

Similar Artilces:

graphical problems
Hi I have produced several graphs of beach profiles using excel. They are basically scatter graphs plotted with height against distance. I need now to sort the data out into a format where I have a data point (with height and distance) every 10cm drop in height. In most cases the data does not provide me with this, but I hoped that I could get it off the graph. Thanks ...

How to implement this?
Greetings, I want to check if current application is the active window, if not, then I want the window blink. Just like MSN receives a new message when it is not active. How to implement that? My target platform is Win2K. Evan "music4" <music4@163.net> wrote in message news:Os85ecxTGHA.424@TK2MSFTNGP12.phx.gbl... > Greetings, > > I want to check if current application is the active window, if not, then > I > want the window blink. Just like MSN receives a new message when it is not > active. How to implement that? My target platform is Win2K. GetForegr...

Spot Color, Word Art, Autoshapes
I designed a project using PUBLISHER 2002. It came out great. However, when I save for pre-press SPOT COLOR (PANTONE), all the WORD ART graphics, and AUTOSHAPES turn GREY. The graphics that turn grey were all FILLED with a cloud graphic that was included with the program. I recolored the graphic using the FORMAT PICTURE>RECOLOR option to the PANTONE as I was advised by my printer. I also selected COLOR PRINTING>SPOT COLOR prior to saving. I also tried it by setting COLOR PRINTING>SPOT COLOR and selecting the PANTONE prior to designing the document. I am about to go to ...

not displaying graphics in publisher 2003
I am unable to see any Clipart, WordArt. Lines or Autoshapes in publisher 2003. I have done a complete reinstall of xp and office 2003. All services packs are applied for office & xp. Clipart is displayed in all other office products ok. There's a possibility that you need to update your video driver. It might be worth a try to check your Video Adapter mfg's website for a more current version. -- John Inzer "Olddog" <Olddog@discussions.microsoft.com> wrote in message news:DD69E4A5-0E61-4382-AD4E-C233E316BA73@microsoft.com... >I am unable to see any Clipar...

Update Form with Command Button
I have a report which is created using criteria entered into a form. There is already a button on the form which opens the report. If someone does not tab out of a particular box then sometimes the the control isn't updated and the report doesn't get the proper criteria. I can use the button to update all of the individual controls before creating the form, but can I use the button to update the entire form instead? RMires, Just do a... Refresh DoCmd.OpenReport... etc... -- hth Al Campagna Microsoft Access MVP 2006-2009 http://ho...

Problem with IOCTL command IOCTL FSCTL_SET_REPARSE_POINT
Hi I'am being developpe a drive virtual disk file system. When I call API definedosdevice on my name device , it's OK, it works for a drive letter I can see virtual files and virtual directory. I'am try with the command IOCTL FSCTL_SET_REPARSE_POINT to make a link empty directory on my virtual disk containing some virtual files installed with DeviceType = FILE_DEVICE_DISK_FILE_SYSTEM and devicecharacteristics = FILE_DEVICE_IS_MOUNTED , it's ok for command IOCTL FSCTL_SET_REPARSE_POINT. Problem : it's don't work when click directory linked to my disk contain...

How to implement CCheckListBox
How does one correctly implement CCheckListBox? Dhe docs say to derive your own class and then call Create(); I tried to do that. My code is the following in a file StdChkListBox.h: #include <afxwin.h> class CStdChkListBox : Public CCheckListBox { public: } The error returned was was error c2504: Public: base class undefined CCheckListBox is defined in afxwin.h, right? how come it isn't working? Any idea? C++ is case sensitive. Try 'public' instead of 'Public'. Something like class CStdChkListBox : public CCheckListBox { } -- Cheers Check ...

Implementing Single Sign On #2
Thanks Mark & BigHaig, I tried it but its not working yet.I use SSL for my OWA authentication i.e https://servername/exchange.Could this be why its not working? -- Buchi On Thu, 13 Oct 2005 12:40:04 -0700, "Buchi" <Buchi@discussions.microsoft.com> wrote: >Thanks Mark & BigHaig, >I tried it but its not working yet.I use SSL for my OWA authentication i.e >https://servername/exchange.Could this be why its not working? Yes absolutley. You didn't say about making that switch on your previous posts. You must enter credentials when you use SSL. ...

COMMAND Vs. UPDATE_COMMAND_UI
Hello all, When I add an even handler for a menu item, I am presented with a choice of two message types: COMMAND UPDATE_COMMAND_UI What is the difference between these? Thanks, Dave COMMAND is where you do what the menu item tells you UPDATE_COMMAND_UI is where you enable/disable the menu item, change its text, or add a check mark or something like that. void CWhereever::OnUpdateStopRun(CCmdUI * pCmdUI) { pCmdUI->EnableWIndow(canstoporrun); if(canstoporrun) if(running) pCmdUI->SetText(_T("Stop")); else pCmdUI->Set...

Windows Sockets implementation
I have used Winsock2 for my application to communicate with the device over TCPIP socket.I get the following sequence of events . 1. The Application that runs the Client socket is alive.But after about 24 hrs. the network connectivity for the Machine is disabled. 2. On further investigation of the issue I found that in the Event viewer the event has been noted as Event ID -2019 and the note alongside is "The server was unable to allocate from the system nonpaged pool because the pool was empty." Do help me out with this. As I have no clue as to why it behaves so. "Rohan Bh...

Microsoft Dynamics CRM 3.0 Implementation For Large Corporation (August 2006)
How Microsoft CRM 3.0 could contribute and be a part of its computer environment. (Sales Module, MS CRM Security, Integration with Microsoft Dynamics GP 9.0/Microsoft Great Plains,Integration with IBM Lotus Notes Domino ,International Considerations, Competition) http://microsoft-crm-3.blogspot.com/2006/08/microsoft-dynamics-crm-30.html ...

Yahoo! DomainKeys Implementation
So, my company has been noticing a large portion of our email sent externally is now ending up in 'Spam' and 'Bulk' email folders. We have a current and valid SPF record and are not listed on any blacklists. From my research, I have found all our emails are not signed with Yahoo!'s DomainKeys signature; which many front-end 3rd party spam filters are looking for...especially Yahoo! and MSN mailboxes. I have Googled until my eyes have bled and can find only general information pertaining to DomainKeys but virtually nothing on how to implement DomainKeys in our Exchan...

How to implement OnChar?
I have an application I wrote in MSVC4 and OnChar seems to work fine when I compile it for MSVC7. However, when I create my minimal "Hello World" program in MSVC7 and try to implement the OnChar Message handler, it never gets called. When I override OnLButtonDown, that works. Why does not not OnChar work? Thanks, Siegfried "Siegfried Heintze" <siegfried@heintze.com> wrote in message news:OSaMLwQmFHA.3900@TK2MSFTNGP09.phx.gbl... >I have an application I wrote in MSVC4 and OnChar seems to work fine when I > compile it for MSVC7. > > However, when I cre...

menu commands are gray
When making a new file, commands are okay. I have a file I update once per month, however now some of the menu options are grayed out. Worksheet is not protected. Can anyone help me? kcohio You don't say which items are grayed out, so just guessing here. Possibly you have two or more sheets "grouped" as in selected? Do you see [Group] behind the filename in title bar? Note which sheets are grouped. The sheet tabs will be white. Then right-click on any sheet and "ungroup". Note: check your data carefully on any sheets that were grouped. What you have done to...

Undo-Redo feature implementation
Hi, I have a graphic editor application, where the user can create/edit images using pixels. I would like to provide an Undo-Redo feature to it, but am not sure how to proceed with it. Of course, it should support any level of undo redo. Is some kind of stack required? Appreciate if anyone could provide me some ideas/samples. Thanks, Sucharit ...

Change graphic chart color bar based on name?
Hello to all! I have a horizontal graphic chart showing Intel and AMD processors speeds. I was wondering if it is possible to tell Excel to apply a color to Intel processors bar and another to AMD ones? See file in attachment. Thanks a lot for any help. +-------------------------------------------------------------------+ |Filename: CPU Charts 2008 Q1 2008 - 3ds 9.xls | |Download: http://www.thecodecage.com/forumz/attachment.php?attachmentid=180| +-------------------------------------------------------------------+ -- Jimic --------------------------------------------...

SSPI implement SSL
Hi All Happy coding : ) I want implement a smtp client for gmail. In my code I use the SSPI to implement the SSL. In my program, some code is from Using SSPI with a Windows Sockets Clienthttp://msdn.microsoft.com/library/default.asp?url=/library/en-us/secauthn/security/using_sspi_with_a_windows_sockets_client.asp[^]. The handshake and DectryptMessage is OK. But EnctryptMessage seem to occur error. dos any one have any idea about this? Here is my code: #include "stdafx.h" #include "SSPI.h" #ifdef _DEBUG #define new DEBUG_NEW #endif //----------------------------------...

Code Be Hind Command Button Not Working.
Hi All, Ive Been Using a Simple Code to Open another form and close the Current form, it works perfectly fine, untill this morning i created a new form and now that the code won't work, they typyical code im using is as follows Private Sub CmdSearch_Click() DoCmd.OpenForm "frm_ViewProjectsByClients" DoCmd.Close acForm, Me.Name End Sub But what happens now when i click on the button when the form is in normal mode is as follows. The Expression on the On Click You Entered a the event property setting produced the following error: A Problem Occurred While Microsoft Office Acce...

NOT IMPLEMENTED
this is the message i keep getting when trying to check my email in OUTLOOK '07 ***not Implemented*** then it tells me i need to redownload my micrsoft email 07 which i can't seem to find... what do i do? ...

How to implement TRACE
Hi there: I am developing with Platform SDK and IDE is VC++ 2005, I don't know how to ouput a string to the output window of IDE. In MFC we can use TRACE to do it, so how to make the same effects just use API? Thanks. >I am developing with Platform SDK and IDE is VC++ 2005, I don't know >how to ouput a string to the output window of IDE. In MFC we can use >TRACE to do it, so how to make the same effects just use API? OutputDebugString. Dave If you use "OutputDebugString" API, you can debug the app in release mode using "Dbgview.exe" this software i...

Spot Color, Word Art, Autoshapes
I designed a project using PUBLISHER 2002. It came out great. However, when I save for pre-press SPOT COLOR (PANTONE), all the WORD ART graphics, and AUTOSHAPES turn GREY. The graphics that turn grey were all FILLED with a cloud graphic(.bmp) that was included with the program. I recolored the graphic using the FORMAT PICTURE>RECOLOR option to the PANTONE as I was advised by my printer. I also selected COLOR PRINTING>SPOT COLOR prior to saving. I also tried it by setting COLOR PRINTING>SPOT COLOR and selecting the PANTONE prior to designing the document. I am about to...

Command or action '' isn't available now
This is more of an annoyance than anything, but in Access 2007, whenever I use some custom menu options from right-clicking the Access window title bar, I get the infamous "Command or action '' isn't available now" error. That's right, a blank command or action! The custom menus in this case are from UltranMon: Move to Other Monitor, and Maximize to Desktop. Weird. -- Eric Legault - Outlook MVP, MCDBA, MCTS (SharePoint programming, etc.) Try Picture Attachments Wizard for Outlook: http://www.collaborativeinnovations.ca Blog: http://blogs.officezealot.com/leg...

Macro help to position a freeze pane command
I have a macro where it filters rows based on a user request. I want to lock the title rows on the first visible row below row 2 on column J. The problem I am having is how to instruction the freeze pane command to occur in column J on the 3rd visible row down. Does anyone have any ideas? Thanks, Alan On a scale of 1 to 100, representing expertise in VBA, I'm about a 12. But, I've always found it educational to record a macro while performing the actual keystrokes, inspecting the resulting code, and then editing it appropriately. Sometimes, it requires a book alongside the computer...

DocClass Implement Serial
Well I have done a bit more study and experimenting and I have 3 questions. Appreciate input from everyone as usual and hopefully Goran will also reply since he has helped me the most on serialization and from going back and rereading the context of his replies (after I studying and experimenting enough to even understand them) I can tell the he has a firm grasp on what is going on in MFC's serialization process. , My first question is, I can not help but wonder why MFC does not generate the Doc class (derived from CDocument) with the Serial macros as opposed to the Dyncre...

Implementing an idea ...
Hello everyone. I am currently trying to create an Excel spreadsheet that will allow someone to organise a tournament (a videogaming tournament) Basically, the tournament starts with the players being split into 4 groups, in each group a player must play every other player twice, someone can either win 2-0 or the two opponents can draw 1-1. At the end of the four groups the four highest placing participants are entered into a 16 man knockout tournament (single elimination) I am stuck with trying to think of a viable method for organising the group stages. Players need to be given 1 point p...