|
what about trying double buffer here.
CMemDC class [^] comment out the background filling with FillSolidRect
and use CMemDC class
BOOL CMyEditorDlg::OnEraseBkgnd( CDC* pDC ){
CRect rcClient;
GetClientRect(&rcClient);
CMemDC memDC(pDC, &rcClient);
Graphics g(memDC.m_hDC);
. . .
. . .
|
|
|
|
|
I've tried to make it as:
BOOL CMyEditorDlg::OnEraseBkgnd( CDC* pDC ) {
return TRUE;
}
It still flicks (no less), so I think it's other problem.
However, I tried your suggestion, now it flicks much less (say 90% less).
|
|
|
|
|
Here is the new version with less flicker
BOOL CEditorDlg::OnEraseBkgnd( CDC* pDC )
{
CRect rcClient;
GetClientRect(&rcClient);
static CRect rcClientPrev(0,0,0,0);
Graphics g(pDC->m_hDC);
if (rcClient!=rcClientPrev || m_pBmBk==NULL) {
rcClientPrev=rcClient;
CRect rc(rcClient);
rc.bottom=rc.top+m_capH;
Bitmap bmBkCap(rc.Width(),rc.Height(),PixelFormat32bppARGB);
Graphics gMemBkCap(&bmBkCap);
TextureBrush brBkCap(&m_bmCapBkM);
gMemBkCap.FillRectangle(&brBkCap,m_bmCapBkL.GetWidth(),0,
rc.Width()-m_bmCapBkL.GetWidth()-m_bmCapBkR.GetWidth(),m_bmCapBkM.GetHeight());
gMemBkCap.DrawImage(&m_bmCapBkL,0,0);
gMemBkCap.DrawImage(&m_bmCapBkR,rc.right-m_bmCapBkR.GetWidth(),0);
gMemBkCap.DrawImage(&m_bmCapBkTitle,(rc.Width()-m_bmCapBkTitle.GetWidth())/2,0);
rc=rcClient;
rc.top=rc.bottom-m_footH;
Bitmap bmBkFoot(rc.Width(),rc.Height(),PixelFormat32bppARGB);
Graphics gMemBkFoot(&bmBkFoot);
TextureBrush brBkFoot(&m_bmFootBkM);
gMemBkFoot.FillRectangle(&brBkFoot,m_bmFootBkL.GetWidth(),0,
rc.Width()-m_bmFootBkL.GetWidth()-m_bmFootBkR.GetWidth(),m_bmFootBkM.GetHeight());
gMemBkFoot.DrawImage(&m_bmFootBkL,0,0);
gMemBkFoot.DrawImage(&m_bmFootBkR,rc.right-m_bmFootBkR.GetWidth(),0);
Bitmap bmMemBk(rcClient.Width(),rcClient.Height(),&g);
Graphics gMemBk(&bmMemBk);
gMemBk.Clear((ARGB)Color::White);
gMemBk.DrawImage(&bmBkCap,0,0);
gMemBk.DrawImage(&bmBkFoot,0,rc.top);
delete m_pBmBk;
m_pBmBk=new CachedBitmap(&bmMemBk,&g);
}
g.DrawCachedBitmap(m_pBmBk,0,0);
return TRUE;
}
|
|
|
|
|
what about a single offscreen bitmap (cached), you are using 3 bitmaps now, (bk, cap, foot). I think background has to drawn first but you are drawing last.
|
|
|
|
|
I have a dialog and this dialog's domodal function(myDlg->DoModal) is called from another cpp file. I got rectangle of this dialog at the end of the oninitdialog function and a button clicked event after the dialog had been visible but these two rectangle values were different. Does domodal function do something about position of the dialog after oninitdialog function of this dialog?
<br />
other.cpp:<br />
<br />
myDlg->domodal()<br />
<br />
<br />
myDlg.cpp:<br />
<br />
myDlg::OnInitDialog<br />
{<br />
......<br />
......<br />
GetWindowRect(&rect);
}<br />
myDlg::ButtonClick
{<br />
GetWindowRect(&rect);
}<br />
Why are these two rectangle diffenrent? Thanks.
|
|
|
|
|
Did you move your dialog before clicking the button ? If yes, then it's normal that the rectangle changed.
|
|
|
|
|
mehmetned wrote: Does domodal function do something about position of the dialog after oninitdialog function of this dialog?
There is a function called _AfxPostInitDialog which does some additional house keeping after OnInitDialog !
From what I see it's centering the dialog!
Nibu thomas
Microsoft MVP for VC++
Code must be written to be read, not by the compiler, but by another human being.
Programming Blog: http://nibuthomas.wordpress.com
|
|
|
|
|
Sure, GetWindowRect is not correct at OnInitDialog.
Use GetWindowPlacement to get window position is a better idea.
Chintse Wu/[^]
|
|
|
|
|
I need to find CButton\CComboBox\ some other control properties and i have the hwnd of the component - How can i do it ?
Thanks.
|
|
|
|
|
try
LONG GetWindowLong(HWND hWnd, int nIndex);
|
|
|
|
|
What i need is little more complex.
I want not only the properties that i can get by using GetWindowLong - i want also the properties around the object.
I mean properties like - object color, text, size, class, parent of the object ( if the object is CButton that "sit" on some panel or dialog )
So... How can i get all those information ?
|
|
|
|
|
Yanshof wrote: I mean properties like - object color, text, size, class, parent of the object
go through CWnd class Members.
|
|
|
|
|
I have a function char * SetName() that I use inside a method of a different class. If I do:
char * cOpName ;
cOpName = AnotherObj.SetName() ; everything's fine. But if I try to assign the return value of SetName() to a member variable
private:
char * m_cOpName ;
m_cOpName = AnotherObj.SetName() ; I get an error, "error C2166: l-value specifies const object"
Any idea??
|
|
|
|
|
Where did you put that code ? Because looking at it it seems you put it inside the class declaration which is plainly wrong... You need to put that in a member function of the class. And the function must be non-const.
On a side note, do you know what the assignement operator is doing on char pointers ? Do you know that it only copies the pointer. It means that if inside your AnotherObj you modify the original string, the changes will also occur in m_cOpName (both pointers point at the same memory location).
|
|
|
|
|
piul wrote: m_cOpName = AnotherObj.SetName() ;
Where have you put the above line of code?
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.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
class CAnneal
{
public:
void GenOp () ;
/...
public:
char * m_cOpName ;
};
class COperation
{
public:
char * SetName() ;
};
char * COperation::SetName()
{
return "Hello" ;
}
void CAnneal::GenOp()
{
COperation op ;
char * cOpName ;
cOpName = op.SetName() ;
m_cOpName = op.SetName() ;
}
|
|
|
|
|
Your code works fine on my system, as it should do also on your.
BTW Simulated annealing?
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.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
I hate strings...
If the "=" operator only copies the pointer, how do I do to copy the characters?? Because, the object that sets the string falls out of scope.
Oh, and it's not simulated, it's for real!
|
|
|
|
|
Use a std::string instead, it will handle all the ugly stuff for you.
|
|
|
|
|
While the best suggestion is the Cedric Moonen's one (use std::string ), you may choose the Win32 API approach (if you need to be stuck on plain C ), i.e.
void SetText(char * buf, int len);
Where buf is a buffer (of size len ) allocated by the caller.
In the function implementation, of course, you've to take care of copying characters.
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.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
you should never use operator=() on C style strings (as you stated, it copies the pointers addresses instead of the strings contents.
if you still have to deal with char*, the use strcpy() and its variants.
but as you're coding in C++, you'd better use the std::string class which provides powerful operators to handle this...
|
|
|
|
|
piul wrote: cOpName = AnotherObj.SetName() ;
Is this SetName or GetName?
piul wrote: everything's fine. But if I try to assign the return value of SetName() to a member variable
private:
char * m_cOpName ;
m_cOpName = AnotherObj.SetName() ;
I get an error, "error C2166: l-value specifies const object"
This means "this" is constant! You are trying to assign a value to a const class' member.
For e.g.
const SomeClass sc;
sc.m_cOpName = AnotherObj.GetName(); // Error l-value specifies const object
Nibu thomas
Microsoft MVP for VC++
Code must be written to be read, not by the compiler, but by another human being.
Programming Blog: http://nibuthomas.wordpress.com
|
|
|
|
|
I'm sorry guys!!
I must be blind or something... GenOp() was in fact GenOp() const
I just didn't see it and couldn't understand...
Thanks for the help!
|
|
|
|
|
hello for all
please help me
i have
char x[50]="int w ; int s,get;";
i want to divide this string as
w
s
get
then i want to store each of them as example
string s[8];
s[1]=w
s[2]=s
s[3]=get
i can store it
i can't divide it, i have some ideas but didn't execut
please help me
|
|
|
|
|
sofia_111 wrote: i can't divide it, i have some ideas but didn't execute
What was your idea? Can you show us what you tried?
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|