CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Dec 2001
    Posts
    60

    about doc/view open ?

    my project have many view form
    when open appplication it will show dialog like picture below , user must
    select which form to opn
    but i don't want this dialog
    i want some default form to open when open application ex. input form view
    how can i do?

    i copy project from msdn example --> VIEWEX
    Attached Images Attached Images

  2. #2
    Join Date
    Feb 2006
    Posts
    3

    Re: about doc/view open ?

    Just Write in MDi or Main form Load Event


    frmdefault.Show();

    'frmdefault' is your default form name.
    Last edited by Guru4Nav; February 20th, 2006 at 11:26 PM.

  3. #3
    Join Date
    Dec 2001
    Posts
    60

    Re: about doc/view open ?

    please give me more detail
    or example code

    thank you !!!

  4. #4
    Join Date
    Feb 2000
    Location
    San Diego, CA
    Posts
    10,354

    Re: about doc/view open ?

    From what you say, it appears to be that you have multiple document templates for your app.
    If so, instead of ProcessShellCommand default handling, you replace it by a call to
    appropriateTemplate->OpenDocumentFile(NULL);

    Also, take a look at
    http://www.codeguru.com/forum/showthread.php?t=376311

  5. #5
    Join Date
    Nov 2002
    Location
    California
    Posts
    4,556

    Re: about doc/view open ?

    Quote Originally Posted by nor1
    my project have many view form
    when open appplication it will show dialog like picture below , user must
    select which form to opn
    but i don't want this dialog...
    The easiest way to remove this dialog is to edit the corresponding "document template string" in the string resources. You want to remove the third sub-string, which corresponds to the <fileNewName> sub-string, for all the document template strings, except for the one template that you want to use for the default view.

    The "dialog template strings" are the string resources starting with IDR_xxxx. The format is described in MSDN at "Description of the format of the document template string" at http://support.microsoft.com/default...b;en-us;129095

    Here's what I mean. In the VIEWEX sample, the CWinApp::InitInstance function registers five different document templates, each having a different IDR_xxx:
    Code:
    BOOL CViewExApp::InitInstance()
    {
    	// Standard initialization
    	Enable3dControls();
    
    	// This VIEWEX sample shows several techniques for creating CView
    	//  derived classes.   All the views in this sample use the same
    	//  CMainDoc class.  For simplicity the CMainDoc class does not
    	//  support serialization, but has a very simple data model of
    	//  a single string and an RGB color.  We register different
    	//  document templates for each of the interesting view types.
    
    	// simple text output view
    	AddDocTemplate(new CMultiDocTemplate(IDR_TEXTTYPE,
    			RUNTIME_CLASS(CMainDoc),
    			RUNTIME_CLASS(CMDIChildWnd),
    			RUNTIME_CLASS(CTextView)));
    
    	// simple color output view
    	//   a doc template with no 'fileNewName' so it is not a choice for FileNew
    	AddDocTemplate(new CMultiDocTemplate(IDR_COLORTYPE,
    			RUNTIME_CLASS(CMainDoc),
    			RUNTIME_CLASS(CMDIChildWnd),
    			RUNTIME_CLASS(CColorView)));
    
    	// form view with input
    	AddDocTemplate(new CMultiDocTemplate(IDR_INPUTTYPE,
    			RUNTIME_CLASS(CMainDoc),
    			RUNTIME_CLASS(CMDIChildWnd),
    			RUNTIME_CLASS(CInputView)));
    
    	// splitter frame with both simple text output and form input view
    	AddDocTemplate(new CMultiDocTemplate(IDR_SPLIT2TYPE,
    			RUNTIME_CLASS(CMainDoc),
    			RUNTIME_CLASS(CSplitterFrame),
    			RUNTIME_CLASS(CTextView)));
    
    	// 3-way splitter frame with form input, text output and color output views
    	AddDocTemplate(new CMultiDocTemplate(IDR_SPLIT3TYPE,
    			RUNTIME_CLASS(CMainDoc),
    			RUNTIME_CLASS(C3WaySplitterFrame),
    			RUNTIME_CLASS(CInputView)));
    
    	// create main MDI Frame window
    	// Please note that for simple MDI Frame windows with no toolbar,
    	//   status bar or other special behavior, the CMDIFrameWnd class
    	//   can be used directly for the main frame window just as the
    	//   CMDIChildWnd can be use for a document frame window.
    
    	CMDIFrameWnd* pMainFrame = new CMDIFrameWnd;
    	if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
    		return FALSE;
    
    	// Also in this example, there is only one menubar shared between
    	//  all the views.  The automatic menu enabling support of MFC
    	//  will disable the menu items that don't apply based on the
    	//  currently active view.  The one MenuBar is used for all
    	//  document types, including when there are no open documents.
    
    	// Now finally show the main menu
    	pMainFrame->ShowWindow(m_nCmdShow);
    	pMainFrame->UpdateWindow();
    	m_pMainWnd = pMainFrame;
    
    	// command line arguments are ignored, create a new (empty) document
    	OnFileNew();
    
    	return TRUE;
    }
    So, there are five different doc template strings: IDR_TEXTTYPE, IDR_COLORTYPE, IDR_INPUTTYPE, IDR_SPLIT2TYPE and IDR_SPLIT3TYPE. Look at the string resources for these, and you'll see something like this:

    IDR_SPLIT3TYPE: "\nTri\nThree-way Splitter Frame"

    ... which shows three substrings as follows:

    first sub-string (which is the <windowTitle> substring): "" (i.e., blank)
    second sub-string (the <docName>): "Tri"
    third sub-string (the <fileNewName>): "Three-way Splitter Frame"

    (In this case, only the first three sub-strings of the nine possible substrings are being used.)

    The third substring is the string that's displayed in the File-New dialog that you want to get rid of. Just delete it, so that the string is

    IDR_SPLIT3TYPE: "\nTri\n"

    Delete the third substring for all except one of the IDR_xxxx's, which is the view that will open automatically for File->New

    Mike

  6. #6
    Join Date
    Dec 2001
    Posts
    60

    Re: about doc/view open ?

    thank you everyone.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured