|
Hi All
i want to get Unique Id of a particular device connected through USB \FIRWIRE Port.
IS Serial number unique? so how will i find find it of a device (like digital camera,scanner etc.)
i am able to get serial number of storage device(like USB flash Key, eternal Hard disk).
With Regards
RYK
|
|
|
|
|
I have this UI issue causing my application to hang and I am absolutely clueless what is causing the hang.
From the callstack I find that it waits at ntdll, using SPY++ I find no messages being recieved by the application. It is also not a crash as the frame messages are being recieved but the opened document is frozen.
Any clues about how to approach the problem??
|
|
|
|
|
cpp_prgmer wrote: I have this UI issue causing my application to hang...
At what point?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Well it works fine handling mouse move message over a tree. But then when I click on the cross of my MDI to close a document, I have my appln prompt to ask for save changes. It is not able to even display the messagebox, and it is stuck at ntdll... no idea why?
Also strange is that this happens when the tree is expanded and i handle mouse move event... does not happen when I collapse the tree and try to close the document. Any clues??
|
|
|
|
|
Can you more explain about your program?
|
|
|
|
|
It sounds like a deadlock, do you have multiple threads ? Are you using SendMessage() to send a message from one thread to another ?
Check the callstacks of each thread ( assuming you have more than one).
If you are not getting full symbol info in the call stacks, then try setting up a symbol server before you debug, also make sure that your .pdb file is accessible.
regards
|
|
|
|
|
I am not sure if this is happening... but I will check. The prob is with mouse move event over a tree, so in tree collapsed state it works fine but with tree expand state, i am not able to close my document...
|
|
|
|
|
I have just found the root cause to this happening is that I am calling SetCapture and not allowing processing of any other message when tree is expanded...
Sorry for the trouble... Is there any function that can detect this and override the same when trying to close the document??
|
|
|
|
|
This error occured when i was trying to create eLoader.dll from the
vcproject. Which i downloaded from eAccelerator project.
can anyone know where can i find this header file php.h....
KIRAN PINJARLA
|
|
|
|
|
kiran.pinjarla wrote: can anyone know where can i find this header file php.h....
Are you sure it is not present on your machine?
kiran.pinjarla wrote: Which i downloaded from eAccelerator project.
Is it a Windows application?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
hey folks,
I wrote a little wrapper for the gsl-library and had to face a problem I never had expected (and never noticed before).
It's a simple class-question... So first the code:
<br />
class myClass<br />
{<br />
public:<br />
myClass();<br />
~myClass();<br />
myClass Testfunction();<br />
int val;<br />
};<br />
<br />
myClass::myClass()<br />
{<br />
val=0;<br />
}<br />
<br />
myClass::~myClass()<br />
{<br />
int t = 0;<br />
int h = t;<br />
this->val = val;<br />
cout << "Destructor called\n";<br />
}<br />
<br />
myClass myClass::Testfunction()<br />
{<br />
myClass newClass;<br />
newClass.val = 7;<br />
return newClass;<br />
}<br />
<br />
int main()<br />
{<br />
myClass A;<br />
myClass B;<br />
cout << "Calling test function\n";<br />
B = A.Testfunction();<br />
<br />
cout << "Print out value:\n";<br />
cout << B.val << "\n";<br />
<br />
<br />
cout << "Waiting for user...\n";<br />
cin.get();<br />
}<br />
Allright... actually there shouldn't be any destructor called BEFORE the cin.get().
The output is:
<br />
Calling test function<br />
Destructor called
Destructor called
Print out value:<br />
7<br />
Waiting for user...<br />
The Destructor is somehow called for the return value and I don't know why...
And even if I get an explanation... is there a way of not calling the destructor here? (Compiler setting???)
because I actually free some memory in my prog in the destructor and when the memory is freed I never get it back...
any idea??
thx in advance
zqueezy
|
|
|
|
|
The Testfunction returns myClass also.
newclass doesn't exist past the end of testfunction, so the function returns a copy of it... Temporary copy needs constructing, and (drumroll) destructing.
Try adding another member to myClass, and a constructor which assigns a random value to it. Then also spit it out in the destructor. See how its actually different myClass instances getting killed.
As to the avoidance? That all depends on what you were really trying to do. What you have posted is a very artificial example to show the "double" destructing, it doesn't show what you were trying to do when you ran into this issue.
And just in case this is homework, as least I've only done 50% of your work.
Iain.
|
|
|
|
|
well, no it's no homework. I'm well aware of the fact that the copy-call is run for the object that went out of scope...
To make my example less artificial:
In gsl a matrix need allocation of memory (alloc) and freeing the memory, of course.
I tried to write a matrix-class which does the allocation in the constructor and which does the freeing in the destructor.
Now I wrote an operator function for the multiplication:
CMatrix CMatrix::operator *(const CMatrix& factorMatrix);
when I try to return the resulting matrix the destructor is called and the memory freed thus the matrix deleted and cannot be assigned with any operation like the operator=...
better?
zqueezy
|
|
|
|
|
The "extra" destructor you're getting is because you're being nice and elegant and writing a * operator, which (quite correctly) returns an instance (albeit a temporary one) on CMatrix.
If the constructor / destructor is "expensive", then you're going to have to do it a different way.
class CMatrix
{
public:
....
BOOL Multiply (CMatrix const &lhs, CMatrix const &rhs)
{
if (!ValidToDoThisMaths (lhs, rhs))
return FALSE;
....
return TRUE;
}
....
};
void main ()
{
CMatrix A,B,C;
A.Create (blah);
B.Set (blah);
C.Multiply (A,B);
C.DoStuff ();
}
Its less elegant, but it would solve your problem.
It would also lose the ability to do:
D = A * B * C
but frankly, matrices are enough of a pain to work with [ (n x m) * (m x n) etc ] that that's probably not a huge loss.
I hope that helped,
Iain.
|
|
|
|
|
zqueezy wrote: Allright... actually there shouldn't be any destructor called BEFORE the cin.get().
Of course it should.
zqueezy wrote: The Destructor is somehow called for the return value and I don't know why...
Because newClass went out of scope, and the destructor must be called in that case.
zqueezy wrote: is there a way of not calling the destructor here?
Rewrite the function like this:
void myClass::Testfunction(myClass& obj)
{
obj.val = 7;
}
Create the object before calling it, and pass it as the argument.
|
|
|
|
|
when I do the whole thing as reference... why is the destructor called anyways... isn't the reference just an address?
|
|
|
|
|
zqueezy wrote: when I do the whole thing as reference... why is the destructor called anyways
No, it is not.
|
|
|
|
|
Ach, I'm weak.
Below is a copy of a =operator function, where you can see the return type is a reference to object, rather than the object. This allows you to dasiy chain loads of =s together.
RgbQuad &operator=(RgbQuad &r)
{
rgbRed = r.rgbRed;
rgbGreen= r.rgbGreen;
rgbBlue = r.rgbBlue;
return *this;
};
I hope that steers you in the right direction.
Iain.
|
|
|
|
|
zqueezy wrote: The Destructor is somehow called for the return value and I don't know why...
The newClass object in your test function is created on the stack and so cannot be used by anyone once the function exits. So the compiler has to copy it into your B variable, then destroy the newClass object. I think you're getting two calls to the destructor because the compiler is copying the newClass object into a temporary "return value" object and then copying this one into the B variable. Google for something called "return value optimization" for info on how to get rid of this.
zqueezy wrote: is there a way of not calling the destructor here?
Nope. The newClass object *must* be destroyed (since it's on the stack).
zqueezy wrote: because I actually free some memory in my prog in the destructor
This is usually not the best way of designing things but if you absolutely have to do it like this, allocate the newClass object from the heap (using "new") and return a pointer to that.
I enjoy occasionally wandering around randomly, and often find that when I do so, I get to where I wanted to be [^].
Awasu 2.3 [^]: A free RSS/Atom feed reader with support for Code Project. 50% discount on the paid editions for CP members!
|
|
|
|
|
I didn't want to do a heap allocation... for the reason of the easy-user interface (see my first reply) but perhaps... that's the only possibility.
thanx for all your help
|
|
|
|
|
To give my end-solution:
I didn't know I had to create a Copy-Constructor for my class,
you need a copy-constructor for classes that allocate memory dynamically...
|
|
|
|
|
Im using this method needless to say is not working and need some help.
void rotateb(Bitmap* image, HDC dc){<br />
Graphics graphics(dc);<br />
Bitmap* SrcBitmap1 = image;<br />
Color mc;<br />
<br />
int angle=45;
float radians=(2*3.1416*angle)/360; <br />
<br />
float cosine=(float)cos(radians); <br />
float sine=(float)sin(radians); <br />
<br />
float Point1x=(-SrcBitmap1->GetHeight()*sine); <br />
float Point1y=(SrcBitmap1->GetHeight()*cosine); <br />
float Point2x=(SrcBitmap1->GetWidth()*cosine-SrcBitmap1->GetHeight()*sine); <br />
float Point2y=(SrcBitmap1->GetHeight()*cosine+SrcBitmap1->GetWidth()*sine); <br />
float Point3x=(SrcBitmap1->GetWidth()*cosine); <br />
float Point3y=(SrcBitmap1->GetWidth()*sine); <br />
<br />
<br />
float minx=min(0,min(Point1x,min(Point2x,Point3x))); <br />
float miny=min(0,min(Point1y,min(Point2y,Point3y))); <br />
float maxx=max(Point1x,max(Point2x,Point3x)); <br />
float maxy=max(Point1y,max(Point2y,Point3y)); <br />
<br />
int DestBitmapWidth=(int)ceil(fabs(maxx)-minx); <br />
int DestBitmapHeight=(int)ceil(fabs(maxy)-miny);<br />
<br />
Bitmap* DestBitmap = new Bitmap(DestBitmapWidth, DestBitmapHeight);<br />
<br />
for(int x=0;x<DestBitmapWidth;x++) <br />
{ <br />
for(int y=0;y<DestBitmapHeight;y++) <br />
{ <br />
int SrcBitmapx=(int)((x+minx)*cosine+(y+miny)*sine); <br />
int SrcBitmapy=(int)((y+miny)*cosine-(x+minx)*sine); <br />
if(SrcBitmapx>=0&&SrcBitmapx<SrcBitmap1->GetWidth() && SrcBitmapy>= 0 && <br />
SrcBitmapy<SrcBitmap1->GetHeight()) <br />
{ <br />
SrcBitmap1->GetPixel(SrcBitmapx,SrcBitmapy,&mc);<br />
DestBitmap->SetPixel(x,y,mc);<br />
} <br />
} <br />
} <br />
<br />
graphics.DrawImage(DestBitmap,0, 0); <-- this does not <br />
}
Thank you
|
|
|
|
|
what does it display? Try to set some pixels in destination bmp with some constatnt color to check if there is problem in rotation alghoritm or displaying
rrrado
|
|
|
|
|
Also, if you aren't required to write the rotation code yourself, GDI+ will do it for you
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
hi
the GDI+ i find is not very precise Mark i mean the image center shifts, and you have to draw the image then rotate the DC then draw it again you end up with two images and a rotated DC lol
the method i posted is skipping the second for loop for some reason
thanks for your replies... back to digging 
|
|
|
|