|
I'm not sure why this isn't working. Try breaking it down to see what part is actually causing
the exception:
CString hello("Hello");
gcroot<String ^> HelloStr = gcnew String(hello);
gcroot<SqlConnection ^> m_SqlDbConnection = gcnew SqlConnection(HelloStr);
The System.String constructor should be using the LPCTSTR operator of CString so I expect it
should work.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Hi All,
I'm new to these boards. You guys seem like
a knowledgeable group of programmers, so let me throw
out my first question:
I'm enhancing a c++ MFC application that querys
various databases and displays the info. I need to add
a new query class for a brand new query. I went
ahead and copied one of the previous queries
and changed the variables and parameters, etc..
When I compile I get the following error:
Error 1 error C2039: 'classCSetspQueryForTimeOverlap' : is not a member of 'CSetspQueryForTimeOverlap' c:\setspqueryfortimeoverlap.cpp 15
Because the class that it's talking about,
classCSetspQueryForTimeOverlap
is not something I've created, This seems to have something to do with dynamic linking. I have declared the header file
CSetspQueryTimeOverlap.h:
DECLARE_DYNAMIC(CSetspQueryTimeOverlap)
and in the implementation file
CSetspQueryTimeOverlap.cpp:
IMPLEMENT_DYNAMIC(CSetspQueryForTimeOverlap, CBaseRecordset)
Any help, suggestions, advice appreciated.
Thanks.
|
|
|
|
|
DECLARE_DYNAMIC/IMPLEMENT_DYNAMIC have nothing to do with dynamic linking.
These macros add members to CObject-derived classes so they provide runtime type information which
is used by the MFC framework.
Have you actually implemented the class or only used the macro?
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
ok, well ... that shows you what i know! thanks
for your help, much appreciated.
i'm still learning the lingo: i have "implemented the class" if that means that i created both a header and implementation
file, and added them to the project.
note that the error message points to the line
directly before the IMPLEMENT_DYNAMIC statement
in the implementation file.
here is the text from the header file, for example:
////////////////////////////////////////////////////////
#include "StdAfx.h"
#include "SNU.h"
#include "BaseRecordsetOdbc.h"
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
// JF created to StartTime & EndTime validation
class CSetspQueryForTimeOverlap : public CBaseRecordset
{
public:
CSetspQueryForTimeOverlap(CDatabase* pDatabase = NULL);
DECLARE_DYNAMIC(CSetspQueryTimeOverlap)
// Field data
long m_PaymentID;
// Param data
long m_paramClientIDParam;
COleDateTime m_paramStartTimeParam;
COleDateTime m_paramEndTimeParam;
BOOL Run(long ClientID, COleDateTime StartTime, COleDateTime EndTime);
// Overrides
virtual CString GetDefaultSQL(); // Default SQL for Recordset
virtual void DoFieldExchange(CFieldExchange* pFX); // RFX support
// Implementation
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
};
///////////////////////////////////////////////////////////
and here is the code from the implementation file:
///////////////////////////////////////////////////////////
#include "StdAfx.h"
#include "SetspQueryForTimeOverlap.h"
#include "SNU.h"
#include "BaseRecordsetOdbc.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
IMPLEMENT_DYNAMIC(CSetspQueryForTimeOverlap, CBaseRecordset)
CSetspQueryForTimeOverlap::CSetspQueryForTimeOverlap(CDatabase* pdb)
: CBaseRecordset(gGetApp()->m_pDBPool, CDBConnectionPool::RecTypeSP)
{
// Field Init
m_PaymentID = 0;
m_nFields = 1;
// Param Init
m_paramClientIDParam = 0;
m_paramStartTimeParam = COleDateTime(1972,1,22,0,0,0); // Initialize to "dummy value" - my birfday! JF
m_paramEndTimeParam = COleDateTime(1972,1,22,0,0,0);
m_nParams = 3;
m_nDefaultType = snapshot;
}
CString CSetspQueryForTimeOverlap::GetDefaultSQL()
{
return _T("{CALL spQueryTimeOverlap (?,?,?)}");
}
void CSetspQueryForTimeOverlap::DoFieldExchange(CFieldExchange* pFX)
{
// RFX field mapping
pFX->SetFieldType(CFieldExchange::outputColumn);
RFX_Long(pFX, _T("[PaymentID]"), m_PaymentID);
// RFX input param mapping
pFX->SetFieldType(CFieldExchange::inputParam);
RFX_Long(pFX, _T("[@paramClientID]"), m_paramClientIDParam);
RFX_Date(pFX, _T("[@paramStartTime]"), m_paramStartTimeParam);
RFX_Date(pFX, _T("[@paramEndTime]"), m_paramEndTimeParam);
}
#ifdef _DEBUG
void CSetspQueryForTimeOverlap::AssertValid() const
{
CBaseRecordset::AssertValid();
}
void CSetspQueryForTimeOverlap::Dump(CDumpContext& dc) const
{
CBaseRecordset::Dump(dc);
}
#endif //_DEBUG
BOOL CSetspQueryForTimeOverlap::Run(long ClientID, COleDateTime StartTime, COleDateTime EndTime)
{
m_paramClientIDParam = ClientID;
m_paramStartTimeParam = StartTime;
m_paramEndTimeParam = EndTime;
return DoRequery();
}
////////////////////////////////////////////////////////
ok, sincere thanks for the help!
|
|
|
|
|
Thanks for posting the code - You've implemented the class
I'm not seeing what would cause the error but I'll keep looking at it.
Is there a typo somewhere? Class name spelled wrong or one of the letters wrong case?
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
arrrrrrgghhh! yes, there was a spelling error in the
DECLARE_DYNAMIC statement (missing "For" in the class
name.)
WOW, do I feel like an idiot!
ok, are there any tricks experienced programmers
use to prevent stuff like that before making
embarrassing posts on CodeProject?
and thanks again.
|
|
|
|
|
I don't think it's embarrassing. Well maybe a little haha but I think first you'll get used
to the error message and know it's something like that.
Asking someone else to look when I'm stumped on something often helps. Sometimes someone else
will see something right away that I've spent much time looking for. Of course I was no help
to you on this one - I didn't see it
Have fun!
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
i want design a control (dll or activex) for use in c#.net
my control is like as an image control that will be insert in windows form (c#.net)
i need a step by step tutorial that help me to create this control and set new properties for it like as image address and etc
|
|
|
|
|
I've got an MFC CDialog class that displays and manages a dialog. There are several controls on the dialog (combo boxes, edit boxes, static text boxes, etc.). Included in the mix are four Microsoft date and time controls. The dialog is used in three separate instances. Not all of the controls are relevant in all three instances so we hide the controls that aren't relevant in each instance, move the controls around on the screen, and resize the dialog to eliminate dead areas on the dialog. We are getting the CWnd for each control and using the CWnd::SetWindowPos() method for each control to move it where we want. To eliminate the need to know which control appears before it in the Z-Order, we pass a NULL for the first parameter and use the SWP_NOZORDER parameter for the flags to keep from changing the tab order of the controls. This works perfectly for all the controls except the four date time pickers. When the dialog is displayed, the date/time picker controls are not visible. It appears that they were moved off the screen somehow or the dialog itself is now at a higher Z-Order than the date and time picker controls.
The code was originally invoking SetWindowPos with the first parameter set to NULL and the nFlags parameter set to 0. This changed the tab order for all the controls but the date and time picker controls were visible after everything was moved. The only thing I've changed is to pass the SetWindowPos call the SWP_NOZORDER flag. I've also tried invoking CWnd::MoveWindow instead of CWnd::SetWindowPos but the results were no different. Why is just setting the nFlags parameter to SWP_NOZORDER causing the date and time picker controls to not show up on the dialog after the move?
-- modified at 16:08 Monday 23rd April, 2007
|
|
|
|
|
I was able to work around the issue but I really don't like the solution. I used the CWnd::SetWindowPos method passing a NULL for the pWndInsertAfter parameter and 0 for the flags. This, in essence, reverses the tab order of all the controls on the dialog since the code is invoking this for each of the controls on the dialog in order from top-to-bottom and left-to-right on the dialog. After doing this, I added code to go back through each of the controls in the same order calling CWnd::SetWindowPos with the proper CWnd pointer for the pWndInsertAfter parameter and SWP_NOMOVE and SWP_NOSIZE for the nFlags parameter.
Some additional information: The date and time picker controls don't show up in the Controls window when the dialog is displayed in the Resources panel in the IDE. It appears the date and time pickers are being accessed through the IDTPicker interface in mscomct2.ocx. This OCX is being imported in the class definition header file and the four controls are defined as MSComCT2::IDTPickerPtr data types in the class definition. I'm not sure if this has anything to do with my intial problem. While the workaround is probably sufficient for our needs, I'd still like to know why CWnd::SetWindowPos with the SWP_NOZORDER flag or CWnd::MoveWindow didn't work on the date and time pickers.
|
|
|
|
|
for some uni work i'm doin i'm tryin to make it so that u login on a html page, and then for it to open a new html page using the login details. The problem is that i don't know how to get C++ to take in the details and output the html page using login details. Don't know whether thats worded properly but any help would be much appreciated.
|
|
|
|
|
I need a routine to compress wave files into speex raw format (preferably without the Ogg wrapper) and another to decompress them back to wave files. I'll be putting the the raw speex data into my own database structure, so I'd rather not mess with the Ogg. Has anyone worked with Speex that can tell me if I'm barking up the right or wrong tree?
|
|
|
|
|
On regard http://www.codeproject.com/script/comments/forums.asp?msg=1994839&forumid=1647&XtraIDs=1647&sd=20+Jan+2007&ed=20+Apr+2007&author=cdrain&stype=1#xx1994839xx[^]" rel="nofollow">comment
Thanks a lot for the help... ok I'm able to create a UI-Thread from my MainWnd as I need to get the ActiveX functionality.
My Activex must fill the grid contained on the MainWnd, while the progressBar is incremented.
So I set the timer, that increment the progressbar on the OnTimer event, and create the ui-thread using this code I use:
thread = new CMyThread();
//Set parameter I need on the ActiveX
// Include the pointer to the grid (is it right?)
thread->GripPointer= GridPointer;
thread->par2 = par2;
thread->par3 = par3;
thread->CreateThread();
On my ui-thread code i fill the grid on the Run() method and at the end of the operation I PostMessage(..) to the MainWnd and here I close the ui-thread sending a
PostMessage(WM_INFORM_CLOSE, 0, 0);.
At Run-Time it gives me an error "Not valid pointer' when i call the function to fill the grid on the ui-thread.
WHY?
- Where I need to use the ::CoMarshalInterThreadInterfaceInStream(...) and ::CoGetInterfaceAndReleaseStream(...) method you said, and witch is they're scope? (Sorry I'm newer in this use )
- Have you an example code?
Another question:
But can I manage a graphic component of the MainWnd (the grid) from the ui-thread?? Is this my problem?
Thanks a lot
|
|
|
|
|
char dbBuff[INFO_BUFFER_SIZE]={0};
char HoldDBBuff[INFO_BUFFER_SIZE]={0};
DWORD dwBytesWrittenTrans;
HANDLE HND=CreateFile(FileName.c_str(),GENERIC_READ, NULL, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
BOOL read=ReadFile(HND,dbBuff,sizeof(dbBuff),&dwBytesWrittenTrans,NULL);
int dbCount=0;
int dbHoldCount=0;
bool proceed=false;
while (dbBuff[dbCount]!=0)
{
if (dbBuff[dbCount]=='*'||proceed)
{
strcpy((char*)HoldDBBuff[dbHoldCount], (const char*)dbBuff[dbCount]);
dbHoldCount++;
proceed=true;
}
dbCount++;
}
As soon as I try and do a strcpy, the IDE brings up the assembly code and a error occurs.
Can someone please help ??
Regards,
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
My Blog: ^_^
|
|
|
|
|
|
Programm3r wrote: Stupid ....
When I first read this reply, I didn't know it was to yourself - I thought it was kinda
harsh!
I'm not sure about the above line, but, as Michael mentioned, those casts in the strcpy
call are suspicious (bad!)
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Programm3r wrote: strcpy((char*)HoldDBBuff[dbHoldCount], (const char*)dbBuff[dbCount]);
Why are you casting characters to character pointers?
|
|
|
|
|
I think I see what you're trying to do, but you need to take the address of dbBuff[dbCount] before casting it to a (const char*):
strcpy((char*)HoldDBBuff[dbHoldCount], (const char*)&dbBuff[dbCount]);
(Notice the & I added.
Hope that helps.
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
What about the destination address?
Maybe
strcpy((char*)&HoldDBBuff[dbHoldCount], (const char*)&dbBuff[dbCount]);
??
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Yep, that one needs it, too. I guess I looked at it too quickly and thought that he was copying part of the source into the beginning of the destination.
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
There is no need for those casts. Incorrect casts mask errors, and this was the case in the OP's original code. He probably threw in casts to "fix the compiler errors" and ended up with non-functional code.
|
|
|
|
|
Those are the OP's original casts - not mine. I know they aren't needed, but his main problem (as you eluded to in your first post) was that the buffer had already been dereferenced.
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
When using Visual C++ 6.0 and 7.1 to create a message handler for WM_NCPAINT, the wizard places a comment in there...
void CSomeView::OnNcPaint()
{
// TODO: Add your message handler code here
// Do not call CScrollView::OnNcPaint() for painting messages
}
Because I don't want to draw the scroll bar myself, I call CScrollView::OnNcPaint() but I feel like I'm beaking some major programming rule but I do not know what that rule is. I've not been able to detect any problems with doing this except of course some redundant drawing that might occur elsewhere in the non-client area that causes a teeny tiny amount of flicker where my drawing code differs from that of he default.
Does anyone know why the "Do not call CScrollView::OnNcPaint() for painting messages" warning gets placed in this handler and what is it intended to prevent?
|
|
|
|
|
Because in general, if you handle WM_NCPAINT , you're going to repaint the whole NC area for skinning or some similar purpose. The comment is just an advisory that if you do call the base class function, you'll get the standard NC area, which is not usually what you want because you're handling WM_NCPAINT . The world won't end if you call it, but you will end up with double the painting work and possibly flicker.
|
|
|
|
|
Thanks for the assistance.
|
|
|
|