|
Unless I'm missing something here, the implementation you suggested in your original posting seems superior to the implementation that Nitron suggests. In your implementation, the main window class (let's call it CMainFrame) needs to know about CMyDlg, but CMyDlg needs to know nothing about CMainFrame. In Nitron's suggested implementation, CMainFrame needs to know about CMyDlg and CMyDlg needs to know about CMainFrame. Choose the path with the least linkage.
--------
There are 10 types of people in this world. Those who know binary and those who don't.
|
|
|
|
|
was thinking that myself
"... and so i said to him ... if it don't dance (or code) and you can't eat it either f**k it or throw it away" biz stuff about me
|
|
|
|
|
Hi, I have a control from which I regular need the current width, so I created a member variable. I did override OnSize() to get the new width.
Where do I get the initial width?
|
|
|
|
|
Well, I remember from my poor Win32 experience that you get a WM_SIZE after the control is created... so overriding OnSize() might be enough?
Propably someone can confirm this? Or is there any other message handler to override and call GetClientRect()?
|
|
|
|
|
Initially you will recieve a WM_SIZE before the control is created, and one after the control is created. You could do the following:
static bool first = true ;
if (GetDlgItem(IDC_OF_CONTROL) != NULL && first)
{
CRect size ;
GetDlgItem(IDC_OF_CONTROL)->GetWindowRect(&size) ;
first = false ;
}
Roger Allen
Sonork 100.10016
I think I need a new quote, I am on the prowl, so look out for a soft cute furry looking animal, which is really a Hippo in disguise. Its probably me.
|
|
|
|
|
Try reading here: CWnd::OnGetMinMaxInfo
--BlackSmith--
/*The roof is on fire, we don't need no water, let the MF burn*/. BHG.
|
|
|
|
|
sorry, I dont get the relation to my question about current control size, which is a client window (a listbox) of a dialog.
Meanwhile I tried with OnSize() , but OnSize() gets called to late. I need to catch the width somewhere earlier, right after the control is created....
|
|
|
|
|
Overwriting OnCreate() brought no luck... so I found this one:
void CListBoxLovely::PreSubclassWindow()
{
CListBox::PreSubclassWindow();
CRect rect;
GetClientRect(rect);
m_nItemWidth = rect.Width()
}
it works good
|
|
|
|
|
This brings up the UI and nothing can be done to it. Cant input anything in the combobox. THe UI is totallly unresponsive to anything:
BOOL CCombobox1View::PreTranslateMessage(MSG* pMsg)
{
CString s;
if ( pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_RETURN )
if (GetFocus() ==& m_combo1)
{
m_combo1.GetWindowText(s);
m_combo1.InsertString(0,s);
m_combo1.SetWindowText("");
m_combo1.SetFocus();
return FALSE;
}
else
{
}
else
{
return TRUE;
}
return CFormView::PreTranslateMessage(pMsg);
}
Appreciate your help,
ns
|
|
|
|
|
I'm just trying to check out the basic functionality of a combobox. I thought that with the code above< I could enter something, then dropdown the box and see it in the list...
Appreciate your help,
ns
|
|
|
|
|
Its probably due to the if(pMsg->) else condition. you should just miss this section out of the function.
BOOL CCombobox1View::PreTranslateMessage(MSG* pMsg)
{
CString s;
if ( pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_RETURN )
{
if (GetFocus() ==& m_combo1)
{
m_combo1.GetWindowText(s);
m_combo1.InsertString(0,s);
m_combo1.SetWindowText("");
m_combo1.SetFocus();
}
else
{
}
}
return CFormView::PreTranslateMessage(pMsg);
}
Roger Allen
Sonork 100.10016
I think I need a new quote, I am on the prowl, so look out for a soft cute furry looking animal, which is really a Hippo in disguise. Its probably me.
|
|
|
|
|
Modifying the UI in PreTranslateMessage may be unsafe. I guess you should move the presented functionality to OnKeyDown (WM_KEYDOWN handler). Additionally, to make OnKeyDown being called for VK_RETURN, you should override OnGetDlgCode (WM_GETDLGCODE handler) to return DLGC_WANTALLKEYS constant.
Regards,
Bartosz Bien
|
|
|
|
|
My Cdialog has two CEdits. THe default ONOK has no code in it (I'm trying to prevent enter from killing the dialog), THe way things are, the Done button has third tab order (after the CEDits) and does an EndDialog. For some reason, Enter is dismissing the dialog even though the default ONOK is empty. I need to prevent this behavior, but the standard method is not working. I even made a label be third tab order just in case.But the enter still dismisses the dialog ?This has worked before (emptying OnOK) but this time it isnt and I dont know why..
Appreciate your help,
ns
|
|
|
|
|
PreTranslateMessage
search this forum for it.
-c
No matter how fast light travels it finds the darkness has always got there first, and is waiting for it.
-- Terry Pratchett,
|
|
|
|
|
Thats what I ended up doing...I had saved a link to it...
Appreciate your help,
ns
|
|
|
|
|
Hi
I'm not sure whether it will help but try it. Do not delete default ONOK handler. If I remember well there should be line with OnOk() or something like this. Comment this line.
Greetings
Mariusz Popiolek
|
|
|
|
|
I didnt delete it. I just commented out that base class calll like you said...
Appreciate your help,
ns
|
|
|
|
|
And what? Did it help? (I suppose not )
Greetings
Mariusz Popiolek
|
|
|
|
|
Nope> But I've used Pretranslate message and thats okay for the moment....so thanks for the interest..
Appreciate your help,
ns
|
|
|
|
|
Now I tried this in VC to be sure . I double-clicked ok button so I obtain such autogenerated code:
void CMy123testappDlg::OnOK()
{
// TODO: Add extra validation here
CDialog::OnOK();
}
And after commenting CDialog::OnOK(); pressing Ok button does nothing! (dialog doesn't close). So it must help, or maybe we have a little misunderstanding (maybe your problem is a bit different).
Greetings
Mariusz Popiolek
|
|
|
|
|
I agree that pressing the OK after commenting out the line is unresponsive. I'm however hitting the enter key. Its probably got something to do with my tab order, but I only have two CEdits and 1 OK, 1 cancel to organize.....
Appreciate your help,
ns
|
|
|
|
|
Maybe you have screwed something. As far as I know hitting enter key and pressing the button using the mouse does exactly the same (launch BN_CLICKED handler). I don't think that tab order has something to do here. Handling this by messing with PreTranslateMessage is not quite elegant, my solution should work, just try to find the bug (easy to say I know)
greetings
Mariusz Popiolek
|
|
|
|
|
pretranslatemseeage is cool cos u can prevent the esc key closing ur dialog too if u want
"... and so i said to him ... if it don't dance (or code) and you can't eat it either f**k it or throw it away" biz stuff about me
|
|
|
|
|
One standard way I use to stop the OK button closing the dialog unless it has the focus is:
void CMyDialog::OnOK()
{
if (GetFocus() == GetDlgItem(IDOK))
EndDialog(IDOK) ;
}
Roger Allen
Sonork 100.10016
I think I need a new quote, I am on the prowl, so look out for a soft cute furry looking animal, which is really a Hippo in disguise. Its probably me.
|
|
|
|
|
Thats a great trick! Thank you so much! This does mean however , that the ok button HAS to be pressed to exit, right? I wanted Enter to exit me too, but only if I had written into an CEdit...
But your solution looks good, so thank you very much!
Appreciate your help,
ns
|
|
|
|