Exemple #1
0
MsgResult ToolnameDlg::Message(Msg* Message)
{
	if (IS_OUR_DIALOG_MSG(Message))
	{

		DialogMsg* Msg = (DialogMsg*)Message; 
		BOOL EndDialog = FALSE; 
		switch (Msg->DlgMsg)
		{
			case DIM_CREATE:
			    SetKeyboardFocus (_R(IDC_EDITNEWBARNAME)) ;
				HighlightText    (_R(IDC_EDITNEWBARNAME)) ;
				break ;

			case DIM_COMMIT:
 			{
 				// Accept all changes that the user wants to make to toolbars...
 				BOOL VV;
 				String_32 NewBarName = GetStringGadgetValue(_R(IDC_EDITNEWBARNAME),&VV);
				if(NewBarName.Length()==0)
				{
				  	UINT32 Number = DialogBarOp::FindUniqueBarNumber();	
					NewBarName._MakeMsg(TEXT("Bar #1%ld"),Number); 
				}
				DialogBarOp* pNewBar = new DialogBarOp(NewBarName);
 				if (pNewBar)
 				{
 					pNewBar->SetDockBarType(DOCKBAR_FLOAT);
 					pNewBar->Create();
					// The Create function sends a message which we intercept to update
					// the list of bars in the Toolbars... dialog.
					// this is very dangerous in fact it blows up..
					// so I have removed it .. chris.
					/*	if (pNewBar)
					{
						// Find toolbar dialog and close it...
 						ToolbarDlg* pToolbarDlg = ToolbarDlg::GetToolbarDlg();
						if (pToolbarDlg)
						{
							pToolbarDlg->Close();
							pToolbarDlg->End();
						}
					}
					*/
					ToolbarDlg* pToolbarDlg = ToolbarDlg::GetToolbarDlg();
					pToolbarDlg->ShowToolbarList();
 				}
 				EndDialog = TRUE;
			
 			}
 			break;

 			case DIM_CANCEL:
 				// Cancel all changes the user wants to make to toolbars...
 				EndDialog = TRUE;
	 			break;

//			default:
		}

		if (EndDialog)	// Dialog communication over 
		{
			Close();	// Close the dialog 
			End();		// Destroy dialog 
	   	}

//		return (DLG_EAT_IF_HUNGRY(Msg)); 
	}

//	return OK; 

	// Pass everything on to the base-class . . .
	return DialogOp::Message(Message);
}