|
yeah, VK_RETURN
-c
Conservative:
One who admires radicals centuries after they're dead.
-- Leo C. Rosten
|
|
|
|
|
And let's say there's another control in the dialog, one that needs the enter-key (ex. TreeCtrl in editlabel mode).
if we override the pretranslatemessage like you showed above, we have to manualy take care of all that. Or am I wrong?
we can't dispatch it to the CDialog::PreTranslateMessage member, cause the enter key will close the dialog.
A member like CDialog::SetAutoClose(TRUE/FALSE) doesn't exits, is it?
[VISUAL STUDIO 6.0] [MFC] [WIN98/2]
Bluute tette!
|
|
|
|
|
here's how i handle it in http://www.codeproject.com/property/saprefs.asp[^].
BOOL CSAPrefsSubDlg::PreTranslateMessage(MSG* pMsg)
{
if ((pMsg->message == WM_KEYDOWN) && (pMsg->wParam == VK_ESCAPE))
{
GetParent()->PostMessage(WM_CLOSE);
return TRUE;
}
if ((pMsg->message == WM_KEYDOWN) && (pMsg->wParam == VK_RETURN))
{
TCHAR szClass[10];
CWnd* pWndFocus = GetFocus();
if (((pWndFocus = GetFocus()) != NULL) &&
IsChild(pWndFocus) &&
(pWndFocus->GetStyle() & ES_WANTRETURN) &&
GetClassName(pWndFocus->m_hWnd, szClass, 10) &&
(lstrcmpi(szClass, _T("EDIT")) == 0))
{
pWndFocus->SendMessage(WM_CHAR, pMsg->wParam, pMsg->lParam);
return TRUE;
}
return FALSE;
}
return CDialog::PreTranslateMessage(pMsg);
}
Conservative:
One who admires radicals centuries after they're dead.
-- Leo C. Rosten
|
|
|
|
|
some more comments. This is what I just read today:
The following keys are active in a dialog:
...
Enter: Press the button if the focus is on a button. Otherwise it presses the default button. One button in a dialog can be given the BS_DEFPUSHBUTTON style. If no button is the default, Enter generates WM_COMMAND with IDOK.
Esc: Generates WM_COMMAND with IDCANCEL.
So in your case, you need to overwrite the virtual function OnOK and OnCancel.
|
|
|
|
|
Allright,
deprecating OnOK and OnCancel works
[VISUAL STUDIO 6.0] [MFC] [WIN98/2]
Bluute tette!
|
|
|
|
|
I tried to do this:
GetListCtrl().SetItemState( j,LVIS_SELECTED|LVIS_FOCUSED , LVIS_SELECTED|LVIS_FOCUSED );
But there is no any changing in my CListView derivied class.
|
|
|
|
|
hi,
i have these values in demo.txt:-
1
2
3
4
5
6
7
8
9
when i do
//...
ifstream file("demo.txt");
while(!file.eof())
{
int nValue = 0;
file>>value;
values.push_back(nValue);//some vector
}
file.close();
//...
i get the last number 9 read twice;Why?
|
|
|
|
|
here you go.. this should work.. I think...
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
void main()
{
vector<int> values;
ifstream file("demo.txt");
while(!file.eof())
{
int nValue = 0;
file>>nValue;
values.push_back(nValue);
cout << nValue << endl;
}
file.close();
}
well.. I'm assuming it will. Oh.. and sometimes have a new line at teh end of a file will give you an arbitary value.. SO don't put in a new line at eh end.
"When a friend hurts us, we should write it down in the sand, where the winds of forgiveness get in charge of erasing it away, and when something great happens, we should engrave it in the stone of the memory of the heart, where no wind can erase it" Nish on life [methinks]
"It's The Soapbox; topics are optional" Shog 9
|
|
|
|
|
how to get mathematical symbols in a list box? \ooo doesn't seem to work!Should i change the font or something?
|
|
|
|
|
If the symbols belongs to another fontset, you should indeed change the listbox fonts.
|
|
|
|
|
There is a white strip with a formatted date in a date/time picker. How can I change the background color of that white strip? I tried just about everything I know.
Any response any one can give me will be greatly appreciated.
Sincerely,
Danielle (an overworked graduate student)
|
|
|
|
|
Look into SetTextBkColor. I do not know what control you are using or if you built one. But the SetTextBkColor function should be able to help you. It sets the background colour for the text within a control which is different from the background colour of the control it self. Setting the colour to be equal to that of your control will make your text look better. Hope this helps.
|
|
|
|
|
I need to get the exact time in ms. Anyone know how?
Cheers,
Ali
|
|
|
|
|
If you don't mind using 100-ns intervals since 12:00 AM, January 1st, 1601, then GetSystemTimeAsFileTime is the way to go.
Tomasz Sowinski -- http://www.shooltz.com
What is "scratch" and why can everything be made from it?
|
|
|
|
|
I'm trying to create a custom control which contains a few input fields.
I've read Chris Maunders tutorial courses about 'the art of subclassing' and 'create your own custom control' which are btw great, but still I can't seem to find out where to begin.
Basically I want to create a small control with 2 input fields, some text and a button or 2. Let's say a login control containing username, password and a connect button.
There are a lot of good articles about subclassing for instance a CEdit field, but I can't find one that handles my question.
Does anybody know if it is possible to create this control starting from a dialog? Or should I just sublass a CWnd and add the Edit/static fiels and button myself. How to do this?
I really can't figure out how to start, so it should be great if anyone can point me out how to start.
Thanks in advance
Wim
|
|
|
|
|
You'll need a child dialog. Derive your class from CDialog, create a dialog template with 'child' style set, add controls on the dialog surface and add event handlers. At runtime, you'll need easy method for placing child dialog on the parent. I'm usually using 'dummy' static control which provides the initial position and size and it's replaced with child dialog.
Tomasz Sowinski -- http://www.shooltz.com
What is "scratch" and why can everything be made from it?
|
|
|
|
|
Thanks a lot. That did the trick!
|
|
|
|
|
Hi.
I am trying to create a wizard-style property sheet.
I want to add header & watermark images to it.
The header gets displayed, but the watermark does not appear.
Here is the piece of code.
HBITMAP hbm1, hbm2;
hbm1 = LoadBitmap(::AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_BMP1));
hbm2 = LoadBitmap(::AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_BMP2));
m_ps.Construct("Options", NULL, 0, hbm1, NULL, hbm2);
m_ps.m_psh.dwFlags |= (PSH_WIZARD97 | PSH_WATERMARK
| PSH_USEHBMWATERMARK | PSH_STRETCHWATERMARK
| PSH_WIZARDCONTEXTHELP | PSH_HASHELP
| PSH_HEADER | PSH_USEHBMHEADER);
I tried various combinations of the flags, but the watermark image is not getting displayed.
Does this require some change to the property pages?
ALso, I am unable to add header title/subtitle.
I use VC++ 6.0
Can somebody guide me?
Thanks.
Logic is a systematic method of coming to the wrong conclusion with
confidence.
|
|
|
|
|
This is a complete mystery to me - ive opened an access database, and its only recognised 1 row:
{
CSoundFile* pSoundFile = new CSoundFile();
pSoundFile->Open();
CString tmp;
tmp.Format("%d - %d ", pSoundFile->GetODBCFieldCount(), pSoundFile->GetRecordCount());
tmp += pSoundFile->GetTableName();
AfxMessageBox(tmp);
}
The messagebox outputs "2 - 1 [soundfilelookup]". However there are loadsa records in the database. Does anyone know what the problem is??
|
|
|
|
|
If my memory serves me correct...
The recordcount may not be accurate until EOF is seen (i.e. you have iterated through all records).
|
|
|
|
|
Cheers mate, i'll give it a try
|
|
|
|
|
Exact ! but i think you have just to move to the last record.
|
|
|
|
|
I've a ReBar in my SDI-Application and an Extended Combo Box in it. With the help of Class Wizard I select an existing class (CMainFrame) to be associated with the IDR_MAINFRAME resource of the rebar. In CMainFrame I create a OnSelChangeComboboxex1() function.
It looks like this:
CComboBoxEx *pCombo = (CComboBoxEx *)GetDlgItem(IDC_COMBOBOXEX1);<br />
int nSel = pCombo->GetCurSel();
etc.
But the program fails because of some unhandled exception. I really don't know what the problem can be. Someone, please, help!
|
|
|
|
|
If this is really urgent, why can't you provide more information on 'some unhandled exception'?
Is your combo a child of mainframe, or rather it's located on rebar?
Tomasz Sowinski -- http://www.shooltz.com
What is "scratch" and why can everything be made from it?
|
|
|
|
|
Even though CMainFrame may be getting messages sent by it, the combobox is not actually a direct child. So GetDlgItem() is returning NULL , hence your crash. You'll need to obtain a handle to the ReBar window (this should already be a member of CMainFrame ) and use that to obtain the combobox handle.
---
Shog9
If I could sleep forever, I could forget about everything...
|
|
|
|