|
CYourDoc *pDoc = (CYourDoc *)(((CFrameWnd *)AfxGetMainWnd())->GetActiveView()->GetDocument()); I guess this is what you're after.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi,
I have a vector with pointers to an object. Now for each object I need to call a function Update(float fTime). Now when I write something like this:
for_each(...begin(), ...end(), mem_fun1(CActor::Update(fTime));
fTime is a valid floating point value in the method which calls this algorithm. This does not compile! I tried a variety of alternatives but none compile. Any suggestion on how to compile this?
Jurgen
|
|
|
|
|
Try with
for_each(...begin(), ...end(), bind2nd(mem_fun(CActor::Update),fTime));
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Is there anyone that knows why the following piece of code does not work as it's supposed to?
void CStomGraphDlg::OnSelectMonthcalendar(NMHDR* pNMHDR, LRESULT* pResult)
{
COleDateTime dtSel;
if(m_ctlMonthCalendar.GetCurSel(dtSel)!=0)
{
MessageBox(dtSel.Format("%x"));
// set current selection
GetDlgItem(IDC_STATIC_SEL)->SetWindowText(dtSel.Format(_T("%x")));
}
else
{
MessageBox(_T("Error getting current selection"), _T("Error"), MB_OK|MB_ICONERROR);
}
*pResult = 0;
}
It is supposed to return the date selection in COleDateTime format but the only time it works is after the program has just started, and you select the current date. After changing the selection it crashes and returns invalid date format or something. GetCurSel should return the selection date, right?
Any help appreciated,
Deian
|
|
|
|
|
Deian,
Have a look at this Same problem I perhaps? Only way I could get round it was with GetCurSel( LPSYSTEMTIME pDateTime ) which seemed to return the right result.
Adam.
"I spent a lot of my money on booze, birds and fast cars. The rest I just squandered"
George Best.
|
|
|
|
|
Thanks, I will try that solution ))
Greetings,
Deian
|
|
|
|
|
Hello there,
I run my program from CD, when my program wants to open the database from CD ... my program crashes
I think it's for strange file( .LDB ) because the database can not make .LDB file beside the access database !
How can i change the .LDB path ?????
Please help me !!!
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
The .LDB file is for record locking. Open the database for exclusive use and no ldb file will be generated. See MSDN KB Q208778 (Access2000) or Q136128 (Access95/97) for more info.
Cheers
Steen.
"To claim that computer games influence children is ridiculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
|
|
|
|
|
This seems like a simple question but I just wanted to know peoples thougths on it.
Is it better to load an entire Megabyte file all at once and parse it through memory, or is it better to parse through it a line at a time consuming minimal memory?
I implemented the second method for large file downloads to an embedded system but I would love to hear what others thoughts are on this issue.
Thanks,
Brian
|
|
|
|
|
You can use memory mapped file.
Pavel
Sonork 100.15206
|
|
|
|
|
You should use file mapping for big files. Otherwise, reading a file one line at a time will have the same result as reading the entire file such as in binary mode using C++.
Kuphryn
|
|
|
|
|
Hi.
Is it possible to sort a map *by value* instead of by key? Moreover, is it possible to declare a map that with a custome sorting algorithm that sorts accord to value? If yes, please give a sample of the sorting function. I can create the function object, but I need to know the parameter.
Thanks,
Kuphryn
|
|
|
|
|
You cannot sort a map by value (except in the trivial cases in which key order equals value order). What are you trying to do? If you explain it in more detail maybe we can give an alternative.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Are you sure that you want to use a std::map? Maybe another container is better for your needs?
You could use a std::vector of pairs, and sort this using either first or second.
|
|
|
|
|
A map is a key-value containter. The point of a map is to sort by key and look-up items according to their keys. You may use a second map with first one's values as keys and depending on the situation you use either of them.
Best regards,
Alexandru Savescu
|
|
|
|
|
Okay. Thanks.
The algorithm I am working on a probably simple for most programmers. Nonetheless, I want to come up with my own solution instead of posting it and have someone else solve it.
I have implemented a working solution.
Hey, I always appreciate help from members. Sorry about the late reply. CodeProject server was down yesterday evening.
Kuphryn
|
|
|
|
|
When I set the editbox to read-only, its backgroud color will be gray. Can I set it to another color?
Thanks in advance.
|
|
|
|
|
Try to chenge the backcolor with the Erase Background message....
Best Regards
Carlos Antollini.
Sonork ID 100.10529 cantollini
|
|
|
|
|
You can!!
handle the WM_CTLCOLOR message and check if the handle of the window passed to the handler function is equal to the handle of the editbox whose colour you want to change.
Then set the handle hbr to the brush you want to use as your background. Call SetBkColor() to change the background colour used when painting your text.
Look up WM_CTLCOLOR in MSDN!!
hope this helps
Adam.
"I spent a lot of my money on booze, birds and fast cars. The rest I just squandered"
George Best.
|
|
|
|
|
I have tried to handle the WM_CTLCOLOR message, but failed. When the editbox is set to read-only, it will not send the WM_CTLCOLOR to its parent window.
Anyway, thanks a lot.
|
|
|
|
|
Hmm.. I am doing the same... the following code paints a white background in IDC_USER and IDC_KEY which are read only (I didn't want them to be gray) and paints everything else with a blue background. They are Enabled though (i.e. EnableWindow(TRUE)).
HBRUSH CCncloginDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) <br />
{<br />
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);<br />
HWND hWnd=pWnd->GetSafeHwnd();<br />
if(nCtlColor==CTLCOLOR_EDIT || hWnd==GetDlgItem(IDC_USER)->GetSafeHwnd() || hWnd==GetDlgItem(IDC_KEY)->GetSafeHwnd())<br />
{<br />
pDC->SetBkColor(RGB(255,255,255));<br />
hbr=(HBRUSH)m_brBrush;<br />
}<br />
else<br />
{<br />
pDC->SetBkColor(RGB(128,128,200));<br />
hbr=(HBRUSH)m_brBrush2;<br />
}<br />
return hbr;<br />
}
Sounds mysterious! If you work out what's up then post it. I would be interested to hear what it was.
Adam.
"I spent a lot of my money on booze, birds and fast cars. The rest I just squandered"
George Best.
|
|
|
|
|
How do I initialize the dialog's list box in the View's member function ?
Actually, I want to display a record in the listbox in the view button down handler fucntion?
When I try to do, my program aborts in the listbox.AddString(...) fucntion?
What could be possible wrong?
|
|
|
|
|
Sounds like the listbox hasn't been created yet. If the listbox is within a dialog class, you shouldn't initialise it until you receive a WM_INITDIALOG message - the OnInitDialog() method is called. So, in this case you could pass the relevant information to the dialog constructor, and then in the OnInitDialog() method of the dialog class, initialise the listbox there.
Dave
|
|
|
|
|
Yes, u are correct.
But I would like to initailize with the data I read from the database. I am reading the records in the View's member function, so how do i pass the values read to the listbox?
|
|
|
|
|
The same principle applies:
Something like:
void CMyView::DoSomething()
{
CMyDialog dlg( this );
for ( each value in database )
{
CString strValue = GetValueFromDataBase();
dlg.AddValue( strValue );
}
if ( IDOK == dlg.DoModal() )
{
// Do something with it
}
else
{
// Panic / shoot user
}
}
class CMyDialog : public CDialog
{
// All the usual stuff
public:
void AddValue(const CString& strValue);
private:
CStringList m_lstValues;
};
void CMyDialog::AddValue(const CString& strValue)
{
m_lstValues.AddTail( strValue );
}
BOOL CMyDialog::OnInitDialog()
{
CDialog::OnInitDialog();
// Add the values
for ( POSITION pos = m_lstValues.GetHeadPosition() ; pos != NULL ; )
m_lstCtrl.AddString( m_lstValues.GetNext( pos ) );
return TRUE;
}
Dave
|
|
|
|