InvlidateRect() Doesn't Allow to Display My Child Screen in MFC?
Hi,
I'm Getting Real-time Data and Display the image in main screen. Using the InvalidateRect() method, I'm refresh the main screen(Image Area only - 768 * 256) continuously.
Now I opened a child screen . It was display the back side of main screen.
If i press ALT key means it appear in front.
With out Alt key press, how can I display the child screen?
Re: InvlidateRect() Doesn't Allow to Display My Child Screen in MFC?
Okay, I'll clear you.
First of all, your app breaks all thinkable rules of GUI app. You think you draw data continuously, but in fact you draw without calling EndPaint, and this way you never let your window be aware of proper WM_PAINT handling. This causes WM_PAINT be sent again and again, which in it's turn results in 100% CPU load. You GetDC and never release it. You do calculations (potentially heavy ones in future) in WM_PAINT handler. This is not how decent GUI app behaves. Due to the WM_PAINT effect your app never makes it to redraw Client and Exit buttons once the window gets moved. Summarizing, your app is all mess. You really need to find some good book on Windows programming and work it through, from cover to cover. Besides, I would definitely recommend you to read something on good C programming styles.
I've made some more changes to demonstrate how some of the issues could be solved by moving data processing to a worker thread. Please see the attachment.
Re: InvlidateRect() Doesn't Allow to Display My Child Screen in MFC?
Now I cleared Little more, but not fully. Sure I will study the Window Programming books.
Now, I'm useing the SetWindowPos method. It worked.
I will release my GetDC like you tell in the above example.
But, I don't know its working correct or not in real time data capture & plot (B'cos of my card Problem - Getting real time data) .
I will check and tell you the feed back.
Re: InvlidateRect() Doesn't Allow to Display My Child Screen in MFC?
Originally Posted by Igor Vartanov
you need to build and run my last project.
I run it. Its working good. You are indexing and plot the every line data which contains 1000 pixels (width of data) per line.
So 256 line data, every line contains 1000 pixels.
Indexing data like:
Code:
for (int y = 0; y < ClientHeight; y++)
{
Index = y * NumberOfBytesPerRow; // 0,999,1998
for (int x = 0; x < ClientWidth; x++)
{
ImageData[Index] = (y + add) % ClientHeight;
Index = Index + 1;
}
}
But in my project the ploting area is same. 1000*256 or 768*256.
But I'm plot the data vertically. I'm getting 768 line data & every line contain 256 pixels.
sample indexing data like:
Code:
for (int y = 0; y < width; y = y + 1)
{
iIndex = y + (width * height) - width; //getting every line index vertically
for (int x = 0; x < height ; x = x + 1)
{
OfflineImageData[iIndex] = (byte)(*(pBitmapData + iIndex));
OfflineData[y][x] = OfflineImageData[iIndex];
iIndex = iIndex - width; //Indexing vertically
}
}
It's kinda number of bytes per column, but number of bytes per row still remains
NumberOfBytesPerRow = (ClientWidth + 3) & 0xFFFFFFFC; // Your code
And please note that my sample was not about plotting data, but it's about organizing interaction between your worker thread and main GUI dialog. I don't care about how you plot your data, this business is all yours. What matters now is how you invoke your picture painting and handle device context.
Last edited by Igor Vartanov; June 26th, 2013 at 04:40 PM.
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.