|
Thanks for your clarification, Gary!
regards,
George
|
|
|
|
|
George_George wrote:
class A{
A& foo1()
{
return *this;
}
A foo2()
{
return *this;
}
};
Well, there's nothing special related to this in the above snippet:
you can do as well:
class B
{
int i;
int * p;
...
int getiValue(){ retirn i;}
int & getiRef(){ return i;}
int getpValue(){ return *p;}
int & getpRef(){ return *p;}
...
}
it is simply C++ syntax for dealing with references.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Cool, CPallini! Thanks, and my question is answered.
regards,
George
|
|
|
|
|
Hello everyone,
I am reading some code from other people, there are some code like this,
class Foo {
};
Foo& func()
{
Foo foo;
return foo;
}
int main()
{
Foo& foo = func();
return 0;
}
I want to confirm with you that it is not good code, since we return a reference to local object instance, right? Even if the code has expected function currently.
thanks in advance,
George
|
|
|
|
|
Yep! Whatever else it is, it most certainly is NOT good code! The local instance of foo inside func will get deallocated when control returns from func . So the reference foo in main is undefined.
|
|
|
|
|
Thanks gleat,
My question is answered.
regards,
George
|
|
|
|
|
Hi All,,
I have created MFC Activex Control in VS 2005.In that I want to get the instance of the main window.
As like in Win32 Application we can get this instance from Winmain() function like below...
<br />
HINSTANCE hAppInstance;<br />
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)<br />
{<br />
hAppInstance = hInstance;<br />
<br />
}<br />
.. and this Instance I can use in futher application.(for example to create window CreateWindow() function)
Same way how can I get this Instance form MFC Activex Control Application??
Plz suggest me if you know anything about this.
Thanks in Advance.
|
|
|
|
|
I suggest you take a step back and tell us what problem you are actually trying to solve.
The HINSTANCE passed to CreateWindow is used to allow multiple independently-developed libraries to register window classes using the same name. The HINSTANCE differentiates between the different classes. Generally when registering a window class you pass your DLL or EXE's HINSTANCE value, then use the same value when creating a window of that class.
For more see http://blogs.msdn.com/oldnewthing/archive/2005/04/18/409205.aspx[^].
DoEvents: Generating unexpected recursion since 1991
|
|
|
|
|
Thank you very much for reply.
I was waiting fro reply for very long time.
Now ,I want to get instance of the main window which I want to give to SetWindowsHookEx(...)
function.
I got the instance by using AfxGetInstanceHandle() function,but during hooking it gives the messages for the window in which I am running this Activex(e.g. Explorer and Activex control Container).But I want to get hooking messages for all desktop windows.
Any suggetion?Plz reply me.
|
|
|
|
|
Bitmap *pbm=::new Bitmap(rt.Width,rt.Height,bm.GetPixelFormat());
Graphics *pg=::new Graphics(pbm);
pg->SetInterpolationMode(InterpolationModeHighQuality);
pg->DrawImage(&bm,0,0,rt.Width,rt.Height);
pbm->LockBits(&Rect(0,0,rt.Width,rt.Height),ImageLockModeRead|ImageLockModeWrite,PixelFormat32bppARGB,&bmd);
...
pClr->SetValue(Color::MakeARGB(100,0xff,pClr->GetGreen(),pClr->GetBlue()));
a=pClr->GetAlpha();
I used ImageAttributes to roate and adjust intensity when drawing.
Here is the code:
Matrix NM;
PointF fpt((float)pCB->m_Center.X,(float)pCB->m_Center.Y);
NM.RotateAt(pCB->m_Angle,fpt);
Matrix OM;
m_pMemGraphics->GetTransform(&OM);
m_pMemGraphics->SetTransform(&NM);
ColorMatrix cm = {
1.0f,0.0f,0.0f,0.0f,0.0f,
0.0f,1.0f,0.0f,0.0f,0.0f,
0.0f,0.0f,1.0f,0.0f,0.0f,
0.0f,0.0f,0.0f,1.0f,0.0f,
pCB->m_IntensityAdjust,pCB->m_IntensityAdjust,pCB->m_IntensityAdjust,0.f,1.0f
};
ImageAttributes ImAtt;
ImAtt.SetColorMatrix( &cm,ColorMatrixFlagsDefault,ColorAdjustTypeBitmap);
m_pMemGraphics->DrawImage(pbm,rt,0,0,rt.Width,rt.Height,UnitPixel,&ImAtt);
modified on Sunday, December 16, 2007 12:08:59 PM
|
|
|
|
|
followait wrote: GDI+ Alpha changed, the image is still opaque why?
You should create your destination Bitmap (pbm) with format
PixelFormat32bppARGB, not bm.GetPixelFormat().
You obtain a copy of the pixel bits in PixelFormat32bppARGB format
with LockBits(), but when you call UnlockBits(), the pixel bits are
converted back to the original Bitmap format.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks so much.
The task has been blocked until now.
|
|
|
|
|
Because size of the mask bitmap is different from of the to-mask bitmap,
how to do stretch efficiently.
Bitmp bm("myimage.jpg");
Graphics gp(&bm);
|
|
|
|
|
Well, any stretch is going to create fuzzy edges on your masks, but you can just create a new bitmap using the old bitmap and the new size as parameters to the constructor, I thought.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
As Christian mentioned, you'll have problems with
the mask pixel values at edges if you stretch it.
You could set the interpolation mode of the Graphics
object you're stretching to InterpolationModeNearestNeighbor
so you don't get new mask colors introduced, but that may
not give you satisfactory results.
How do you have a mask that doesn't match the size of its
associated bitmap?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I'm develop an album editor.
The mask bitmap is used for all photos.
|
|
|
|
|
I have written a C++ program. I want to do away with the default box. How do I design a nice skin and put my C++ code in it? For instance, I could write the word LOTTERY. When you click on LOTTERY the program runs.
|
|
|
|
|
I draw a frameless form and do my buttons with bitmaps, so I can make them look however I like, do rollovers, etc.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
How do you prevent someone from entering an invalid entry? For instance, the user can enter a "y" or "Y". If they entered anything else, they would receive a message saying invalid entry and be given the chance to re enter their input. I am using Microsoft Visual C++.
|
|
|
|
|
One way could be...
BOOL bOK = FALSE;
CyourDialog newDlg;
do
{
if (IDCANCEL == newDlg.DoModal ())
break;
if ((newDlg.yourParameter == "y") || (newDlg.yourParameter == "Y"))
{ bOK = TRUE;
break;
else
AfxMessageBox ("The entry is not valid, please give a correct value");
}while (bOK == FALSE)
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
Hi,
I have written a class that contains an array of pointers to another class object I wrote. In an effort to not waste CPU time by accessing the constructors to the member class until they are needed, I use the allocator class to reserve memory for these member objects. Unfortunately I can only allocate enough memory for about 2 million objects taking up about 450MB in memory. When I try to allocate more (hard coded) the code compiles but crashes when you run it.
I checked the max_size (ie allocator<lploanidtrie> alloc.max_size()) and it returns a value of 15 million. Why does the program not work? This program is coded in VS C++ 2005 and is compiled as a DLL that is called in an Excel application.
Mike
modified on Saturday, December 15, 2007 6:41:20 PM
|
|
|
|
|
You can only allocate a contiguous range of virtual addresses in a single memory allocation call. In a 32-bit application, you have 2GB of virtual address space available [*] but it's fragmented due to the locations that DLLs load at. System-supplied DLLs load towards the end of the available address space but third-party ones tend to have lower addresses. Clearly for your application on your system, the largest contiguous block of address space available is around 450MB.
You'll have to look into managing multiple arrays if your data set is this large.
[*] OK, on a 32-bit machine booted with the /3GB switch, running a version of the OS that supports it, and running a program marked /LARGEADDRESSAWARE you get closer to 3GB available, and the same program running on an x64 machine gets virtually 4GB of virtual address space. It's still fragmented.
DoEvents: Generating unexpected recursion since 1991
|
|
|
|
|
Hi.
I'd like to have a cout manipulator which would print to the console description of an instance of a class. E.g.
class MyClass
{
public:
int a;
ostream &Print(ostream &str)
{
str << "a = " << a << "\n";
return str;
}
};
void main()
{
MyClass obj;
obj.a = 1;
cout << "obj: " << obj.Print();
}
Of course the code above doesn't work, but I hope it shows what I meant.
Any ideas?
Thanks in advance.
Greetings - Gajatko
Portable.NET is part of DotGNU, a project to build a complete Free Software replacement for .NET - a system that truly belongs to the developers.
|
|
|
|
|
You need to provide an implementation of operator<< for your class and ostream. This is accomplished with a non-member function:
ostream& operator<<( ostream& str, const MyClass& mc )
{
return mc.Print( str );
} You would need to add const to the end of the declaration of Print for this to work, i.e.
ostream& Print( ostream& str ) const otherwise you'll get an error complaining that there's no overload which takes a const MyClass or similar.
You can overload operators as member functions, but they have to be members of the class which appears on the left-hand side of the expression which in this case would mean having to add it to ostream. Clearly that's not practical, so we use a non-member function, where the first argument is the left-hand side of the operator and the second the right-hand side.
DoEvents: Generating unexpected recursion since 1991
|
|
|
|
|
Thanks Mike.
Greetings - Gajatko
Portable.NET is part of DotGNU, a project to build a complete Free Software replacement for .NET - a system that truly belongs to the developers.
|
|
|
|
|