|
lol. don't even ask why... ^^
|
|
|
|
|
Joiner123 wrote: http://groups.myspace.com/HereCometheFourHorsemenofApocalypse
read.. what to do next???
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and you
|
|
|
|
|
Hello,
I am using a thread to receive a data continously and store the in the list control. The data which i received will be updated frequently. I my project, if i click one row in the list control, that particular record will be displayed in the next formview's list control. The second listcontrol record should also updated in synchronous with the first list control items.
Will you please suggest me, how i can use the thread which i have used in the first list control to update the field in second's list control in the next dialog or formview. Is there any other way to solve my problem.
Please help me.
regards
Jagannathan
|
|
|
|
|
Hello,
i am trying to create a box with sphere packing in 3D. during the compilation, if i run with smaller radius of sphere ( r=2), it is working fine. but if i increase to r=4 and increased the box size as well to fit those spheres within the cube,i m getting error as a segmentation fault. as i m beginner with programming, i couldn't fix this error. any suggestions ?. Thanks for the clarifications.
rsanju
|
|
|
|
|
The error you mentioned is obvioulsy runtime error, not compliation error. Try to debug the code, giving you this problem.
Post some relevent code , to asses the problem.
Prasad
MS MVP - VC++
|
|
|
|
|
Hi, I am using the Visual Studio 2005 Professional with SP1. When I tried to create my own custom control as described in "Creating Custom Controls By Chris Maunder" and "Creating and Using custom controls in VC++ By Yogesh M Joshi" (thanks to them by the way... ). In debug mode, program exits as soon as it starts with a memory leak error.
The steps I took to create the control is as follows,
1) I created a dialog based application (Unicode support & Static Library).
2) I created a new MFC class named "CMyCustomClass" which inherits from CView.
3) I declared and defined a public function to register the class. Code of this classs is given below
#define CLASS_NAME _T("CustomClassCtrl")
BOOL CMyCustomClass::RegisterScreenSaverClass(void)
{
HINSTANCE hInst = ::AfxGetInstanceHandle();
WNDCLASS wndcls;
if (!(::GetClassInfo(hInst, CLASS_NAME, &wndcls)))
{
wndcls.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW;
wndcls.lpfnWndProc = AfxWndProc;
wndcls.cbClsExtra = wndcls.cbWndExtra = 0;
wndcls.hInstance = hInst;
wndcls.hIcon = NULL;
wndcls.hCursor = ::AfxGetApp()->LoadStandardCursor(IDC_ARROW);
wndcls.hbrBackground = (HBRUSH)::GetStockObject(WHITE_BRUSH);
wndcls.lpszMenuName = NULL;
wndcls.lpszClassName = CLASS_NAME;
if (!AfxRegisterClass(&wndcls))
{
::AfxThrowResourceException();
return FALSE;
}
}
return TRUE;
}
4) I called this function from "CMyCustomClass" constructor.
5) I dragged and droped a custom control in the dialog window and set its class name as "CustomClassCtrl".
6) There is no more addion to the project just these steps.
7) When I compile and run the code. The following error occurs. (By the way I couldn't understand why dumping objects announced a path in drive "f:", my Visual Studio is installed in "c:")
Detected memory leaks!
Dumping objects ->
f:\sp\vctools\vc7libs\ship\atlmfc\src\mfc\occmgr.cpp(195) : {69} normal block at 0x003F4AE8, 24 bytes long.
Data: < > 01 00 00 00 00 00 00 00 02 00 00 00 00 00 00 00
{68} normal block at 0x003F8F98, 16 bytes long.
Data: < > FF FF FF FF 00 00 00 00 00 00 00 00 00 00 00 00
Object dump complete.
The program '[2672] Screen Saver.exe: Native' has exited with code 0 (0x0)
I have been searching for the answer for a long time now and found none yet...
Thanks for all the help.
-- modified at 18:46 Friday 20th April, 2007
|
|
|
|
|
The memory leak may be the result of the crash not the cause.
Try setting some breakpoints and see where the code is crashing.
Peter
"Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."
|
|
|
|
|
cp9876 wrote: Try setting some breakpoints and see where the code is crashing.
Well, I set some breakpoints and all I can see is that code is exiting not with an exception but at the end of the OnInitDialog() function. This seems to be the normal place to exit so there is something that happens inside the code that I didn't write.
cp9876 wrote: The memory leak may be the result of the crash not the cause.
Well, I cannot say whether it is the cause or the result but it seems so strange. I didn't create any dynamic objects. I only created one custom control. Why is there a memory leak???
|
|
|
|
|
f:\sp\vctools\vc7libs\ship\atlmfc\src\mfc\ is where that source code was when it was compiled. That is the value of its __FILE__ string.
|
|
|
|
|
So here is my code:
In main:
if(!m_movie.OpenMovie(L"Test.avi", hdc))
return false;
Function:
bool MoviePlayer::OpenMovie(const WCHAR* cwMovie, HDC hdc)
{
if(cwMovie == NULL)
return false;
m_hdc = hdc;
if(AVIFileOpen(&m_pAviFile, cwMovie, OF_READ, NULL))
return false;
...
My Problem is when it gets into the function cwMovie is jibberish. I've tried, passing in a char* instead and calling A2CW() but that didn't work either the same thing happened when it was a LPCWSTR. If any one can tell me how I can get it to not be jibberish that would be much appreciated.
|
|
|
|
|
I don't see a problem. Are you passing a L"" string literal just like you've shown?
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
yeah, and I am pretty sure I don't need to cast it in the AVIOpenFile function to a LPCWSTR. I've try cleaning and rebuilding. I don't know what to do anymore.
|
|
|
|
|
Well if you're getting garbage at the entry to the function - well, that shouldn't be happening
in the code you've shown.
The AVIFileOpen() function, OTOH, takes a LPCTSTR, which needs to be a const char* for non-Unicode
builds or a const wchar_t * for Unicode builds.
Is your code compiled for Unicode?
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Well I got it to work but not the way I want it to.
Works:
wchar_t test[] = L"Test.avi";
if(!m_movie.OpenMovie(test, hdc))
return false;
Doesn't work:
wchar_t test[] = L"Test.avi";
if(!m_movie.OpenMovie(L"Test.avi", hdc))
return false;
The function:
bool MoviePlayer::OpenMovie(const wchar_t* cwMovie, HDC hdc)
{
if(cwMovie == NULL)
return false;
m_hdc = hdc;
if(AVIFileOpen(&m_pAviFile, cwMovie, OF_READ, NULL))
return false;
...
Anyone know why this is?
|
|
|
|
|
What do you mean by "doesn't work"?
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
"Doesn't work" = When it gets into the function cwMovie is jibberish.
|
|
|
|
|
Hmmm doesn't seem possible. Maybe an unrelated piece of code writing to memory that doesn't
belong to it.
What are the first 24 byte values at the address pointed to by cwMovie on entry to the function
(viewed in a debug memory window)?
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
I'm trying to implement a class that create a popup window suitable for things like emulating a menu dropdown, or a drop down for a combo box, and I'm running into some issues in implementing the correct behavior.
What I want is a window that pops up, is topmost, doesn't rec'v focus (I think), and disappears when you click on it, or when you click anywhere else, or hit certain keys. I think that when it is displayed it should not disrupt the currently focused control.
I can get the basics to work doing the following,
create the window with WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN and WS_EX_TOPMOST
show the window with SW_SHOWNOACTIVATE
handle WM_MOUSEACTIVATE messages by returning MA_NOACTIVATE
When I display the window, I start a new message loop, and setup message hooks such that any mouse downs, or VK_ESCAPE keys cause the window to be closed.
This works OK. however I notice that I still have cases where the focus seems to bounce to the popup window, and does NOT get forwarded back to the prior focused control on the main window.
Is this normal Win32 behavior? Or do I need to cache the current focused window before I display the popup, and then reset the focus to this when the popup is dismissed?
Any other gotcha's I need to be aware of?
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
Save an Orange - Use the VCF!
VCF Blog
|
|
|
|
|
Hi All,
I am newbie for .net. I have created the simple console application and trying to create connection to SQL database.
Here is my code for console app:
#include "stdafx.h"<br />
#include "vcclr.h"<br />
#include "atlstr.h"<br />
#using "mscorlib.dll"<br />
#using "System.dll"<br />
#using "System.Data.dll"<br />
<br />
using namespace System;<br />
using namespace System::Data;<br />
using namespace System::Data::SqlClient;<br />
<br />
int _tmain(int argc, _TCHAR* argv[])<br />
{<br />
CString hello("Hello");<br />
gcroot m_SqlDbConnection = gcnew SqlConnection(gcnew String(hello)); <br />
return 0;<br />
}
I have the following exeption
An unhandled exception of type 'System.ArgumentException' occurred in System.Data.dll
Additional information: Format of the initialization string does not conform to specification starting at index 0.
on the string
gcroot m_SqlDbConnection = gcnew SqlConnection(gcnew String(hello));
Please help me to resolve the problem or point me to the article.
P.S. I found that CString defined as in the atlstr.h
typedef CStringT< TCHAR, StrTraitATL< TCHAR, ChTraitsCRT< TCHAR > > > CAtlString;<br />
typedef CAtlString CString; Maybe it helps.
|
|
|
|
|
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.
|
|
|
|
|