|
Ista wrote:
no they are different classes.
Then use FindWindow() .
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
but I need information on the window. more than just the name. i.e... there could be 2 ListViews and I would need to find a way to differentate.
I think I saw a WindowInfo structure somewhere and that would help me.
thanks for helping but I can probably figure it out.
-- too bad I can't tie static fields to edit fields.
Nick
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
well thanks. I just need to enumerate the windows. FindWindow wont work becuase listViews dont have a name.
But enumerating will allow me to check the subclass of each window therefore finding the list view.
But this would only work for one list view and if theres 2 then I'm back to the same spot.
but thnkas everyone for helping.
Nick
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
Ista wrote:
...listViews dont have a name.
But they do have a unique identifier. Once you have a handle to the parent window, just use GetDlgItem() to get a handle to the control itself.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
As far as I understand, the CDocument::m_bAutoDelete variable will tell MFC that it should not delete the document when closing the last view attached to it when set to FALSE .
I tried this with a simplistic MDI MFC application, setting m_bAutoDelete to FALSE in the CDocument constructor; but when I close the last view ( WM_CLOSE on the ChildFrame ), it closes the view ( and frame ), but will replace the current menus with the ones for when there is no document active.
I wanted to have the document loaded with all the views closed, and still have the "Window" ( with the new window command ) menu available.
I want to make sure the user close the document with a "Close" document command, not by closing all the views.
Any Ideas ? I google for this, but nothing really interresing came up.
Thanks.
Max.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
This goes back *years*, but...
Back in 1995 when I was at Peachtree we had a similar situation where the document represented the company whose accounting you were doing and each view was based on that document. Therefore, closing the last view didn't close the document/file. (The user either closed the company explicitly or via closing the app)
As you mentioned, setting the m_bAutoDelete member var in a CDocument-derived class does the trick.
Obviously, the framework has to shut down the menu as it's associated with the view/frame in the template.
Therefore, what we did was to share the menu across all views. IOW, we had a menu (named something like IDR_COMPANY_OPEN) that was always displayed when a cmopany was open regardless of how many views were open.
However, the trick is that when constructing templates, you have to specify a res id that among other things identifies the menu. However, we only wanted to share the menu across all views - not anything else. Therefore, we did the following (I'll try and explain it from 10 years of memory.
* In the app object's InitInstance, we manually loaded a menu and stored its handle
* We derived our own CMultiDocTemplate class
* When constructing each template, we passed the menu handle to that c'tor
* The CMultiDocTemplate-derived class's c'tor then set its internal menu handle to that passed
* [IMPORTANT] In the d'tor you have to set the handle to null. Otherwise, the base class's d'tor will attempt to destroy your shared menu.
I'm pretty sure that was all we had to do.
Tom Archer - Visual C++ MVP
Archer Consulting Group.com
|
|
|
|
|
|
Thanks ... will have a look at it tomorrow.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Maximilien wrote:
I wanted to have the document loaded with all the views closed, and still have the "Window" ( with the new window command ) menu available.
How about the simple solution of adding the commands you want to the main menu (usually IDR_MAINFRAME)?
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
Hello...
I like to support custom text printing in my application (without an edit control)...
The wtl examples that i found at codeproject only support text printing with edit controls...
I implemented the CPrintJobInfo class but unfortunely when it draw the text to the dc (in the PrintPage method) it only print the first drawing operation...
For example .:
bool CMainFrame::PrintPage(UINT nPage, HDC hDC)
{
CDCHandle dc = hDC;
CString text = _T("A Test");
dc.TextOut(0,0,text,text.GetLength()); // This text is only visible on page
dc.TextOut(0,20,text,text.GetLength());
dc.TextOut(0,40,text,text.GetLength());
return true;
}
I hope anybody can help me ...
|
|
|
|
|
Ehmmm... I have found the bug or better my own mistake...
I forget the different resolutions between the screen and printer dc...
The distance between the 3 strings was to small to see them completly...
For example.:
dc.TextOut(0,0,text,text.GetLength());
dc.TextOut(0,400,text,text.GetLength());
dc.TextOut(0,800,text,text.GetLength());
woks...
|
|
|
|
|
I am new to MFC and I am trying to make a program that can input data in Edit boxes and then be able to save it.... I am using the CFormView class..
I add my edit box- example: m_first_name and it adds the
IDD_Text(PDX,FNAME,m_first_name)
My question is how do I get the data in that edit box to my CDocument class to serialize and save it?
void CExampleDoc::Serialize(CArchive& ar)
{CObject::Serialize( ar );
if (ar.IsStoring())
{
ar<<m_first_name;
todo:="" add="" storing="" code="" here
="" }
="" else
="" {
="" ar="">>m_first_name;
// TODO: add loading code here
}
}
I know the above wont work because m_first_name is not apart of the CDoc class...
Thanks for any help given!
|
|
|
|
|
|
then add code in your View to send the data to the Doc.
I have the m_first_name in the CFormView class....
CString m_first_name ;
The problem is I am not sure how to send it to the Doc....
I have been trying to use pointers and anything that has come to mind but nothing seems to work...
Is there an example somewhere that could point me in some direction?
I am lost....
|
|
|
|
|
add a public function in your Doc, CMyDoc::SetFirstName(CString str) .
in your View:
CMyDoc *pDoc = GetDocument();
if (pDoc) pDoc->SetFirstName(m_first_Name);
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|
In view in DDX.. fuction call
GetDocument()->SaveName(m_first_name)
or OnKillFocus()
GetDocument()->SaveName(m_first_name)
create respective memer in CDocument derived class add fuction which set mem var
which is comming from your View
Then do what ever you doing in Serialize.
Resume
Only pass to the document value of control which you got in view.
View has controls, document suppose to keep data from that controls.
Ok?
|
|
|
|
|
You see Cris did same think that I mean but sorter and erlyer. That means he is defenitly smarter.
))
|
|
|
|
|
Thanks for the help... I am starting to get a clear picture on how to do it...
|
|
|
|
|
Is there any easy way to create event\message maps in Visual studio 2003.I counld not find the class wizard.Any help plz.
|
|
|
|
|
The class wizard does not exist anymore in 71. You will need to map any events and messages VB-Style, via the properties window.
I Dream of Absolute Zero
|
|
|
|
|
i havent used VB, can u plz give me somelink that will help me..
Thanks
|
|
|
|
|
This[^] will explain the steps necessary.
I Dream of Absolute Zero
|
|
|
|
|
What is the definition of a smart pointer?
|
|
|
|
|
Smart pointer def[^]
... she said you are the perfect stranger she said baby let's keep it like this... Tunnel of Love, Dire Straits.
|
|
|
|
|
Better read in any COM book it is very simple thing it will take 10 min to understand.
|
|
|
|