Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MFC create window

Status
Not open for further replies.

ahsan786

Technical User
Feb 4, 2004
12
HK
Hi,
This is my first message on this forum. so greetings to all of you.

Below the function i am facing problems with. i call this function with a checkbox. when the window is created the information displayed on it appears fine but another window is overlapped on it the contents of the overlapped part of the window disappears. i know i should put this in onpaint() method but is there any other smarter way to keep the contents of the window as they are. i am sure there must be, because if you can create a window like this (shown below) there must be a way to keep its contents too. even when i minimize the new window created and then reopen it the contents of the window disappear. i know what the problem is - i.e. i need to repaint it. i am looking for a smart way to tell the windows to retain the contents of the newely created window inside the function specified below (a self contained function). plz help!!! thank you :)

void showMatchedFingers(tPointXY *showFing, int num_point){ //for display of query
int size=5,p;
CFrameWnd *pCreateWind = new CFrameWnd;
pCreateWind->Create(NULL, "Template", WS_OVERLAPPEDWINDOW,CRect(5,170,540,540) );
pCreateWind->ShowWindow(1);
CPaintDC dc(pCreateWind);
for(p=0;p<num_point;p++){
CPoint point;
point.x = (showFing+p)->x; point.y=(showFing+p)->y;
CBrush brush(RGB(0,255,255));
CBrush *pOldBrush = dc.SelectObject(&brush);
dc.Ellipse(point.x-size/2,point.y-size/2,point.x+size/2,point.y+size/2);
dc.SelectObject(pOldBrush);
}//number of query points
}
 
You you minimize/maximmize a window OnPaint is eventually called.

But if you wanna catch some other message (I would not recomend) you can watch what messages your window receives with Spy++ from Visual Studio and then capture those window messages.

I had made i heave graphical app on Visual C++, and I advice you to put the painting code in OnPaint/OnDraw.

Watch you, do not create any brushs, pens etc inside these functions, make members of the view class better and manouver them in ctor/dtor . Or else the gdi memory will soon be exceeded, because of the fact that OnPaint/OnDraw are so ofthe close.

BTW, your last line should be something like
DeleteObject( dc.SelectObject(pOldBrush));

HTH,


s-)

Blessed is he who in the name of justice and goodwill, sheperds the weak through the valley of darkness...
 
Hey thanx a lot IonelBurtan for your reply!!!
but my concern is that .... the show graphic info is really relatively a small part of my project. i just want the user to see the graphics postioned in the matrix.

And the technical difficulty is .... the graphics information (showFing - in the above function) is lost once the function that calls the ShowMatchedFingers is finished i.e. the pointers of the info are deleted at the end of the function.
do you have any other recommendations of showing the graphical info??? (e.g. creating a file...etc)
i am sorry i am very new to MFC :)
cheerz
your help will be greatly appreciated. i juss wanna show the info on the window.
 
There is no way of just painting once the contents of a window (as you do now) and not caring about refreshing/ overlapping windows.

The only way a window restores the part of the window that is overlapped by another window is by what you tell it to do in the OnPaint/OnDraw.

Creating a file ... won't help either. Windows just sends you the WM_PAINT message, you catch it with OnDraw/OnPaint and you have to repaint the window (or a part of it).

You do not have to care how the repaint is actually done, your window won't flicker & stuff. This things are hide by windows.

This is how it works, is easy, and if you stick to this plan you will have no problem.

I hope this gives you an idea of how the things are moving around,





s-)

Blessed is he who in the name of justice and goodwill, sheperds the weak through the valley of darkness...
 
hey burtan ... thank you for your reply and time... cheerz
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top