|
|
Do you really expect that someone will make the entire job for you ?
|
|
|
|
|
Stlan wrote:
Do you really expect that someone will make the entire job for you ?
WHAT About RENT-A-CODER
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
I spent tons of time trying to get this working, and it looks like I need someone' help.
I have three C++ functions in a DLL. One creates an object and returns pointer to this object. Second accepts the pointer of an object, and calls one of the object's member functions. Third deallocates memory. When #1 and #2 are in one function, everything works fine. When they are split, the application crashes.
Maybe there is something wrong with my setup? Is there a chance that memory gets deallocated in between somehow? Please help. Thank you.
Function #1
===========
long _stdcall InitClient( char* cErrStr )
{
CBLZQuoteManager* pQuoteManager = NULL;
CMyQuotesClient* pQuotesClient = NULL;
pQuoteManager = (CBLZQuoteManager *)(CBLZQuoteManager::GetInstance(RUNTIME_CLASS(CBLZQuoteManager)))
pQuotesClient = new CMyQuotesClient();
....
return ( long )pQuotesClient;
}
Function #2
===========
short _stdcall GetQuote( long lPtr,
double& dResult,
char* cErrStr )
{
CMyQuotesClient* pQuotesClient = ( CMyQuotesClient * ) lPtr;
pQuotesClient->DoSomething();
....
}
VB.NET side
===========
Public Declare Function InitClient Lib "quotes.dll" () As Long
Public Declare Function GetQuote Lib "quotes.dll" _
(ByVal lPtr As Long, ByRef dResult As Double, _
ByVal sError As String) As Short
......
lPtr = InitClient()
nReturn = GetQuote(lPtr, dResult, sError)
.....
|
|
|
|
|
Here's a small sample showing how i'm doing it wrong :P
I tried the gnu compiler, cause sometimes other compilers give better insight, and it told me that the friend declaration specifies a non-templated function and told me to add <> after the function name...but didn't work out. Help please.
#include <iostream>
using namespace std;
template < class Type >
class Template
{
public:
Template(Type value) : Value(value)
{ }
Type Value;
/* Overloaded stream operators ********************************************/
friend ostream & operator << <>(ostream &, const Template < Type > &);
friend istream & operator >> <>(istream &, Template< Type > &);
};
template < class Type >
ostream & operator <<(ostream & os, const Template< Type > & point)
{
os << point.Value;
return os;
}
template < class Type >
istream & operator >>(istream & is, Template< Type > & point)
{
is >> point.Value;
return is;
}
int main()
{
Template < int > tes(3);
cout<
|
|
|
|
|
'Do not treat <'s as HTML tags' will allow us to read your code. I also have articles on this site about iostream inserters and extractors.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I fixed the <'s...will look for your articlles tomorrow...gettin late over here.
|
|
|
|
|
Hello,
The following code works for me on a VC compiler:
template<class> class Template;
template< class T >
std::ostream& operator << (std::ostream& ost, Template<T> value)
{
return ost << value.m_t;
}
template <class T>
class Template
{
public:
template<class T>
friend std::ostream& operator <<(std::ostream& ost, Template<T> value);
private:
T m_t;
};
The point is that you use a template parameter in a non-template function declaration. Therefore you have to make your operator a template function too.
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
Thanks! your example helped me make it work
Here's a shortened version of the class i needed it for...It works in gnu and vs.net
<br />
<br />
#ifndef POINT_H<br />
#define POINT_H<br />
<br />
<br />
#include < iostream ><br />
using namespace std;<br />
<br />
template < class Type ><br />
class Point<br />
{<br />
<br />
public:<br />
<br />
Point(Type x = 0, Type y = 0) : X(x), Y(y)<br />
{ }<br />
<br />
Type X, Y;<br />
<br />
<br />
<br />
template< class T ><br />
friend ostream& operator <<(ostream &, const Point< Type > &);<br />
<br />
template< class T ><br />
friend istream & operator >>(istream &, Point< Type > &);<br />
};<br />
<br />
template < class Type ><br />
ostream & operator <<(ostream & os, const Point< Type > & point)<br />
{<br />
return os << "(X: " << point.X << ", Y: " << point.Y << ")";<br />
}<br />
<br />
template < class Type ><br />
istream & operator >>(istream & is, Point< Type > & point)<br />
{<br />
return is >> point.X >> point.Y;<br />
}<br />
<br />
#endif //POINT_H<br />
<br />
|
|
|
|
|
You're welcome
FocusedWolf wrote:
using namespace std;
A little bit of advise: never and I mean NEVER use a using statement in a header file. I may not cause problems directly, but if you start to work on large projects or libraries that will be used by third party people, this little statement is likely to cause some nasty trouble.
The reason for this is the following: the using SomeNamespace keyword brings all the declarations in of SomeNamespace into the current namespace (in your case the global namespace). This feature is often called polluting a namespace. This could cause name clashes with other namespaces or whatever. This problem is hard to track down.
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
Hello,
Here's my problem. I have a CListCtrl that supports in-place editing. I need to capture the Return key and notify the parent dialog that Enter has been pressed. I've tried the following:
void CInPlaceEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// If Enter has been pressed, we need to post a WM_KEYUP message to our parent dialog.
if(nChar == 13)
{
// Get a handle to our dialog window
CWnd* pDialogWnd = NULL;
pDialogWnd = GetParent();
// Post the message to our dialog window
pDialogWnd->SendMessage(WM_KEYUP, VK_RETURN, 0);
}
...
I think I'm going about this the wrong way but I'm not sure of the right way to do it. Any help would be greatly appreciated! I'm Stuck!
Thanks!
-Ian
|
|
|
|
|
You need to either create a custom message ( why does the keyup HAVE to mean something happened in a child dialog ? ), or pass an instance of the parent through to the child, and call a method on it directly. I'd define the method in an abstract class and derive from it, so that it's easy to change the parent dialog.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I was using the keyup message because the code used to be in a CEdit-derived class in the WM_KEYUP handler.
A custom message would work, but I'm having trouble getting a handle to the dialog...
-Ian
|
|
|
|
|
I need some help for my project. i'm using MFC C++.
Actually i need to write a program tat can select the wanted region on an given image(256 by 256) to compute some calculation.... but before i can compute the calculation i need to differentiate the selected region i wan and the region tat is unwanted... so the wanted region i need is the thickness of hollow cylinder.... i need to draw a bigger circle first capture the pixel selected and store in a array call (Index [r][c]) and follow by drawing a smaller circle in the bigger circle capture the pixel in a array call (index_inner[r][c])...the wanted region is between the bigger and the smaller circle...
can u give me some tip for how to wirte the program
|
|
|
|
|
This sounds to me like a problem you should be able to solve without any interaction with a bitmap at all. You should be able to mathematically work out which pixels will be inside the first circle, then knock out any pixels that occur in the second.
But if you want to store the pixel values also, then you need to create a DIBSection, so you have a pointer to the pixel values. Then use a 24 or 32 bit bitmap so that the pixel values are stored there in an easy to read format. Or you can use GDI+, then the code looks the same as the pixel access code in my image processing articles ( which are in C# ).
Don't use get/setpixel unless speed is not an issue.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
My image used actually is black and white, it not colour..
sorry i didn't mention to u...
|
|
|
|
|
It's a 2 bit image ? OK - well you can either work out how to iterate through it by bitmashing, or you can convert it to 8 bit using GDI+ ( because they each byte will contain one pixel, and you'll just need to work out which palette value is black and which is white ).
So you have a 2 bit image, and you want to work out the pixel values within a donut, is that right ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Dear all:
I am now conducting a project that supports recording videos from TV card. I am wondering if some has similar experience such as capturing videos(using DirectShow) from analog TV card or USB webcam.
Please let me share your experience if possible.
Thank you very much.
Jeffrey
|
|
|
|
|
Is DirectShow on WinCE signifiacantly different from
DirectShow on Windows XP, etc? If not, and if it would
be any use I could "share my experince", which started
with my stumbling through the Amcap sample source code
and finished with my writing a full featured, skinable
video capture application and understanding a heck of a
lot more about DirectShow Filtergraphs than I did before.
Steve T
|
|
|
|
|
Steve:
Thanks a lot for your information.
Yes, there are a lot of differences between WinCE and XP as far as Directshow is concerned. For example, most filters are not supported in WinCE.
Actually, my previous project on XP started from amcap, too. However, when I migrated it from XP to CE, I found a lot of things needed to be done...
Jeffrey
|
|
|
|
|
This morning, I tried to create an instance for a Capture Graph Builder using the following code:
hr = CoCreateInstance(CLSID_CaptureGraphBuilder2, NULL,
CLSCTX_INPROC_SERVER, IID_ICaptureGraphBuilder2, (void**)&pBuild);
Unfortunately, it returns REGDB_E_CLASSNOTREG, which indicates "A specified class is not registered in the registration database. Also can indicate that the type of server you requested in the CLSCTX enumeration is not registered or the values for the server types in the registry are corrupt."
I check the corresponding registrey in WinXP, the CLSID_CaptureGraphBuilder2 is associated with the qcap.dll, which does not exist in WinCE.
Does anybody has the solution? Thanks a lot.
Jeffrey
|
|
|
|
|
Can anybody answer my question?
Thanks a lot.
Jeffrey
|
|
|
|
|
Hi, can anyone explain what does the program below do in MFC C++.
void CMediVisionView::OnFileSaveasraw()
{
// TODO: Add your command handler code here//
FILE *raw;
int n;
unsigned short sdata;
static char BASED_CODE szFilter[] = "DICOM Files (*.txt)|*.txt|All Files(*.*)|*.*||";
CFileDialog dlg_save_as(FALSE, "dcm", NULL, OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY, szFilter);
if(dlg_save_as.DoModal() == IDOK) {
raw = fopen("test.raw","a+b");
for (n=0; n
|
|
|
|
|
It shows that the person who wrote it doesn't know C++, but knows C.
It's very poorly written code to open a file dialog, and open a DICOM file which has been saved as a .txt file ( this is ridiculous ), and then it opens the file, and it scales every value by taking a new theoretical maximum value, and it assumes the old maximum was 256.
According to this, a RAW file is not 10 bit at all, it's just 8 bit, one byte per pixel.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Can you advice on a better way to write this program?thks.
|
|
|
|