Ejemplo n.º 1
0
bool wxExFile::FileSave(const wxExFileName& filename)
{
  bool save_as = false;

  if (filename.IsOk())
  {
    Assign(filename);
    MakeAbsolute();
    save_as = true;
  }

  if (!save_as && !m_IsLoaded)
  {
    wxLogStatus("File has not been loaded");
    return false;
  }

  if (m_OpenFile && !Open(m_FileName.GetFullPath(), wxFile::write))
  {
    return false;
  }

  DoFileSave(save_as);

  Close();

  ResetContentsChanged();
  
  m_FileName.m_Stat.Sync();
  m_Stat.Sync();

  return true;
}
Ejemplo n.º 2
0
//----------------------------------------------------------------------------
BOOL CMorphwizardDoc::SaveModified()
{
	CSLFDocument* doc, *doc1;
	CString s;
	if( HasModifiedSlf() ) 
	{
		POSITION pos = m_slfDocs.GetStartPosition();
		while( !!pos ) 
		{
			m_slfDocs.GetNextAssoc(pos,doc,doc1);
			if( doc->IsModified() )
				s += doc->GetLemma() + ",\n";
		}
	}

	bool hasModifedSlf = !s.IsEmpty();
	int rn=IDCANCEL;

	if( hasModifedSlf || IsModified() ) 
	{
		CString msg; 
		if( hasModifedSlf )
		{
			s.Delete(s.GetLength()-2,2);
			msg = GetTitle() + "\n\nSave all ";
			if( GetWizard()->is_changed() ) 
				msg += "changes\nincluding ";

			msg += "revised paradigms:\n\n" + s + "?";
		}
		else	// if( IsModified() )
		{
			msg = GetTitle() + "\n\nSave all changes?";
		}

		rn = ::AfxMessageBox(msg, MB_YESNOCANCEL);

		if( rn==IDCANCEL ) 
			return FALSE;
	}

	if( hasModifedSlf && rn==IDYES ) 
	{
		POSITION pos = m_slfDocs.GetStartPosition();
		while( !!pos ) 
		{
			m_slfDocs.GetNextAssoc(pos,doc,doc1);
			doc->DoFileSave();
		}
	}

	if( rn==IDYES ) 
		DoFileSave();

	return TRUE;
}
Ejemplo n.º 3
0
BOOL CCoolFormat3Doc::SaveModified()
{
	if (!IsModified())
		return TRUE;        // ok to continue

	// get name/title of document
	CString name;
	if (m_strPathName.IsEmpty())
	{
		// get name based on caption
		name = GetTitle();
		if (name.IsEmpty())
			ENSURE(name.LoadString(AFX_IDS_UNTITLED));
		if (m_bTitleMark)
		{
			name = name.Left(name.GetLength() - 2);
		}
	}
	else
	{
		// get name based on file title of path name
		name = m_strPathName;
		GetFileTitle(m_strPathName, name.GetBuffer(_MAX_PATH), _MAX_PATH);
		name.ReleaseBuffer();
	}	

	CString prompt;
	BOOL bNameVaild = prompt.LoadString(IDS_IS_WANTSAVE);
	ASSERT(bNameVaild);
	CString strMsg;
	strMsg.Format(prompt, name);	
	
	switch (CFMessageBox(strMsg, MB_YESNOCANCEL| MB_ICONINFORMATION))
	{
	case IDCANCEL:
		return FALSE;       // don't continue

	case IDYES:
		// If so, either Save or Update, as appropriate
		if (!DoFileSave())
			return FALSE;       // don't continue
		break;

	case IDNO:
		// If not saving changes, revert the document
		break;

	default:
		ASSERT(FALSE);
		break;
	}
	return TRUE;    // keep going
}
Ejemplo n.º 4
0
/******************************************************************************************
BOOL CIntChessDoc::SaveModified()
作者      : tangjs520       创建日期: 2004-9-29
函数名    : CIntChessDoc::SaveModified
返回值    : BOOL
参数列表  : 无
描述      : 
调用关系  : 
被调用关系: 
备注      : 
修改记录  : 
******************************************************************************************/
BOOL CIntChessDoc::SaveModified()
{
    // TODO: Add your specialized code here and/or call the base class
    if (!IsModified())
    {
        return TRUE;        // ok to continue
    }

    // get name/title of document
    CString name;
    if (m_strPathName.IsEmpty())
    {
        // get name based on caption
        name = m_strTitle;
        if (name.IsEmpty())
        {
            VERIFY(name.LoadString(AFX_IDS_UNTITLED));
        }
    }
    else
    {
        // get name based on file title of path name
        name = m_strPathName;
    }

    CString prompt;
    AfxFormatString1(prompt, AFX_IDP_ASK_TO_SAVE, name);
    switch (AfxMessageBox(prompt, MB_YESNOCANCEL, AFX_IDP_ASK_TO_SAVE))
    {
    case IDCANCEL:
        return FALSE;       // don't continue

    case IDYES:
        // If so, either Save or Update, as appropriate
        if (!DoFileSave())
        {
            return FALSE;       // don't continue
        }
        break;

    case IDNO:
        // If not saving changes, revert the document
        break;

    default:
        ASSERT(FALSE);
        break;
    }

    return TRUE;    // keep going
}
Ejemplo n.º 5
0
BOOL CPathDoc::SaveModified() 
{
	if(	m_CustomFileOpen )
	{
		return CDocument::SaveModified();	// Invoke the file save dialog
	}
	else
	{
		if (!DoFileSave())
		{
			ROBOT_LOG( TRUE, "ERROR saving file %s!\n", DEFAULT_PATH_FILE);
		}
	}
	return 1;	// continue shutting down
}
Ejemplo n.º 6
0
BOOL CDocument::SaveModified()
/****************************/
{
    if( !IsModified() ) {
        return( TRUE );
    }

    CString strMessage;
    strMessage.Format( AFX_IDP_ASK_TO_SAVE, (LPCTSTR)GetTitle() );
    int nRet = AfxMessageBox( strMessage, MB_YESNOCANCEL );
    if( nRet == IDYES ) {
        return( DoFileSave() );
    } else if( nRet == IDNO ) {
        return( TRUE );
    } else {
        return( FALSE );
    }
}
Ejemplo n.º 7
0
LRESULT MainFrame::OnScriptRun(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
   if (m_view.GetModify())
   {
      if (!DoFileSave())
         return 0;
   }

   CString cszFilename = m_view.GetFilePath();
   if (cszFilename.IsEmpty())
      return 0;

   {
      CString cszText;
      cszText.Format(_T("Start executing file %s...\n\n"),
         cszFilename.GetString());

      m_ecOutputWindow.OutputText(cszText);
   }

   m_processor.Stop();

   try
   {
      m_processor.LoadScript(cszFilename);

      m_processor.Run();
   }
   catch (const Lua::Exception& ex)
   {
      CString cszText;
      cszText.Format(_T("%s(%u): %s"),
         ex.LuaSourceFile().GetString(),
         ex.LuaLineNumber(),
         ex.LuaErrorMessage().GetString());

      OnOutputDebugString(cszText);

      UIEnable(ID_SCRIPT_RUN, true);
      UIEnable(ID_SCRIPT_STOP, false);
   }

   return 0;
}
//----------------------------------------------------------------------------
BOOL CDigitalTraineeStudioDoc::SaveModified(){
//----------------------------------------------------------------------------
	PROC_TRACE;

	if (!IsModified())
		return TRUE;        // ok to continue

	// get name/title of document
	CString name;
	if (m_strPathName.IsEmpty())	{
		// get name based on caption
		name = m_strTitle;
		if (name.IsEmpty())
			name = TRANSLATE("Unbekannt");
	}
	else	{
		// get name based on file title of path name
		name = m_strPathName;
	}


	char  prompt[2000];
	sprintf(prompt, TRANSLATE("COMMON.MESSAGE.WANTSAVEFILE"), name);
	switch (AfxMessageBox(prompt, MB_YESNOCANCEL, AFX_IDP_ASK_TO_SAVE))
	{
	case IDCANCEL:
		return FALSE;       // don't continue

	case IDYES:
		// If so, either Save or Update, as appropriate
		if (!DoFileSave())
			return FALSE;       // don't continue
		break;

	case IDNO:
		// If not saving changes, revert the document
		break;

	default:
		ASSERT(FALSE);
		break;
	}
	return TRUE;    // keep going
}
Ejemplo n.º 9
0
void CDocument::OnFileSave()
{
	DoFileSave();
}
Ejemplo n.º 10
0
LRESULT MainFrame::OnFileSave(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
   DoFileSave();

   return 0;
}
Ejemplo n.º 11
0
void CDocument::OnFileSave()
/**************************/
{
    DoFileSave();
}
Ejemplo n.º 12
0
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch (msg)
	{
		case WM_CREATE:
			{
				//Create Toolbar
				HWND hTool;
				TBBUTTON tbb[3];
				TBADDBITMAP tbab;

				hTool = CreateWindowEx(0, TOOLBARCLASSNAME, NULL, WS_CHILD | WS_VISIBLE, 0, 0, 100, 100,
						hwnd, (HMENU)IDC_MAIN_TOOL, GetModuleHandle(NULL), NULL);
				if (hTool == NULL)
					MessageBox(hwnd, "Could not create tool bar.", "Error", MB_OK | MB_ICONERROR);

				//Send the TB_BUTTONSTRUCTSIZE message, which is required for backward compatibility.
				SendMessage(hTool, TB_BUTTONSTRUCTSIZE, (WPARAM)sizeof(TBBUTTON), 0);

				tbab.hInst = HINST_COMMCTRL;
				tbab.nID = IDB_STD_SMALL_COLOR;
				SendMessage(hTool, TB_ADDBITMAP, 0, (LPARAM)&tbab);

				ZeroMemory(tbb, sizeof(tbb));
				tbb[0].iBitmap = STD_FILENEW;
				tbb[0].fsState = TBSTATE_ENABLED;
				tbb[0].fsStyle = TBSTYLE_BUTTON;
				tbb[0].idCommand = ID_FILE_NEW;

				tbb[1].iBitmap = STD_FILEOPEN;
				tbb[1].fsState = TBSTATE_ENABLED;
				tbb[1].fsStyle = TBSTYLE_BUTTON;
				tbb[1].idCommand = ID_FILE_OPEN;

				tbb[2].iBitmap = STD_FILESAVE;
				tbb[2].fsState = TBSTATE_ENABLED;
				tbb[2].fsStyle = TBSTYLE_BUTTON;
				tbb[2].idCommand = ID_FILE_SAVEAS;

				SendMessage(hTool, TB_ADDBUTTONS, sizeof(tbb)/sizeof(TBBUTTON), (LPARAM)&tbb);

				//Create Status bar
				HWND hStatus;
				int statwidths[] = {100, -1};

				hStatus = CreateWindowEx(0, STATUSCLASSNAME, NULL,
						WS_CHILD | WS_VISIBLE | SBARS_SIZEGRIP, 0, 0, 0, 0,
						hwnd, (HMENU)IDC_MAIN_STATUS, GetModuleHandle(NULL), NULL);

				SendMessage(hStatus, SB_SETPARTS, sizeof(statwidths)/sizeof(int), (LPARAM)statwidths);
				SendMessage(hStatus, SB_SETTEXT, 0, (LPARAM)"Hi there :)");

				//Create Client Window
				CLIENTCREATESTRUCT ccs;

				ccs.hWindowMenu = GetSubMenu(GetMenu(hwnd), 2);
				ccs.idFirstChild = ID_MDI_FIRSTCHILD;

				g_hMDIClient = CreateWindowEx(WS_EX_CLIENTEDGE, "mdiclient", NULL, 
						WS_CHILD | WS_CLIPCHILDREN | WS_VSCROLL | WS_HSCROLL | WS_VISIBLE,
						CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
						hwnd, (HMENU)IDC_MAIN_MDI, GetModuleHandle(NULL), (LPVOID)&ccs);

				break;
			}
		case WM_SIZE:
			{
				//Size toolbar and get height
				HWND hTool;
				RECT rcTool;
				int iToolHeight;

				hTool = GetDlgItem(hwnd, IDC_MAIN_TOOL);
				SendMessage(hTool, TB_AUTOSIZE, 0, 0);

				GetWindowRect(hTool, &rcTool);
				iToolHeight = rcTool.bottom - rcTool.top;

				//Size status bar and get height
				HWND hStatus;
				RECT rcStatus;
				int iStatusHeight;

				hStatus = GetDlgItem(hwnd, IDC_MAIN_STATUS);
				SendMessage(hStatus, WM_SIZE, 0, 0);

				GetWindowRect(hStatus, &rcStatus);
				iStatusHeight = rcStatus.bottom - rcStatus.top;

				//Calculata remaining height and size client window
				HWND hMDI;
				int iMDIHeight;
				RECT rcClient;

				GetClientRect(hwnd, &rcClient);
				iMDIHeight = rcClient.bottom - iToolHeight - iStatusHeight;
				hMDI = GetDlgItem(hwnd, IDC_MAIN_MDI);
				SetWindowPos(hMDI, NULL, 0, iToolHeight, rcClient.right, iMDIHeight, SWP_NOZORDER);

				break;
			}
		case WM_MDIACTIVATE:
			{
				HMENU hMenu, hFileMenu;
				UINT EnableFlag;

				hMenu = GetMenu(g_hMainWindow);
				if (hwnd == (HWND)lParam)
					EnableFlag = MF_ENABLED;
				else
					EnableFlag = MF_GRAYED;

				EnableMenuItem(hMenu, 1, MF_BYPOSITION | EnableFlag);
				EnableMenuItem(hMenu, 2, MF_BYPOSITION | EnableFlag);

				hFileMenu = GetSubMenu(hMenu, 0);
				EnableMenuItem(hFileMenu, ID_FILE_SAVEAS, MF_BYCOMMAND | EnableFlag);
				EnableMenuItem(hFileMenu, ID_FILE_CLOSE, MF_BYCOMMAND | EnableFlag);
				EnableMenuItem(hFileMenu, ID_FILE_CLOSEALL, MF_BYCOMMAND | EnableFlag);

				DrawMenuBar(g_hMainWindow);

				break;
			}
		case WM_COMMAND:
			switch (LOWORD(wParam))
			{
				case ID_FILE_EXIT:
					PostMessage(hwnd, WM_CLOSE, 0, 0);
					break;
				case ID_FILE_NEW:
					CreateNewMDIChild(g_hMDIClient);
					break;
				case ID_FILE_OPEN:
					{
						HWND hChild = CreateNewMDIChild(g_hMDIClient);
						if (hChild)
							DoFileOpen(hChild);
						break;
					}
				case ID_FILE_CLOSE:
					{
						HWND hChild = (HWND)SendMessage(g_hMDIClient, WM_MDIGETACTIVE, 0, 0);
						if (hChild)
							SendMessage(hChild, WM_CLOSE, 0, 0);
						break;
					}
				case ID_FILE_SAVEAS:
					{
						HWND hChild = (HWND)SendMessage(g_hMDIClient, WM_MDIGETACTIVE, 0, 0);
						if (hChild)
							DoFileSave(hChild);
						break;
					}
				case ID_WINDOW_TILE:
					SendMessage(g_hMDIClient, WM_MDITILE, 0, 0);
					break;
				case ID_WINDOW_CASCADE:
					SendMessage(g_hMDIClient, WM_MDICASCADE, 0, 0);
					break;

				default:
					{
						if (LOWORD(wParam) >= ID_MDI_FIRSTCHILD)
							DefFrameProc(hwnd, g_hMDIClient, msg, wParam, lParam);
						else
						{
							HWND hChild = (HWND)SendMessage(g_hMDIClient, WM_MDIGETACTIVE, 0, 0);
							if (hChild)
								SendMessage(hChild, WM_COMMAND, wParam, lParam);
						}
					}
			}
			break;
		case WM_CLOSE:
			DestroyWindow(hwnd);
			break;
		case WM_DESTROY:
			PostQuitMessage(0);
			break;
		default:
			return DefFrameProc(hwnd, g_hMDIClient, msg, wParam, lParam);
	}
	return 0;
}
Ejemplo n.º 13
0
/////////////////////////////////////////////////////////////////////////////
// switch to the new selected view tab
/////////////////////////////////////////////////////////////////////////////
BOOL CBonfireDoc::SwitchToView(CString strTab)
{
	if (strTab == "")
		return FALSE;

	CChildFrame*	pChild		= (CChildFrame*)g_pMainFrame->MDIGetActive();
	if (!pChild || pChild->GetActiveDocument() != this)
	{
		POSITION pos = GetFirstViewPosition();
		pChild	= (CChildFrame*)GetNextView(pos)->GetParentFrame();
	}

	if (!pChild)
		return FALSE;

	CView*			pViewAdd	= NULL;
	CBonfireView*	pGlobalView	= NULL;
	CBonfireView*	pBNewView	= NULL;
	
	// get the view to "hide"
	CView*			pViewDel	= pChild->GetActiveView();
	
	// if we're already displaying this kind of view, no need to go further.
	for (int i = 0; i < theApp.m_arAllViews.GetSize(); i++)
	{
		if ( ((CBonfireView*)theApp.m_arAllViews[i])->m_strCaption.Compare(strTab) == 0 )
		{
			pGlobalView = (CBonfireView*)theApp.m_arAllViews[i];
			break;
		}
	}

	if ( pViewDel && pViewDel->IsKindOf(pGlobalView->m_pClass) )
		return TRUE;

	// check if a view of this type already exists
 	if ( !m_pViews->Lookup(pGlobalView->m_strCaption, (void*&)pBNewView) )
	{
		// doesn't exist so create a new view
		pViewAdd = (CView*)pGlobalView->m_pClass->CreateObject();
		if (pViewAdd == NULL)
		{
			TRACE1("Warning: Dynamic create of view type %Fs failed\n", pGlobalView->m_pClass->m_lpszClassName);
			return FALSE;
		}

		// draw new view
		CCreateContext context;
		context.m_pNewViewClass		= pGlobalView->m_pClass;
		context.m_pCurrentDoc		= NULL;
		context.m_pNewDocTemplate	= this->GetDocTemplate();
		context.m_pLastView			= NULL;
		context.m_pCurrentFrame		= pChild;

		// draw new view
		if (!pViewAdd->Create(NULL, NULL, AFX_WS_DEFAULT_VIEW, CRect(0, 0, 0, 0),
			pChild, AFX_IDW_PANE_FIRST, &context))
		{
			TRACE0("Warning: couldn't create view for frame\n");
			delete pViewAdd;
			return FALSE;
		}

		// add the view to the map
		pBNewView			= new CBonfireView(pGlobalView);
		pBNewView->m_pView	= pViewAdd;
		pBNewView->m_pClass	= pViewAdd->GetRuntimeClass();

		// add this view to the document's map
		AddViewToMap(pBNewView);

		// WM_INITIALUPDATE is defined in afxpriv.h
		pViewAdd->SendMessage(WM_INITIALUPDATE,0,0);

		// connect the view to the document
		AddView(pViewAdd);
	}
	else
	{
		pViewAdd = pBNewView->m_pView;
	}

	// save file on switching views
	if (theApp.m_opOptions.general.dwSaveOnSwitch && !m_xTextBuffer.GetReadOnly() && pViewDel)
		DoFileSave();
	
	CSplitterWnd*	pSplitter	= NULL;
	POSITION pos				= GetFirstViewPosition();
	BOOL firstOne				= true;
	while (pos)
	{
		CView* pv	= GetNextView(pos);
		if (pv == pViewAdd)	
		{
			pv->SetDlgCtrlID(AFX_IDW_PANE_FIRST);

			// show the view
			if (pBNewView->m_bAllowsSplitter)
			{
				pSplitter	= (CSplitterWnd*)pViewAdd->GetParent();
				
				// show the splitter (show the children view(s) as well)
				pSplitter->ShowWindow(SW_SHOW);
			}
			else
				// show the view
				pViewAdd->ShowWindow(SW_SHOW);
		}
		else 
		{
			// check if the view is inside a splitter
			if (pv->GetParent()->GetRuntimeClass() == (CRuntimeClass*)RUNTIME_CLASS(CSplitterWnd))
			{
				pSplitter	= (CSplitterWnd*)pv->GetParent();
				
				// hide the splitter (hide all views with the splitter)
				pSplitter->ShowWindow(SW_HIDE);
			}
			else
			{
				// hide the view
				pv->ShowWindow(SW_HIDE);
				pv->SetDlgCtrlID(AFX_IDW_PANE_FIRST + 255);
			}
		}

		TRACE("%s (%d) ", pv->GetRuntimeClass()->m_lpszClassName, (unsigned)(pv->GetDlgCtrlID() - AFX_IDW_PANE_FIRST));
		if (pv == pViewDel)		TRACE("= D ");
		if (pv == pViewAdd)		TRACE("= A ");
		if (pv->GetRuntimeClass() == pGlobalView->m_pClass)
		{
			if (firstOne)
				firstOne = false;
			else
				TRACE("removing ");
		}
	}
	TRACE("\n");

	// get rid of extra views created by the splitter
	if (pSplitter)
	{
		for (int cols = 1; cols < pSplitter->GetColumnCount(); cols++)
			pSplitter->DeleteColumn(cols);
		for (int rows = 1; rows < pSplitter->GetRowCount(); rows++)
			pSplitter->DeleteRow(rows);

		pSplitter->RecalcLayout();
	}

	pViewAdd->UpdateWindow();
	pChild->SetActiveView(pViewAdd);
	pChild->RecalcLayout();

	if (pBNewView->m_bModifiedSinceRefresh)
	{
		pBNewView->m_bModifiedSinceRefresh = FALSE;
		if (pGlobalView->m_pClass == RUNTIME_CLASS(CXMLTreeView))
		{
			((CXMLTreeView*)pViewAdd)->RefreshView();
		}
		else if (pGlobalView->m_pClass == RUNTIME_CLASS(CBrowserView))
		{
			((CBrowserView*)pViewAdd)->RefreshView();
		}
		else
		{
			pBNewView->m_bModifiedSinceRefresh = TRUE;
		}
	}

	return TRUE;
}
Ejemplo n.º 14
0
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch(msg)
	{
		case WM_CREATE:
		{
			HFONT hfDefault;
			HWND hEdit;

			HWND hTool;
			TBBUTTON tbb[3];
			TBADDBITMAP tbab;

			HWND hStatus;
			int statwidths[] = {100, -1};

			// Create Edit Control

			hEdit = CreateWindowEx(WS_EX_CLIENTEDGE, "EDIT", "", 
				WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL | ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL, 
				0, 0, 100, 100, hwnd, (HMENU)IDC_MAIN_EDIT, GetModuleHandle(NULL), NULL);
			if(hEdit == NULL)
				MessageBox(hwnd, "Could not create edit box.", "Error", MB_OK | MB_ICONERROR);

			hfDefault = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
			SendMessage(hEdit, WM_SETFONT, (WPARAM)hfDefault, MAKELPARAM(FALSE, 0));

			// Create Toolbar

			hTool = CreateWindowEx(0, TOOLBARCLASSNAME, NULL, WS_CHILD | WS_VISIBLE, 0, 0, 0, 0,
				hwnd, (HMENU)IDC_MAIN_TOOL, GetModuleHandle(NULL), NULL);
			if(hTool == NULL)
				MessageBox(hwnd, "Could not create tool bar.", "Error", MB_OK | MB_ICONERROR);

			// Send the TB_BUTTONSTRUCTSIZE message, which is required for
			// backward compatibility.
			SendMessage(hTool, TB_BUTTONSTRUCTSIZE, (WPARAM)sizeof(TBBUTTON), 0);
			
			tbab.hInst = HINST_COMMCTRL;
			tbab.nID = IDB_STD_SMALL_COLOR;
			SendMessage(hTool, TB_ADDBITMAP, 0, (LPARAM)&tbab);

			ZeroMemory(tbb, sizeof(tbb));
			tbb[0].iBitmap = STD_FILENEW;
			tbb[0].fsState = TBSTATE_ENABLED;
			tbb[0].fsStyle = TBSTYLE_BUTTON;
			tbb[0].idCommand = ID_FILE_NEW;

			tbb[1].iBitmap = STD_FILEOPEN;
			tbb[1].fsState = TBSTATE_ENABLED;
			tbb[1].fsStyle = TBSTYLE_BUTTON;
			tbb[1].idCommand = ID_FILE_OPEN;

			tbb[2].iBitmap = STD_FILESAVE;
			tbb[2].fsState = TBSTATE_ENABLED;
			tbb[2].fsStyle = TBSTYLE_BUTTON;
			tbb[2].idCommand = ID_FILE_SAVEAS;

			SendMessage(hTool, TB_ADDBUTTONS, sizeof(tbb)/sizeof(TBBUTTON), (LPARAM)&tbb);

			// Create Status bar

			hStatus = CreateWindowEx(0, STATUSCLASSNAME, NULL,
				WS_CHILD | WS_VISIBLE | SBARS_SIZEGRIP, 0, 0, 0, 0,
				hwnd, (HMENU)IDC_MAIN_STATUS, GetModuleHandle(NULL), NULL);

			SendMessage(hStatus, SB_SETPARTS, sizeof(statwidths)/sizeof(int), (LPARAM)statwidths);
			SendMessage(hStatus, SB_SETTEXT, 0, (LPARAM)"Hi there :)");
		}
		break;
		case WM_SIZE:
		{
			HWND hTool;
			RECT rcTool;
			int iToolHeight;

			HWND hStatus;
			RECT rcStatus;
			int iStatusHeight;

			HWND hEdit;
			int iEditHeight;
			RECT rcClient;

			// Size toolbar and get height

			hTool = GetDlgItem(hwnd, IDC_MAIN_TOOL);
			SendMessage(hTool, TB_AUTOSIZE, 0, 0);

			GetWindowRect(hTool, &rcTool);
			iToolHeight = rcTool.bottom - rcTool.top;

			// Size status bar and get height

			hStatus = GetDlgItem(hwnd, IDC_MAIN_STATUS);
			SendMessage(hStatus, WM_SIZE, 0, 0);

			GetWindowRect(hStatus, &rcStatus);
			iStatusHeight = rcStatus.bottom - rcStatus.top;

			// Calculate remaining height and size edit

			GetClientRect(hwnd, &rcClient);

			iEditHeight = rcClient.bottom - iToolHeight - iStatusHeight;

			hEdit = GetDlgItem(hwnd, IDC_MAIN_EDIT);
			SetWindowPos(hEdit, NULL, 0, iToolHeight, rcClient.right, iEditHeight, SWP_NOZORDER);
		}
		break;
		case WM_CLOSE:
			DestroyWindow(hwnd);
		break;
		case WM_DESTROY:
			PostQuitMessage(0);
		break;
		case WM_COMMAND:
			switch(LOWORD(wParam))
			{
				case ID_FILE_EXIT:
					PostMessage(hwnd, WM_CLOSE, 0, 0);
				break;
				case ID_FILE_NEW:
					SetDlgItemText(hwnd, IDC_MAIN_EDIT, "");
				break;
				case ID_FILE_OPEN:
					DoFileOpen(hwnd);
				break;
				case ID_FILE_SAVEAS:
					DoFileSave(hwnd);
				break;
			}
		break;
		default:
			return DefWindowProc(hwnd, msg, wParam, lParam);
	}
	return 0;
}
Ejemplo n.º 15
0
bool CScriptEditView::OnFileSave()
{
	return (m_szFilePath[0] == 0) ? OnFileSaveAs() : DoFileSave();
}