|
Do the following steps:
CBitmap bmpYourBitmap;
CDC *pDC;
CDC memDC;
memDC.CreateCompatibleDC(pDC);
CBitmap *pOldBmp = memDc.SelectObject(&bmpYourBitmap);
BITMAP bm;
bmpYouBitmap.GetBitmap(&bm);
pDC->BitBlt(0,0,bm.bmWidth,bm.bmHeight,&memDC,0,0,SRCCOPY);
memDc.SelectObject(pOldBmp);
|
|
|
|
|
I want to get the HWND of a window by FindWindow(). The second parameter is the window name, but the window name I am trying to get has a copyright symbol in it (a c with a circle around it). Is there a way that I can have FindWindow() only search for the first few characters in the window name? or is there a way to put a copyright symbol in a string? Any help is appreciated.
-Dev578
|
|
|
|
|
Use the application "Character Map" which comes with windows. In Windows XP, it's located in Start -> Programs -> Accessories -> System Tools. Double click the copyright symbol, click copy, and then paste it into your C++ code. Or use the hex code \0xa9 in the string. Like this: "Copyright \x0a9 2004"
--
Suche Wissen über Alles.
Der Student
|
|
|
|
|
Hello,
I have following C++ class hiererarchy like this:
class CBase{
protected:
// Construction/Destraction
CBase(){};
CBase(const CBase& Src){}; // Copy constractor
virtual ~CBase(){};
// Operators
virtual const CBase& operator =(const CBase& Src){}; // = operator
};
class CDerived: public CBase{
public:
// Construction/Destraction
CDerived(){};
CDerived(const CDerived& Src); // Copy constractor
virtual ~CDerived(){};
// Operators
virtual const CDerived& operator =(const CDerived& Src); // = operator
};
CDerived::CDerived(const CDerived& Src):CBase((CBase) Src)
{
//Do something here....
}
const CDerived& CDerived::operator =(const CDerived& Src)
{
if(&Src == this)
return *this;
(Base) *this = (Base) Src;
// Do something here ...
return *this;
}
Visual C++.NET compiler generates errors:
error C2248: CBase::CBase' : cannot access protected member declared in class 'CBase'.
Obviously if I changed 'CBase' as following:
class CBase{
public:
// Construction/Destraction
CBase(){};
CBase(const CBase& Src){}; // Copy constractor
virtual ~CBase(){};
// Operators
virtual const CBase& operator =(const CBase& Src){}; // = operator
};
program would compile without problems. But I need keep 'CBase' construction protected to allow instantiation of 'CBase' only via derived classes.
Does anyone have an idea how this can be fixed? Any help will be greatly appreciated.
Thanks,
Leonid
|
|
|
|
|
Maybe look at MFC's CView...
It's created dynamically at runtime using CreateObject() I believe.
How do I print my voice mail?
|
|
|
|
|
typedef void SLIDER_EVENT_HANDLER (int ,int ) ;
typedef SLIDER_EVENT_HANDLER* SLIDER_FUNC_PTR ;
How can i do this in one line eliminating the need for SLIDER_EVENT_HANDLER ?
Thanks
Engineering is the effort !
|
|
|
|
|
typedef void (SLIDER_FUNC_PTR *)(int,int);
Software Zen: delete this;
|
|
|
|
|
Shouldn't that be typedef void (* SLIDER_FUNC_PTR)(int,int); ?
--
Suche Wissen über Alles.
Der Student
|
|
|
|
|
|
Software Zen: delete this;
|
|
|
|
|
Hello,
I need to save a CString in a DLL and I don'r get it to work.
*** Program 1 ***
CString sTest;
sTest = "Hello";
MyDll.Test(sTest);
*** Program 2 ***
OnTimer()
MyDll.Test(Will get the value that program 1 put here )
Byt it dont work I get a int 3 error
If I in Program 2 set a value on the CString then it work but then I don't get the value I need.
*** DLL Class ***
void getFunc( CString sValue )
if(sValue.IsEmty())
{
return;
}
else
{
Do something else!
}
So how can I save A special value from program 1
and check it from program 2?
Please help me.
|
|
|
|
|
Hi larsson
there may be many solution for your problem,but from my knowledge i Know two solution
#1 either declare that variable globlly static in your Dll
or
#2 your have to share them betwwen application
like this
[code]
#pragma data_seg(".SHARDAT")
CString m_strUpdate;
#pragma data_seg()
[/code]
-----------------------------
"I Think It Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
|
Hi guys,
I tried to compile and run a #define type templates example code in Visual C++:
#include <iostream>
#define define_max(type) \
type max(type d1, type d2) { \
if (d1 > d2) \
return (d1); \
return (d2); \
}
define_max(int);
define_max(float);
define_max(char);
int main(void)
{
int i = max(100, 800);
char ch = max('A', 'Q');
float f = max(3.5, 8.7);
return 0;
}
and I am getting compile error ambiguous call to overloaded function on the line
float f = max(3.5, 8.7);
If I replace float with double, it will compile and run ok. Does anyone know why that is? Is there some kind of limitation on uses of float in Visual C++?
Thanks alot
|
|
|
|
|
This is just a guess, but try replacing the four occurrences of max() with something like max1() .
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
3.5 and 8.7 are consider constant doubles.
When I compile the code below, VC gives me a warning for "a" but not for
"b"
float a = 2.4;
warning C4305: 'initializing' : truncation from 'const double' to 'float'
float b = 2.4f;
|
|
|
|
|
vcplusplus wrote:
float a = 2.4;warning C4305: 'initializing' : truncation from 'const double' to 'float'float b = 2.4f;
It makes a difference. I suppose the appended f tells the compiler to treat the numbers as float type?
Thanks.
|
|
|
|
|
Hi,
I have a simple program with a CFrameWnd. I override the OnPaint() function and draw some images. I preload a sequence of images using CxImage (separate objects for each one) and then I use CxImage::Draw() function to draw the particular image one at a time. The problem is that when I change the image being displayed (by changing some pointers to another image and just calling CxImage::Draw() on a different image in OnPaint()) there's a flicker as the images change. It's not that much and when the image is displayed it looks ok, but while the images change there's visible flicker. Is this due to how slow GDI is, or something I'm not doing correctly? The images are 640x480. How do windows that display movies work then (I'm not trying to display movies btw)?
By the way CxImage::Draw() after doing some weird things just calls SetDIBitsToDevice() Win32 function with the bits.
Thanks.
|
|
|
|
|
Budric B. wrote:
The problem is that when I change the image being displayed (by changing some pointers to another image and just calling CxImage::Draw() on a different image in OnPaint()) there's a flicker as the images change. It's not that much and when the image is displayed it looks ok, but while the images change there's visible flicker. Is this due to how slow GDI is, or something I'm not doing correctly?
The flicker comes from automatically erasing the window. That's easily solved. You just have to handle the WM_ERASEBACKGROUND message and return true without erasing.
Nathan Holt
|
|
|
|
|
Thanks. It worked.
But out of curiosity do movie players use GDI? Or do they use OpenGL and write the pixels directly to the graphics card?
|
|
|
|
|
Budric B. wrote:
But out of curiosity do movie players use GDI? Or do they use OpenGL and write the pixels directly to the graphics card?
I believe they use DirectX, which has an intricate set of optomizations. It can give a program direct access to the screen, and I believe it can even set up a hardware pipeline to allow output from a DVD drive to be displayed without any code being executed to draw the video.
Nathan Holt
|
|
|
|
|
How do i change the window shapes to somethiing like ovals. also how do i change the Colors of controols like buttons? i trie using SetBkColor..but i din't work
|
|
|
|
|
this will change the dialog's shape to an oval
CRect rect;
GetClientRect(rect);
m_rgn.CreateEllipticRgn(0, 0, rect.Width(), rect.Height());
SetWindowRgn((HRGN) m_rgn, TRUE);
to change a button's backcolor, if you have a CButton variable assigned to it, it should look something like this: (put this in your dialog's OnCtlColor() message handler).
if(pWnd == (CWnd*)&m_button)
{
pDC->SetBkColor(RGB(0,0,255));
}
[insert witty comment here]
bdiamond
|
|
|
|
|
|
oh, I forgot. You'll have to declare this in your dialog's class definition.
CRgn m_rgn;
[insert witty comment here]
bdiamond
|
|
|
|