|
Yeah, probably. But only because they download Express, or perhaps they live in fairyland.... :P
Ooops - this was in the managed form. My bad...
-- modified at 18:15 Friday 18th August, 2006
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
This is one of the weirdest things I've ever seen. And its been very tricky to nail down.
We instantiate a class (foo *somefoo = new foo() ) using 'new' and get a pointer to that class.
Later in code, witihin a function of another class, we 'new' a new piece of memory (char *buff = (char*) new char [buffSize]) VERY oddly, this 'new' is returning the address of "somefoo" we instantiated earlier and not a new piece of memory.
Any ideas why this is happening? Or how we can avoid this? Remarkably, its happening at the same point in code EVERY time, although we use new everywhere. This was a pain in the a#$ to find.
Help please!?!?!?!?!?
-C
|
|
|
|
|
The most obvious answer is that the particular instance of somefoo is being deleted and returning that address to the available heap prior to the char array being allocated.
led mike
|
|
|
|
|
First: how is this a C++/CLI question?
Second: what? How is it a file if it is not saved?
led mike
|
|
|
|
|
hi,
i am using Visual C++ toolkit 2003.
i am writing a windows forms application.
if i click a button , it has to call an win 32 api from windows.h, say MessageBox(),
i included #include windwos.h
now it is giving an ambiguity error WinMain is already defined,
how to get out of this, even i tried the order of
#using mscorlib.dll
# include windows.h
// i am having some assumption or workarounds for this,, but i need a solution ??
// because i am intersted in discussing about this ..
// warm welcome for the discussion
^-^
@|@
- redCat
|
|
|
|
|
Hello friends,
I have downloaded libjingle application which uses
third party component GIPS. Can we replace third party component GIPS by any
other third party component. Which must be available freely.
Thanks in Advance.
Rahul Kulkarni
|
|
|
|
|
I have an unmanaged C++ dll which is an MFC shared DLL that has functions in it to initialize sockets and do other ethernet related things. I have built a managed C++ wrapper project which is also an MFC shared DLL, compiled with /clr that calls functions in the unmanaged dll. Then I have a C# project which instantiates a member of the wrapper class to access the unmanaged functions.
One of the functions in the unmanaged dll creates a new CAsyncSocket, checks to see if AfxSocketInit is successful, and if so, calls Create to create a new socket. When I call this function through my wrapper from C#, I get a debug assertion when Create is called. The call stack trace indicates that the problem is in a call to AfxGetInstanceHandle.
I've done a lot of reading about the use of AfxGetInstanceHandle, but I can still not find any solution to this problem.
If anyone can help me out, I'd really appreciate it.
|
|
|
|
|
|
According to this, using AFX_MANAGE_STATE isn't the answer...
http://msdn2.microsoft.com/en-us/library/30c674tx.aspx[^]
It says in there:
"The AFX_MANAGE_STATE macro should not be used in regular DLLs that statically link to MFC or in extension DLLs. "
My unmanaged dll is an extension DLL, and when I attempt to use AFX_MANAGE_STATE, I get dllmain linker errors...
Does anyone else have any other ideas? I'm really stuck here and would appreciate any advise. Thank you so much,
Doreen
|
|
|
|
|
see if this article[^] will provide the details you are missing.
led mike
|
|
|
|
|
I'd like to open 500 files with OpenFileDialog with enabled multiselect. But it failes to do it throwing exception? What property to modify to open a lot of files?
9ine
|
|
|
|
|
i want to connect sql server 2000 & mysql 5.0 through c++ on wndows plateform.
can any one help me in this regards?
|
|
|
|
|
Google knows.
BTW, this is the MANAGED C++ forum.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi all,
I am currently working on Serial Interface between a control box and PC and want to send/receive double values from Pc to the box as 8 uint8 values since the box only accepts in uint8 form.
For that i thought as follows : to get that double value (64 bits) in binary form and get the last 8 bits with &(and) operator and shifting bits to right till all bits are finished,namely :
double var;
char var2send[8]; % in array
var2send[0]= var & 0x00000000000000ff % last 8 bits with & operator
var>>8; %shifting bits
var2send[1]= var & 0x00000000000000ff
var>>8;
.
. % and sending this array as output
.
But in this code, i received an error that says i cant use double with & operators so that must be converted 64 bit long form!! How can i manage to do this?? or anyone has better way or suggestion?
I hope i could clearly explain my problem.
I would be very pleased if you could help me!
Thanks a lot!
Cahit
|
|
|
|
|
Yes, binary operations only work with integers. Multiply by whatever number of decimals you want, then cast to int. BTW, this is the wrong forum, this is not a managed C++ question
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
oh sorry, i deliver my message in visual c++ forum then!
|
|
|
|
|
Hello!
I'm trying to use double buffering to display some graphics faster on a pictureBox. I tried to use the setStyle property of the PictureBox the following way
pictureBoxMap->SetStyle(ControlStyles::UserPaint, true);
pictureBoxMap->SetStyle(ControlStyles::AllPaintingInWmPaint, true);
pictureBoxMap->SetStyle(ControlStyles::DoubleBuffer, true);
pictureBoxMap->UpdateStyles();
But no success...
Then i tried using the GDI+ method by drawing the graphics in a bitmap image first and then displaying the image on screen as follows
private: System::Void pictureBoxMap_Paint(System::Object *sender,System::Windows::Forms::PaintEventArgs *e)
{
Graphics *grOnPaint = e->Graphics;
Bitmap *bmpBuf = new Bitmap(ClientRectangle.Width,ClientRectangle.Height);
Graphics *bmpgr = Graphics::FromImage(bmpBuf);
Pen *BluPen = new Pen(Color::FromArgb(0, 0, 0, 255),50);
bmpgr->DrawLine(BluPen,10,10,100,100);
grOnPaint->DrawImage( bmpBufr,100,100);
bmpBuf->Dispose();
bmpgr->Dispose();
My question relates to the later method. It seems that "bmpgr" does not get created properly through Graphics::FromImage with the result "bmpBuf" to be empty and nothing to be drawn on my PictureBox.
Does anyone how i can do this properly? Or may what i am doing wrong with the pictureBoxMap->SetStyle() method.
Any comments would me most appreciated.
Thanks
george
george
|
|
|
|
|
yiwpyos wrote: nothing to be drawn on my PictureBox.
Why do you need a picture box if you're going to paint it yourself ? Just draw it onto your form.
That is how you use Graphics::FromImage, but you don't need it. Just draw your blue line onto grOnPaint instead.
DrawImageUnscaled is faster, if you're not scaling it anyhow.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi Christian,
Thanks for your reply. The truth is that my drawing function is a lot more complicated than the example i showed in my message. I am going through three "for" loops to display 3D dispersions on a map.
I chose to use a pictureBox because i thought it would be easier to handle the map displaying (zooming in/out, panning etc) by specifying it as the pictureBox->image, and then drawing the rest on top and following the same zooming, panning etc. Not sure it is the best way to go about it, just chose it.
To cut a long story short, apart from removing the flickering from my drawing i wanted to use double buffering to also improve the speed of my displays because these are displayed in real time (would like to anyway every 10 seconds). I did manage to implement the GDI+ double buffering i was straggling with (amazingly enough i was drawing in "bmpBuf" and was displaying "bmpBufr" >:E). However, although the flickering went away the displaying speed did not improve enough.
Do you think the .NET way of handling double buffering would do better (i read that the .NET way is more optimized http://www.windowsforms.net/articles/windowsformspainting.aspx). Any help how do make this work? This is what i tried
pictureBoxMap->SetStyle(ControlStyles::UserPaint, true);
pictureBoxMap->SetStyle(ControlStyles::AllPaintingInWmPaint, true);
pictureBoxMap->SetStyle(ControlStyles::DoubleBuffer, true);
pictureBoxMap->UpdateStyles();
Or any other suggestion how to improve the displaying speed would be much appreciated.
Thanks
george
george
|
|
|
|
|
Yes, you need to draw it yourself and turn on double buffering. Always use provided code first, assume a library author has been paid to take the time to provide the best possible implimentation.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hello All!
I have been unable to receive a Byte[] in MC++. Whats the right syntax
this is the C# dll method.
public byte[] GetPictureBytes(Image _Pic)
{
byte[] _rtval = null;
MemoryStream mstr = new MemoryStream();
_Pic.Save(mstr, ImageFormat.Jpeg);
_rtval = mstr.GetBuffer();
return _rtval;
}
Now i have to call this C# dll method in VC++.NET 2005
the syntax that i m using to call and receive this byte array is as follows but its creating some error.
"
array<byte^>^ myImage = gcnew array<byte^>^(1);
myImage = dllobj->GetPictureBytes(_myImage);
"
OR
"array<byte^>^ myImage = gcnew array<byte^>^(1);
myImage = dllobj->GetPictureBytes(_myImage);"
// dllobj is of C# dll Class type that contains metod GetPictureBytes(Image _Pic);
// _myImage is Image type
i have used some other combinations also to receive the Byte array but cant having some errors. Plz guide me writing correct syntax to receive this Byte array in VC++.Net
THNX in Advance
-- modified at 5:55 Wednesday 16th August, 2006
|
|
|
|
|
hello friends;
I am currently trying to write a program that would detect if the colour red.
Basically i need to be able to set it up to monitor a certain portion of my screen (ie, bottom left, box shape) and when it detect a certian chape of red, it will return 1 or 0, or any type of return.
If this is to complicated to explain or to logn to quickly write a short code for it, i understand and thank you for your time in reading this post.
Thank you.
- Droz -
___ ___
/\/\ /\ | |
|
|
|
|
|
To read/set the color of a pixel, there are two Win32/GDI calls, GetPixel() and SetPixel(). Try to find counterparts in managed GDI+. Otherwise, you may have to platform invoke Win32.
Best,
Jun
|
|
|
|
|
Thank you Jun,
i'll look into those functions, thank you.
- Droz -
___ ___
/\/\ /\ | |
|
|
|
|
|
I want to register a sample fax routing dll on Windows XP,
I have found this sample DLL from Windows SDK.
I can not register it, while on Windows 2000 it can be registerered.
On Windows XP the error message is:
"The modem did not accept the command sent to it. verify the configured modem
matches the attached modem."
Anyone could help me plase?
|
|
|
|