|
|
Hi all,
My problem is that I am writing an application using ODBC to connect to an Access database. I have since found out that the there is a problem putting a datetime object into this database.
I found an article at Codeguru... which does fix that problem but on to my current problem. When I enter in a Date Time with the DateTimeCtrl then I advance to the next record or any record and it continues stuffing my original selection into every record.
Thanks,
Steve
|
|
|
|
|
Nevermind I figured it out.
Thanks anyways.
Steve
|
|
|
|
|
Hi,
I have an editable CTreeCtrl, in the function OnEndlabeleditTree() I decide whether I would save the change or, not. The problem is at the end of the function I check the ItemText of the edited label and it always remains unchanged although the label actually changes. Please tell me how I can actually reflect the change in the program. Here is the code:
void CGeneratorView::OnEndlabeleditTree(NMHDR* pNMHDR, LRESULT* pResult)
{
TV_DISPINFO* pTVDispInfo = (TV_DISPINFO*)pNMHDR;
HTREEITEM hItem = pTVDispInfo->item.hItem;
CEdit* pEdit = m_TreeCtrl1.GetEditControl();
CString str;
pEdit->GetWindowText(str);
if (str.IsEmpty())
{
MessageBox("Please enter a valid Label!");
*pResult = FALSE;
return;
}
else
{
*pResult = TRUE;
}
m_TreeCtrl1.SelectItem (hItem);
MessageBox (m_TreeCtrl1.GetItemText(hItem));
}
|
|
|
|
|
From what I understood OnEndlabeleditTree() get's after edit finished, but before actual tree item changed. Therefore, your MessageBox (m_TreeCtrl1.GetItemText(hItem));
inside OnEndlabeleditTree()is premature.
You may use your str at this point, however if you expect item text to be changed somewhere and really want to figure out what text should be -- post User Message to yourself and MessageBox items text in it's handler.
"...Ability to type is not enough to become a Programmer. Unless you type in VB. But then again you have to type really fast..."
Me
|
|
|
|
|
igor1960 wrote:
post User Message to yourself and MessageBox items text in it's handler.
please explain the above statement
|
|
|
|
|
Instead of yours:
m_TreeCtrl1.SelectItem (hItem);<br />
MessageBox (m_TreeCtrl1.GetItemText(hItem));
Do the following for example:
PostMessage(WM_APP+1, (WPARAM)hItem, 0L);
Now, create WindowProc handler if you don't have already, and put the following code there:
LRESULT CYourWnd::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) <br />
{<br />
if(message == WM_APP+1)<br />
{<br />
MessageBox (m_TreeCtrl1.GetItemText((HITEM)wParam));<br />
}<br />
...
"...Ability to type is not enough to become a Programmer. Unless you type in VB. But then again you have to type really fast..."
Me
|
|
|
|
|
I am working on a Vc++ Dialog app with ATL support .
I needed some functionality from Excel and started following :
HOWTO: Create Automation Project Using MFC and a Type Library
ID: Q178749
i get the following errors
ApplicationDev\Cam\CamProgrammer\excel8.h(9228) : error C2011: '_Application' : 'class' type redefinition<br />
C:\ApplicationDev\Cam\CamProgrammer\excel8.h(9511) : error C2011: 'Sheets' : 'class' type redefinition<br />
C:\ApplicationDev\Cam\CamProgrammer\excel8.h(9546) : error C2011: '_Worksheet' : 'class' type redefinition
what is wrong ? Please advise
|
|
|
|
|
Where is the #include < excel8.h > statement?
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
it is there in the projectDlg.h file
|
|
|
|
|
It should go in the stdafx.h file.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Plus using classwizard I am not adding all the zillion classes within Excel . I am adding the classes that I need . Would that be a problem ?
|
|
|
|
|
i am doing some Excel automation stuff and needed to convert a char * to a VARIANT
SysAllocString needs a unsigned short * which doesnt convert correctly from a char *
Is there a function that will allow me to assign a char * value to a VARIANT ?
|
|
|
|
|
Take a look at the _variant_t wrapper class.
|
|
|
|
|
I need to pass a pointer to a _com_ptr_t object (as created by the #import directive), but I can't take the address of it, since the & operator is overriden by the class to return the underlying interface pointer.
eg:
void f( ADODB::_RecordsetPtr *pRs1, ADODB::_RecordsetPtr *pRs2 )
{
if ( NULL != pRs1 )
{
}
if ( NULL != pRs2 )
{
}
}
ADODB::_RecordsetPtr pRs;
f( &pRs, NULL ); Yes, I can pass it by reference, but I want a pointer since the object is allowed to be NULL if it is not required.
Any ideas?
Thanks!
|
|
|
|
|
Always pass smart pointers by value; it's cheap and that is what they are there for. You can test the smart pointer for NULL just like a regular pointer: if it hasn't been set to anything, converting to bool will return false. (you can just use
if ( ptr )
which implicitly converts to bool)
|
|
|
|
|
Wait a second, I think a light just came on in my head...
I need to CreateInstance on the pointers that I need and then pass those to my function. Any pointers that have not had CreateInstance called on them will be false, so I know I cannot use them...
Hmmm... that will work, but I was hoping to be able to get my function to call CreateInstance on the smart pointer if it was not NULL, thereby creating it for me.
Thanks for the insight!
|
|
|
|
|
I am porting a C++ app written on Unix over to Windows using VS. It balks at a function declared and defined in the h file:
template <class T>
T *
s_file::port_data (unsigned int line) {
return ((T *) _port_data + line * _port_samples);
}
I am going to have to write overloaded functions to replace this, but is there a simpler resolution? Apparently VC does not like a template fn embedded in a class ??
Thanks,
Appreciate your help,
ns
|
|
|
|
|
try to resend it and watch for < and >, you're in HTML
Which VC you use for the compilation, the VC6 have only limited support for templates, VC2003 (7.1) supports nearly all features.
I normally used template functions in a class, so there shouldn't be a problem (VC7.0 and 7.1)
|
|
|
|
|
The < > signs in your post were swallowed by HTML. Modify your post and click on the "Do not treat ..." checkbox.
Also, exactly what error message(s) are you getting?
Regards,
Alvaro
Hey! It compiles! Ship it.
|
|
|
|
|
Sorry:
template <class T > T * s_file::port_data (unsigned int line) { return ((T *) _port_data + line * _port_samples); }
THe compiler complains that this function port_data has not been declared (though this inline is in the .h file....).
Thanks
ns
|
|
|
|
|
Try putting the function definition with the declaration inside the class definition. One less thing for VC to be confused about. I have done similar things in VC 6 so you ought to be able to get it to work.
|
|
|
|
|
Nope. Just tried it..same error:
"_p_data' is not a member of of s_file..........
Thanks though. You can see my overloading workaround dilemma in my next post if you like:
Many thanks,
ns
|
|
|
|
|
It didnt recognize this as a function belonging to the class in which it is defined (in the h file).
(BTW I also tried putting the template function body in the cpp file....no go)
template <class T>
T *
s_file::p_data (unsigned int line) {
return ((T *) _p_data + line * _p_samples);
}
so I since know that T can be either unsigned short or unsigned int in this program I thought I'd overload.but the argument list isnt unique!! So obviously these wont work:
unsigned char *
s_file::p_data (unsigned int line) {
return ((unsigned char *) _p_data + line * _p_samples);
}
unsigned short *
s_file::p_data (unsigned int line) {
return ((unsigned short *) _p_data + line * _p_samples);
}
so I need to make something different in each argument list, but what? _p_data is a void*, and _p_samples is an int (both members of the class s_file..........
Thanks,
ns
|
|
|
|
|
How about adding a second dummy parameter of type T? :
template <class T> T * s_file::p_data (unsigned int line, T)
{ return ((T *) _p_data + line * _p_samples); }
Then you just pass some dummy value (and cast it if necessary) so the compiler will know which version to call.
Regards,
Alvaro
Hey! It compiles! Ship it.
|
|
|
|