Thank you.
Member 2119844
Posts
-
how to return value after user input -
how to return value after user inputok i will try. but. as you said. >> Use the events and notifications of the CDialog class. Which Events and Notification? i use this to block call OnOk() while press Enter Key.
BOOL CRetValTestDlg::PreTranslateMessage( MSG* pMsg )
{
if (pMsg->message == WM_KEYDOWN)
{
if ((pMsg->wParam == VK_RETURN) || (pMsg->wParam == VK_ESCAPE))
pMsg->wParam = NULL;// VK_TAB;
}return CDialog::PreTranslateMessage( pMsg );
}
how dialog do my work. it would be great if i could get some sample code. i have spend lot of time to read and search. i did not find or i did not understand. so i request for help. if i understand, i may not request for help.
-
how to return value after user inputDear sir, i really appreciate your and Santhosh suggestion. i do. but the thing is bit difference what i am looking for. maybe i am not able to describe very well, what i am looking for. sorry for that. because my English is not good enough. so please don't get me wrong. once again i am trying to explain what i need to do. and what i come up to. i need to make function that return value after press Enter key. not directly and not in any other way. but from function when it call from outer class. this is the event when user press button in dlg class.
void CRetValTestDlg::OnGetString()
{
m_TxInput.InFlag = false;
CString s = m_TxInput.GetString();
m_TxOutput.SetWindowText (s);
}and this is CMyTextBox calss member function which is call from dlg class on button press. which need to return value.
CString CMyTextBox::GetString()
{
if (InFlag == true)
return RetVal;
return "";
}now i have come upto this
CString CMyTextBox::GetString()
{
while (InFalg != true) // this is infinite loop but
{
DoEvents(); // doEvents hole for it so it wait until it get event
if (InFlag == true) // the InFlag = true when user press Enter;
return RetVal; // and return value
}
return ""; // else return "";
}this is work. but when i use While and DoEvents the processor took lot of work. it took all most 50% of CPU used. and which is really not good. i think. and some time it does not come out from that loop when user left so when the program close. it remain in task manager. and CUP running. now What i am looking for is -> is there any other way to wait till event. maybe using CEvent or CallBack or threading or something else. without using lot of CPU used. because i don't know anything about them. i have never use.
CString CMyTextBox::GetString()
{
//====================== Here i am looking for help =============================
// wait for event here or WaitTill (InFlag !=true); in this line i need help.
//==================================================================================
if (InFlag == true)
return RetVal;
return "";
}i hope this time i could able to tell what i need for. this is really important for me. so Please Please Help.
-
how to return value after user inputwell sir, i am just learning and doing work. i don't have much idea about it. so i request for help. i am trying this from all most a week. i google it and did not found simillar to what i am looking for. maybe because i don't have enough knowledge. so.. hoping to get help from some kind heart.
-
how to return value after user inputThanks. but i don't know about it. is it possible to give one working example. it will be great help for me. please consider i am learning.
-
how to return value after user inputyes this is the part which i did not understand. how it goes to GetString or GetNumber function. because PreTranslateMessage in Dlg class. and GetString and GetNumber function in other class. so how it will connect with each other. and how it trap event from one class to other class function. i would like to request for little more detail and step. how it work? if that is just need to get number or string and put in variable it will be ok. but the value should return from function.
-
how to return value after user inputYes. when it call function. like GetString();
-
how to return value after user inputno no. this is not a way what i need. i need to get value after press Enter Key.
-
how to return value after user inputkeyDown received Enter. that is not a problem. but if you see my code you will find that function does not wait for enter. function are (double CMyTextBox::GetNumber() and CString CMyTextBox::GetString()) they have to wait until press enter. i think the problem is this. here is link of project file. https://skydrive.live.com/redir?resid=78B222720843DE16!116&authkey=!AAjKOKZHSd-q9lI please kindly check test project.
-
how to return value after user inputyes i did as you said. the functions does not work. because functions does not wait for Enter. The function call from outer class so that InFlag has to false until press enter but with out press enter function ends. the function is not giving chance to press Enter or type any text to Edit box.
-
how to return value after user inputwell, this is what i have to complete task. it is required.
-
how to return value after user inputyes i have add InFlag = true; it is not working.
CString CMyTextBox::GetString()
{
// how to come here after press enter by user that is main thing
if (InFlag == true)
return RetVal;
return "";
}it is call form dialog class here is code.
void CRetValTestDlg::OnGetString()
{
m_TxInput.InFlag = false;
CString s = m_TxInput.GetString();
m_TxOutput.SetWindowText (s);
}
void CRetValTestDlg::OnGetNumber()
{
m_TxInput.InFlag = false;
CString s;
double d = m_TxInput.GetNumber();
s.Format ("%d",d);
m_TxOutput.SetWindowText (s);
}i would like to upload project file for review. if possible.
-
how to return value after user inputHi All, i need to return input value after press enter. how to make it. need little help. the main think here that i have to make function that return value after press Enter. here is link of project file. https://skydrive.live.com/redir?resid=78B222720843DE16!116&authkey=!AAjKOKZHSd-q9lI i have a dialog box with 2 EditBox (m_TxInput and m_TxOutPut) and 2 Button for (GetString and GetNumber) i made class CMyTextBox for m_TxInput . here is code below. i have 2 function GetString and GetNumber in CMyTextBox Class. i am calling these function on button down in dlg.
/////////////////////////////////////////////////////////////////////////////
// CMyTextBox windowclass CMyTextBox : public CEdit
{
// Construction
public:
CMyTextBox();// Attributes
public:// Operations
public:bool InFlag; // After Press Enter InFlag = true; CString RetVal; // store return value
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMyTextBox)
//}}AFX_VIRTUAL// Implementation
public:
CString GetString();
double GetNumber();
virtual ~CMyTextBox();// Generated message map functions
protected:
//{{AFX_MSG(CMyTextBox)
afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
//}}AFX_MSGDECLARE\_MESSAGE\_MAP()
};
// CPP file======================================================
// CMyTextBox message handlers
void CMyTextBox::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// TODO: Add your message handler code here and/or call default
if (nFlags == 28) // Enter press
GetWindowText(RetVal);
CEdit::OnKeyDown(nChar, nRepCnt, nFlags);
}double CMyTextBox::GetNumber()
{
// how to get return here after press enter by user
if (InFlag == true)
return atof(RetVal);
return 0;
}CString CMyTextBox::GetString()
{
// how to get return here after press enter by user
if (InFlag == true)
return RetVal;
return "";
}Thanks Amrit
-
How to Get Event from Controls in Docking Dialogi have create Docking Dialog with CDialog CDialogBar m_wndDlgBar; in preCreateWindow
if (!m_wndDlgBar.Create(this, IDD_COMMAND_WINDOW,
WS_CHILD | WS_VISIBLE | CBRS_BOTTOM|CBRS_TOOLTIPS|CBRS_GRIPPER |CBRS_FLYBY| CBRS_SIZE_DYNAMIC, IDD_COMMAND_WINDOW))
{
TRACE0("Failed to create DlgBar\n");
return -1; // Fail to create.
}
m_wndDlgBar.EnableDocking (CBRS_ALIGN_BOTTOM );
EnableDocking(CBRS_ALIGN_BOTTOM );
DockControlBar(&m_wndDlgBar);it Work fine. it display dialog with no error. but it does not give any event. i have create Class ClsCommandWindow for IDD_COMMAND_WINDOW. in IDD_CCOMMAND_WINDOW i put 2 EditBox and one Button, one of Edit Box apply from Class CMyEdit because i have to use onChar Event. now the DialogBar display dialog from it ID(IDD_CCOMMAND_WINDOW). with no use of Class. because it is not using class any event from that dialog box does not work. When i TRACE ("%i\n",nChar); on OnChar it just did nothing. please some one help me on this how to get event form that dialog box. Thanks Amrit