Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - landings

Pages: [1]
1
Sorry my friend, it came cross my mind that here is a more specialized forum after my post on stack overflow. I checked both sites and didn't mean to waste anyone's time.
Actually I am not skilled in threading. This code is just a beginner's inspiration. I thought it would work, but after all I have a lot to learn. Thank you very much.

2
I'm writing a SFML test application with MFC. The following code runs inside an infinite loop in another thread started by AfxBeginThread() function. (Because I want to use SFML like it's in a pure WinAPI application :-\)

// SFML Window and View were initialized using CView's HWND
// Use SFML to draw
sf::Color back(255, 255, 0); // a yellow background
_psfwnd->clear(back);
_psfwnd->display();

// Then use MFC GDI functions to draw
CWnd* pwnd;
pwnd = CWnd::FromHandle(_psfwnd->getSystemHandle()); // It seems that the HWND is valid
CPaintDC dc(pwnd);
CRect r(10, 10, 100, 100);
CBrush b(0xFF000000);
dc.FillRect(&r, &b);    // draw a black rectangle

The result is a white background with a black rectangle. It seems that SFML draws nothing but MFC does.

Same code above. Now I put it into a MFC command handler (so the above code draws one frame when I click a button once).

This time the window background is yellow and MFC black rectangle is gone.

Now I am quite confused. I have two questions:

Why SFML doesn't draw the first time? It's because of threading, or initialization?

Why MFC doesn't draw when SFML does?

Pages: [1]
anything