|
If you're using MFC, the document templates which are part of your application and which are registered are used to build the filter in the open file dialog. The best way to learn about MFC is to dig here. You can also learn all about CDocument::OnOpenDocument there.
OnOpenDocument does not actually create the dialog box you're asking about. It is a result of MFC mapping the extension to one of your registered document templates after the user selects a file. To learn about the dialog, refer to CFileDialog.
You can learn about how the MFC document, view, and application classes relate by reading TN025: Document, View, and Frame Creation.
|
|
|
|
|
Check out CDocTemplate::GetDocString() , and the IDR_MAINFRAME resource in the string table.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Does anyone know how to programmatically obtain the number of bytes received and transmitted on a network (dial-up or lan) connection ?
I appreciate any help - thanks DW
|
|
|
|
|
|
Is there a simple function call that will do the following.
Say i have 3 edit boxes side by side for the purpose of a ticket number.
and i have my user enter one number at a time for instance 1 2 3.
How can i make it jump (tab) to the next box on input? Like if he/she enteres 5 it will jump to the next box waitin input then you enter 6 it goes to the last box. I know it can be done cause i see it on webpages alot. Just not sure how to do it. thanks
Win32newb
"Making windows programs worse than they already are"
|
|
|
|
|
|
thanks for the reply. I didn't use his class but I seen what he was doing. The simple SetFocus function. I have three controls m_ticket1 m_ticket2 and m_ticket3;
I just put inside the onchangeticket1() m_ticket2.SetFocus() and so on it works like a charm.
Thanks again for your help,
Win32newb
"Making windows programs worse than they already are"
|
|
|
|
|
I created a SDI aplication with two views, one based on CTreeView and second
on CListView.
Wich message is sending to CListView class when I change a width of column in list control (I set a LVS_REPORT style)?
I'm sorry about my English.
Wojtek
|
|
|
|
|
WM_NOTIFY, if not mistaken.
|
|
|
|
|
It is WM_NOTIFY, but you need the right sub-message:
afx_msg void OnEndtrackConcentrations(NMHDR* pNMHDR, LRESULT* pResult);
ON_NOTIFY(HDN_ENDTRACK, IDC_CONTROL, OnEndtrackControl)
void CYourClass::OnEndtrackControl(NMHDR* pNMHDR, LRESULT* pResult)
{
You may also need to add this line to your OnInitDialog() to get the message mapped correctly, as by default the header control would report a control ID of 0:
m_Control.GetHeaderCtrl()->SetDlgCtrlID(m_Control.GetDlgCtrlID());
Roger Allen - Sonork 100.10016
Roger Wright: Remember to buckle up, please, and encourage your friends to do the same. It's not just about saving your life, but saving the quality of life for those you may leave behind...
|
|
|
|
|
Thanks for your help.
It works, but I have one more little problem. This is list control from CListView class and I don't know its ID's. I checked this list's ID
by function GetDlgCtrlID() and I created resource symbol of its ID's value and I seted list's and header's IDs by function SetDlgCtrlID() in function OnInitialUpdate(). It works and I hope that it's a good way.
|
|
|
|
|
i wonder, at the moment, alot of text editors are created the same way. toolbars and menus on the top, on the left, treeview, on the right, tags and textarea for multidocuments (resizable) and status bar on the bottom.
how are those editors created? as a dialog based or doc/view multi documents?
thanks for all answers
|
|
|
|
|
.eh.. doc/view multi documents sounds good to me.
jhaga
---------------------------------
Every generation laughs at the old fashions, but follows religiously the new.
Henry David Thoreau, "Walden", 1854
|
|
|
|
|
|
thank you for your answer but i don't get it to work:
To build and run the MULTIPAD sample
1. Open the solution multipad.sln.
2. On the Build menu, click Build.
3. On the Debug menu, click Start Without Debugging.
1. i opened multipad.sln in the vc++,
2. i cannot use the build button. it's disabled!
|
|
|
|
|
Sorry, I am not sure what is wrong with your compiler. What version of VC++ are you using??
John
|
|
|
|
|
|
That is why... You must load the dsw file if it has one. You should have the same example on your help with a proper .dsw file. I know I do...
John
|
|
|
|
|
you mean, the msdn cd?
if so.. then, i'm on it and thanks
|
|
|
|
|
Hi,
Here's what I'm trying to do in my MFC application. Like MS WORD do when you save a document for the first time, you click Save and Word takes the first line of your text and wants to save your document to "My first line of text.doc". Me, I want to create my default file name with the current date, example: today is March 15, then when I click Save (or save as) I would like to see "March15.las".
The default save name is found in the string table under the IDR_MAINFRAME (ID 128).
My IDR_MAINFRAME STRING : LaserPlusBeta1\ndefaultsavename\nLaserPlusBeta1\nLaserPlusBeta1 Files (*.las)\n.las\nLaserPlusBeta1.Document\nLaserPlusBeta1.Document
Is it possible to modify the caption of IDR_MAINFRAME at runtime?
If not, how can I generate my own string every time I save and associate an ID to it? Because the CSingleDocTemplate takes a UINT as first parameter for the IDR_MAINFRAME string.
CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CLaserPlusBeta1Doc),
RUNTIME_CLASS(CMainFrame), // main SDI frame window
RUNTIME_CLASS(CLaserPlusBeta1View));
Thank you
Dave
|
|
|
|
|
Call CDocument's SetPathName() or SetTitle prior to showing the FileSave Dlg.
onwards and upwards...
|
|
|
|
|
If you take alook at the default MFC implementation of CDocument::DoSave():
BOOL CDocument::DoSave(LPCTSTR lpszPathName, BOOL bReplace)
{
CString newName = lpszPathName;
if (newName.IsEmpty())
{
CDocTemplate* pTemplate = GetDocTemplate();
ASSERT(pTemplate != NULL);
newName = m_strPathName;
if (bReplace && newName.IsEmpty())
{
newName = m_strTitle;
int iBad = newName.FindOneOf(_T(" #%;/\\"));
if (iBad != -1)
newName.ReleaseBuffer(iBad);
CString strExt;
if (pTemplate->GetDocString(strExt, CDocTemplate::filterExt) &&
!strExt.IsEmpty())
{
ASSERT(strExt[0] == '.');
newName += strExt;
}
}
if (!AfxGetApp()->DoPromptFileName(newName,
bReplace ? AFX_IDS_SAVEFILE : AFX_IDS_SAVEFILECOPY,
OFN_HIDEREADONLY | OFN_PATHMUSTEXIST, FALSE, pTemplate))
return FALSE;
}
CWaitCursor wait;
if (!OnSaveDocument(newName))
{
if (lpszPathName == NULL)
{
TRY
{
CFile::Remove(newName);
}
CATCH_ALL(e)
{
TRACE0("Warning: failed to delete file after failed SaveAs.\n");
DELETE_EXCEPTION(e);
}
END_CATCH_ALL
}
return FALSE;
}
if (bReplace)
SetPathName(newName);
return TRUE;
}
If you were to override this function in your MFC document copy/paste the above and replace the bold section with your own code to determine the default filename, it should do what you need.
Roger Allen - Sonork 100.10016
Roger Wright: Remember to buckle up, please, and encourage your friends to do the same. It's not just about saving your life, but saving the quality of life for those you may leave behind...
|
|
|
|
|
Thanks for your answer,
But I did what basementman suggested: I'm using SetTitle() and it's working fine.
Here's where I put the function, in my CLaserPlusBeta1Doc.cpp:
BOOL CLaserPlusBeta1Doc::OnNewDocument()
{
if (!CDocument::OnNewDocument())
return FALSE;
// TODO: add reinitialization code here
// (SDI documents will reuse this document)
CDocument::SetTitle("MyTitle");
return TRUE;
}
I don't need to specify a path name, so it's easier this way.
Dave
|
|
|
|
|
I need the code for opening a file in Microsoft Access from Visual C++. I want to create a button that when you click the button, the program will take you to a file in Microsoft Access.
|
|
|
|
|
You could put it into "Tools", just type in the full command line for Access.
My neighbours think I am crazy - but they don't know that I have a trampoline. All they see my head bobbing up and down over the fence every five seconds
|
|
|
|