Hi there. I am studying some Visual C++ MFC programming just to understand some GUI programming in Windows.
Mind you that my environment is Visual Studio 6, and I'm following the book "Learn Visual C++ Programming in 21 Days".
(I am following too a book on C++ and one on Direct-X, the first just to make the transition from Java, and the latter because I am interested in Direct X).
Anyway, my problem (was) this:
In one of the examples wanted to trace a white line instead of a black one. First I came across (nice MSDN documentation) the DeviceContext.GetStockObject() function, and I tried to pass it to DeviceContext.SelectObject()...
I tried to do this:
This did not work, even if it looked as a legal function: the value returned was different than null (signal that the White Pen was loaded) and I think no exception was thrown since the program continued to go on without problems (mind you, I come from a Java background).Code:dc.SelectObject((CPen *)(dc.SelectStockObject(WHITE_PEN))
After some research I was convinced to create a white pen by myself and to use it:
This works.Code:CPen zPen(PS_SOLID, 1, RGB(255, 255, 255)); dc.SelectObject(&zPen);
Why?
Is the GetStockObject an obsolete function? Does it work in Windows 2000? Did I make a mess out of pointers? (I used some C a long long long time ago... that is 2 years ago, always hated all the pointer stuff )
Thankyou at least for reading!