|
Mouse clicks on a window shouldn't cause a repaint unless you've got code somewhere
causing the window to be invalidated.
How do you know the points are being drawn again? Does the background get "erased"?
You shouldn't be tying up your UI thread for "several seconds".
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
<br />
void CMyView::OnInitialUpdate()<br />
{<br />
CFormView::OnInitialUpdate();<br />
GetParentFrame()->RecalcLayout();<br />
ResizeParentToFit();<br />
<br />
RECT rect;<br />
GetWindowRect(&rect);
}<br />
<br />
<br />
void CMyView::OnBnClickedBtnTest()<br />
{<br />
<br />
RECT rect;<br />
GetWindowRect(&rect);
}<br />
After OnInitialUpdate() until I clicked test button(run OnBnClickedBtnTest() ), nothing to do.
|
|
|
|
|
I am not sure but maybe when you get the rectangle in button code, it gives the button's rectange.
so plz check if your button's top is 30. if it is 30 then you need to find a way to get the view's rectangle
|
|
|
|
|
Hi,
The MSDN says that
"The GetWindowRect function retrieves the dimensions of the bounding rectangle of the specified window. The dimensions are given in screen coordinates that are relative to the upper-left corner of the screen."
So may be(am not sure) the window is created (0,0) as top left. Then it is moved to new Co Ordinates When it is displayed. that is why you are getting different co ordinates. My suggestion is that no need to bother about this co ordinates u just use rect. top, rect.left etc. so that your drawing or anything will positioned based on the parent window.
thanks
Nitheesh
|
|
|
|
|
i need to show one triangle in the display area and it is moving forward. so I use loop to draw the same trianle in the new location. but i need to delete the previous triangle while i m drawing the new one in new location.
plese help me to solve this.
|
|
|
|
|
XOR the old triangle bits. it will clear the area.
first XOR the same triangle with the one you want to delete
after that draw a new one
|
|
|
|
|
Are you sure XOR will retain the background if i didn't first draw the triangle in XOR (I draw the triangle in say RED ?)
|
|
|
|
|
if you are using only one layer it won't which is really bad way to do it. Always keep a background layer. After XOR application redraws it immediately and redraws it fast.
|
|
|
|
|
what's that layer means, do you mean layered window, OP is not using that. if you mean fill with background color, then why need XOR simple draw it.
I mean to say XOR approach won't work if you draw the triangle with solid color, or else can you give a sample.
|
|
|
|
|
still i cant fixt it out. do you guys can make it simpler. with an example of a triangle.
|
|
|
|
|
post what you have did, we try to correct it.
|
|
|
|
|
here is the poriton of the code:
BOOL CUserInterfaceDlg::PlotGraph(CPoint* Points,size_t m_SizeOfArray)
{
int i;
GraphRegion->SelectObject(PenSimulation);
for (i=0;i<m_SizeOfArray;i++)
{
Draw_triangle(&Points[i]);
}
return 0;
}
void CUserInterfaceDlg::Draw_triangle(CPoint* Points)
{
GraphRegion->MoveTo(Points[0].x,Points[0].y);
GraphRegion->LineTo(Points[0].x+10,Points[0].y-10);
GraphRegion->LineTo(Points[0].x-10,Points[0].y-10);
GraphRegion->LineTo(Points[0].x,Points[0].y);
}
but problem is, let sizeofArray is 100 then 100 triangles are generating but i need to show only one tiangle at a time. as when it generates the triangle no. 8 it should not show the previous 7 triangles. how can i solve that.
|
|
|
|
|
easy to do that is draw the background every time you draw the triangle to erase the previous one, then better one is draw the previous triangle again in background colour to erase.
you may need some delay in between the nth draw, otherwise human cannot see all those plots, if your machine is fast may be user can see only the last draw. Again,
If you are putting delay, your application will not be responsive, so you may use timers or threads to plot.
|
|
|
|
|
Are you using Invalidate () before painting the new one???
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 everybody,
I did solve how to create Flexgrid on dialog with your help.
But now I got another problem which is I do wanna use flexgrid in my code. Created a flex grid 6.0 object on cdialog (using resources)
I have a class CMyClass:CDialog and I create the dialog using Create(IdOfDialog)
Now as far as I know I do need a CMSFlexGrid pointer, smt like this:
CMSFlexGrid* grid = GetDlgItem(FlexGridID);
grid->Clear();
and my problem is I do not have CMSFlexGrid class dunno how to include, which class I should use.....
any idea?? thank you...
|
|
|
|
|
You may have a bit of web search.
Add variable of type control to the CDialog derived class, CMyClass using Class Wizard it takes care of getting the class for you.
I know you are using VS 6.0 from previous posts, so do the following,
1) right click the Flexgrid control on the Dialog resource then select Class Wizard.
2)In the Member Variables tab Select the appropriate project name, class name CMyClass, Select the Control ID FlexGridID, and click Add Variable (button)
3) Give the name for the member variable say m_grid. Select Category as Control. Where the Variable type is automatically populated to you by class wizard as CMSFlexGrid, then OK (it will confirm to add the CMSFlexGrid in to project,.. OK).
CMSFlexGrid is served to you, go ahead.
|
|
|
|
|
thanx man...
I did see "use wizard" tips on web pages but they all said use add variable wizard and I couldn't find such a thing till now...
ok one more thing... I do have a class but i did not associate it with dialog resource. How can I associate it with an existing class, cause Select Class listbox is all empty.....
thank you for your reply..
|
|
|
|
|
which class you are talking about now, previous post said you don't have CMSFlexGrid?
Specify which class which control.
|
|
|
|
|
I mean when I use class wizard it says this dialog is not associated with a class. But I did write an header file which inherits CDialog class CLangNWords : CDialog
I want to associate my dialog with my existing class but when I select Use Existing class there's nothing in listbox I can select.
It may because of I only write h file and there's no cpp file for it.
I am asking about how to associate these to. But doesn't seem too important right now I can write it again.
Thank you for your help.
|
|
|
|
|
Its better you create a MFC class derived from CDialog using class wizard at that time itself it associated with the dialog ID, then copy any necessary code from old class to this one.
|
|
|
|
|
How to set background color of menu in vc++
|
|
|
|
|
|
It is very difficult to understand.
Any other easier way to do it?
|
|
|
|
|
|
How to change menu background color in VC++
|
|
|
|