LWUIT javame Dialog dispose - java-me

I cannot seem to make the dialog in my javame program disapear. I have used dispose but nothing. Any help. Here is the code
Dialog d=new Dialog("Comment added");
Label lb=new Label(response);
d.setLayout(new BorderLayout());
d.addComponent(BorderLayout.CENTER,lb);
d.show();
d.dispose();

the d.show(); blocks until the dialog disposes, therefore you are not getting to the next line of code.
add a Button to your dialog and on the button event invoke dispose.

Related

C++ Windows form application Switching between forms

So i have my main form and i open a second form using this code
this->Hide();
Form2^ dlg=gcnew Form2();
dlg->ShowDialog();
how do i go back from the second form to the main one?
In the dialog code set the DialogResult property, this will close the dialog and return to the main form, ShowDialog will return the DialogResult value you set.
Alternatively you can have a button on the dialog that has a DialogResult property set and then clicking the button will close the dialog and return the value associated with the button.

To send a custom Message from Parent Dialog Box to child Dialog Box using SendMessage() function

There are several ways to use SendMessage()
WIN32API modal
::SendMessage(h, MY_MSG ,0,0);
MFC modal
Let's ptr having child Dialog box Handle then we can use this modal
ptr->SendMessage(MY_MSG,0,0);
But How can I get child dialog Box handle once I clicked a button in parent Dialog box see this.. I write the code
void CCustomMessageDlg::OnBnClickedOpen(){
MyDialog2 d2(IDD_CHILD_DIALOG);
d2.DoModal();
}
I Need Send Custom Message to child Dialog using SendMessage() API once Button is clicked. Can You Please Suggest A solution for this problem
You cannot send a message to the dialog after DoModal() returns, because the dialog will already be destroyed.
In case you want to pass data to the dialog, you can add a member variable to your child dialog, say:
CString m_strMyData;
Then use:
MyDialog2 d2(IDD_CHILD_DIALOG);
d2.m_strMyData = "Test";
d2.DoModal();
and access m_strMyData from within the child dialog.

Updating toolbar button state MFC

I have a dialog in MFC application, which is having menu-bar. Now I have created a toolbar in that dialog using the same command ID which is in the menu-bar.
I use to update the menu-item's state and makes it enable/disable as per some check in ON_UPDATE_COMMAND_UI, When I clicks on the menu. But for toolbar I didn't gets these calls to update it's state, If it should be enabled/disabled.
Moreover I didn't have any notification when the test fails and I to disable the item.
Is there some alternative for doing this?
Thanks
call to ON_UPDATE_COMMAND_UI is only coming when I click on the toolbar button.
Use MFC in a dialog can be frustrating.
I suggest you disable the toolbar button directly when changing state to the variable that will enable / disable the menu:
void CtestDlg::OnBnClickedButton_DisableSomeControls()
{
command_menu_1 = !command_menu_1;
m_ToolBar.GetToolBarCtrl().EnableButton(ID_COMMAND_TEST, command_menu_1);
}
is not very elegant, but it works!

Change Edit Box content when Button is clicked in mfc

I have an Edit Box and a Button on a dialog. How can I change the content in the edit box runtime as the button is clicked? I have to read a new record from a file and post it in the Edit Box as the Button is clicked and I am using mfc.
Once you have trapped the button press, in most cases the easiest way to change text in an Edit Control is:
SetDlgItemText(IDC_EDIT_ID, "Desired Text String")
Where IDC_EDIT_ID is the ID of the Edit Control (set in the properties window)
You can set the text of an Edit control (wrapped by the CEdit class in MFC) by calling the SetWindowText method, which it inherits from the CWnd base class.
So then all you need to do is respond to a click event on your button control. You do this by listening for the BN_CLICKED notification from the appropriate button control within your parent window's OnCommand method.
Something like:
BOOL CMyDialog::OnCommand(WPARAM wParam, LPARAM lParam)
{
if (HIWORD(wParam) == BN_CLICKED && LOWORD(lParam) == IDC_MYBUTTON)
{
m_Edit.SetWindowText(TEXT("My string"));
}
return CWnd::OnCommand(wParam, lParam);
}
Obtaining and reading a book on MFC would be very helpful. This is fairly basic stuff, but it's a lot to cover in a single answer if you don't already understand the fundamental concepts.
Using the Class Wizard would make this even easier... Invoke it with the Ctrl+W keys and follow the on-screen instructions. You'll end up with something like:
void CMyDialog::OnMyButton()
{
m_Edit.SetWindowText(TEXT("My string"));
}

LWUIT: overriding Dialog

I want to override Dialog so that it disposes itself the very moment it shows.
though it is a strange question, but you can override onShow() or onShowCompleted() and call dispose() inside one of them to close the dialog immediately.

Categories

Resources