I think Fahr's problem is similar to my problem.I want to explain more , maybe someone could solve our problem. I wrote a program that someone could choose items from a toolbar and put them on the document by clicking left button of mouse on the view. I considered a CRectTracker variable for each symbol and in the OnDraw function I draw each symbol's tracker's rectangle.And for selecting each symbol which is shown on the page I check if the position of left click of mouse is in the tracker of any of the symbols or not.At the beginning I used CView class but now I want to use CScrollView in order that my program could support scrolling.I changed the base class of my view class to CScrollView and write some lines in its OnInitialUpdate in order to set the size of scrolling.Now I scroll my program but when I put an item on the page and scroll the page , in some places that my item doesn't exist , it seems that its tracker exists and if I move it or delete it or sth else , those changes would be applied on the real item that is somewhere upper than there. I think I should change the coordinates of the CRectTracker variable of my item , but I don't know how. Thanks Azadeh
Azadeh
Posts
-
CRectTracker inside a CScrollView -
How to get name of a file opened by Open dialog box?As you said , I overrided CDocument::OnOpenDocument() , but I simply open a text file and in that case this function isn't been called.I think it only opens files that are saved with serilizing and using CArchive and it doesn't open my text file.I used a text file to save graphic items that are drawn by the user in my project and I want user can open the file in a symbolic way then I draw the items using text file.However this is enough for me that I can get the name of file even if it hasn't opened really.I thought it opens file and I can not open it simultanously.But even for a file that is saved with the CArchive format, it seems that it opens the corresponding file and then close it because I can open the same file at that time.
-
How to get name of a file opened by Open dialog box?I want to open it by myself to be able to read and write to and from it.
-
How to get name of a file opened by Open dialog box?Thank you! It worked well.
-
Tree Control and CDocumentThank you and my problem is solved by adding the following lines to my code which I found in MSDN: CMDIFrameWnd *pFrame = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd; // Get the active MDI child window. CMDIChildWnd *pChild = (CMDIChildWnd *) pFrame->GetActiveFrame(); // or CMDIChildWnd *pChild = pFrame->MDIGetActive(); // Get the active view attached to the active MDI child // window. CMyDoc *pDoc = (CMyDoc *) pChild->GetActiveDocument(); You're right,using C style casts isn't good ,but I don't know exactly where I can use dynamic_cast and static_cast operators.Once I wanted to type cast a pointer to a base class to a pointer to one of its derived class with these operators but I wan't successful. Base b; // suppose base class has a pointer to Base named link Derived* d; b.link=new Derived; First of all ,can I use b.link as a pointer to Derived and use fields of Derived?
-
How to get name of a file opened by Open dialog box?Hi friends, How can I get the name of file which is opened by the user by means of open dialog box in a document/view architecture? Thank you, Azadeh
-
Tree Control and CDocumentYes , you had right , it was NULL .But what can I do ? I don't know how to access to active document.My code is as follows: void MyTreeCtrl::OnDblclk(NMHDR* pNMHDR, LRESULT* pResult) { HTREEITEM hItem = GetSelectedItem ( ) ; Symbol* item; CRect rectSave1; CMyDoc* doc; CMDIFrameWnd f; doc=(CMyDoc*)f.GetActiveDocument(); if(doc!=NULL) { if ((item=doc->Find(hItem))!=NULL) { CRectTracker rectTracker=item->tracker; doc->ChangeTrackerStyle(rectTracker); doc->SetModifiedFlag(); rectTracker.GetTrueRect(rectSave1); doc->UpdateAllViews(NULL, (LPARAM)(LPCRECT)rectSave1); doc->UpdateAllViews(NULL); } } *pResult = 0; } I work with an MDI application.
-
Tree Control and CDocumentEven I used CFrameWnd::GetActiveDocument() to get pointer to the document , but it wasn't useful and the same error is repeated.
-
Tree Control and CDocumentI run it in debug mode.I have written a function in my class CMyDoc::CDocument and I call it without any problem but when I call SetModifiedFlagfunction , an exception raises. I think this problem relates to the way I call these functions.I defined a global pointer to CMyDoc and initialized it with the GetDocument function in the CMyView::CView .So I use this global pointer to call CMyDoc functions.Of course I call these functions in another class CMyTreeCtrl::CTreeCtrl.
-
Tree Control and CDocumentI've written a program which has a tree control placed on a dialogbar in a MDI application.I want my tree control to have this ability that if I click on a tree item , it shows the coresponding item that I've drawn before on the document.I wrote some codes for it but when I use the "SetModifiedFlag" and "UpdateAllViews" functions, it issues error that "program should be terminated and the instruction at the specified address couldn't be read.".Is this possible to do ?