|
Well, you have to send the message to some
window I guess? Or a button?
jhaga
|
|
|
|
|
So its not possible to catch it in the CEdit box?
|
|
|
|
|
Yes, an edit box is a window. But it must have
the focus of course.
jhaga
|
|
|
|
|
You'll need to derive a class from CEdit. In this class' OnChar() handler, look for nChar equal to VK_RETURN.
|
|
|
|
|
I found it in CWnd, thanks a lot!
|
|
|
|
|
Uhhhh, i just saw that it was to be found in the message map the entire time... at least i learned something new...
|
|
|
|
|
Hi,
Also try with "ES_WANTRETURN" style in CEdit button (or click "Want Return" checkbox in resource
properties" along with DavidCrow's suggestions.
Hope this helps
regards
~Hari~
|
|
|
|
|
void CMyEditView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
switch(nChar) {
case VK_RETURN:
// do something
break;
default:
CRichEditView::OnKeyDown(nChar, nRepCnt, nFlags);
// TODO: Add your message handler code here and/or call default
}
}
and remember
ON_WM_KEYDOWN() in the
MESSAGE_MAP
jhaga
|
|
|
|
|
Yes, i noticed that it didnt work after all, i was mistaken. Perhaps(not really) i pressed another key. I hope it works now...
|
|
|
|
|
Process NM_RETURN message, if the edit control has the focus.
// Afterall I realized that even my comment lines have bugs
|
|
|
|
|
Edit control is not the same as CEdit, is it?
jhaga
|
|
|
|
|
Yes, and it still doesnt work. Im really lame sorry, but i dont even get a
BOOL CGlosEdit::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
{
// TODO: Add your specialized code here and/or call the base class
return CEdit::OnNotify(wParam, lParam, pResult);
}
message...
|
|
|
|
|
The parent is a CListCtrl derived class, and is waiting for my CEdit derived class:s modal loop to finish, i have even specified the ES_WANTRETURN style for it(and unspecified)...
|
|
|
|
|
jhaga wrote:
Edit control is not the same as CEdit, is it?
The CEdit class provides the functionality of a Windows edit control, and NM_RETURN is the notification code sent when the user presses enter while the input control (in our case the edit control) has the focus. NM_RETURN is a code for common controls.
// Afterall I realized that even my comment lines have bugs
|
|
|
|
|
It also depends on where he wants to catch(or process) the key.
jhaga
|
|
|
|
|
Override the PreTranslateMessage virtual function for the dialog class that contains your CEdit-derived control:
BOOL CMyDlg::PreTranslateMessage(MSG *pMsg)
{
if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_RETURN)
{
CWnd *pFocus = GetFocus();
if (pFocus == GetDlgItem(RESOURCE_ID_OF_CEDIT_DERIVED_CONTROL))
{
return TRUE;
}
}
return CDialog::PreTranslateMessage(pMsg);
}
-Sean
----
Shag a Lizard
|
|
|
|
|
Hi, i am beginner to visual c++, and some problems with list control and hope that somebody can help me out. Currently i have made a WebBrowser using active x. I want to capture the navigation when i surf the net with the WebBrowser.
So far i know that
void CIETEST2Dlg::OnNavigateComplete2Explorer1(LPDISPATCH pDisp, VARIANT FAR* URL)
{
CString strURL = m_WebBrowserCtrl.GetLocationURL();
SetDlgItemText(IDC_XXX, strURL); //IDC_XXX whereby is what tool control you use
}
i tried "SetDlgItemText(IDC_EDIT, strURL);" //whereby IDC_EDIT is edit box. And it works but it can display 1 URL at a time...
i tried creating a list control named IDC_LIST but it can't work. Now i have no idea on how to display the captured navigation to display out on the List control.
I hope that sombody could kindly help me with this problem. Thanks a million
-Desperate for help
I'm a newbie to visual c++. Simpler terms please
|
|
|
|
|
you can't use SetDlgItemText to set the text in a list control. You need to actually add the string to the list box. If you have an actual CListCtrl object you can call the InsertItem function. If you don't have the CListCtrl object already you can also do a
<br />
CListCtrl* pListCtrl = ( CListCtrl* ) GetDlgItem( IDC_LISTCTRLIDGOESHERE );<br />
pListCtrl->InsertItem( );<br />
Hope that helps.
Note: A simpler alternative to a ListCtrl object would be to use a list box. When using a list box you can use a similar method to get it if you don't have CListBox object but the functions are a bit simpler to use ( but provide less functionality ). Either way you can't use SetDlgItemText. You can use AddString() for a CListBox.
Cheers!
Joseph Dempsey
joseph_r_dempsey@yahoo.com
"Software Engineering is a race between the programmers, trying to make bigger and better fool-proof software, and the universe trying to make bigger fools. So far the Universe in winning."
--anonymous
|
|
|
|
|
I see. Thanks Joseph for responsing. I am kind of don't understand what you meant by
//If you have an actual CListCtrl object you can call the InsertItem function. If you don't have the CListCtrl object already you can also do a
CListCtrl* pListCtrl = ( CListCtrl* ) GetDlgItem( IDC_LISTCTRLIDGOESHERE );
pListCtrl->InsertItem( /*Fill This Stuff*/ );
erm, what do you mean by actual CListCtrl object? Sorrie about it. I'm new to visual c++ and seems to have shallow understanding. Thanks again.
I'm a newbie to visual c++. Simpler terms please
|
|
|
|
|
A control variable mapped to the actual control (i.e., DDX), versus using GetDlgItem(). Here's an example of the former:
void CMyDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_LISTCTRLIDGOESHERE , m_lbMyListControl);
}
Then you'd use it like:
m_lbMyListControl.InsertItem(...);
|
|
|
|
|
First of all you're using a simple Edit box. You need to change its style to "multiline", then you can write multiple lines into it. But if you want to list up a list of URLs the user has entered, I suggest you using a CListBox . It's nice, cute, simple and the best control for your purpose. You can find it in the toolbar as well. You can then add a URL to it with m_listBox.AddString(strURL); .
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Thanks David and Greg for your responses.
//You can then add a URL to it with m_listBox.AddString(strURL);.
Greg: When i set the member variable for listbox, is it correct that i set the category to "control"? i set to "value" before and i gave me error.
But there is another problem that appear.
after compling,
IETEST2.exe - 0 error(s), 0 warning(s)
it seems that nothin has happen. The exe doesnt seems to load (pop up).
Anyones who knows what problem is this due to?
I'm a newbie to visual c++. Simpler terms please
|
|
|
|
|
//is it correct that i set the category to "control"?
yes, it is
To the second question:
Seems like there are some rests of your old edit control, try to delete anything in your files dealing with the edit control in case you placed a new ListBox control on the dialog.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Yeah~ Thanks a lot Gerg. I manage to achieve it. But i was hoping to make it into something like this http://www.codeproject.com/listctrl/XListCtrl/XListCtrl1.jpg[^] whereby there can be more than 1 column. Can this be done by list box?
Thanks for the help again.
I'm a newbie to visual c++. Simpler terms please
|
|
|
|
|
Hi
If you want multliple columns you need to use a CListCtrl with LVS_REPORT -style turned on (can be in the control properties. Here's a nice article how to use this control.
But if you want to insert progressbars and checkboxes into your listcontrol, like on the picture, you need to draw all the things yourself, which is quite difficult for a newbie. You can simpler pick one of the custom listcontrol provided - here -.
Remember, a simple CListBox has only one column, whereas you can do a lot of things with a CListCtrl .
regards
modified 12-Sep-18 21:01pm.
|
|
|
|