Basically the LButtonDblClk function is using TextOut to put "Hello World" on the screen at the cursors position. The intention is to have the output accumulate on the screen and remain on the screen when resized, minimized or covered by another window etc...
I tried recreating the bitmap each time by changing the conditional statement at the beginning of LButtonDblClk if(!= NULL)delete the bitmap and just have the bitmap created each time the problem with that is the output does not accumulate on the screen.
I will try what you have here to see if my results can improve. Again this code is working, it just paints the background black and I am having trouble figuring out why that is, I have been messing with this same project for a while, maybe I'll try generating a new one and see what happens.
I am puzzled why this is so difficult to solve, although I have not written alot of code I have been doing it for a long time and the programmer has always had to take care of refreshing the screen and keeping the output(text, graphics etc..) on there theirself, at least I have. So what does a novice have to do to get the information or at least a clue to the solution. This cannot be stumping the programming gurus here in this forum, no way.
Make your painting function (i.e. ShowIt() ) accepting as argument, a CPaintDC instead of creating its own device context.
Never call directly your paint function (or other drawing code, use instead InvalidateRect and UpdateWindow to force the painting happen).
inside the button handler just set a flag (a member variable of the class) and use it to conditionally call your painting function inside OnPaint
void Ccom_testView::OnLButtonDblClk(UINT nFlags, CPoint point)
// don't put drawing stuff here
// the following calls force the window re-paint
CPaintDC dc(this); // device context for paintingif (m_showit)
void Ccom_testView::ShowIt(CPaintDC & dc)
// use the passed dc for drawing
Hope it eventually makes sense.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
Actually this makes alot of of sense, I have a better time making sense of things than I do communicating them in a way that makes sense, if that makes sense .
Seriously I think this is going to work for me once I get it implemented properly. I have always been week at passing perameters and therefore I avoid it and never think about the possibilities. I have alot to learn but I'm not going to give up.
Thank you very much for your help, I have learned a great deal just in the communications, that's asside from the code information.
Try [^vc++ in 21 days^] It will give you very good idea of mfc in 2 or 3 days. it's the shortest and most effective way known to me to learn about mfc. it may be a bit dated but the concepts are same and you don't need to spend big bucks to purchase it from nearby second hand bookshop or if you are really smart, you can find an ebook floating around somewhere in this cyberspace. (i know no one likes to spend money on buying fat and boring technical books)
I like to learn and books are good way to start... I accually own the predecessor to that book "C++ in 21 days" which I found to be quite good. I also found "MFC From the Ground Up" which is a great book if you are compiling using Visual C++ 6.0, it seems like things are done non-stansard though, you have to change alot things around to get them to compile and run from the VS2005 that I have now. It's really a good thing Microsoft made it difficult to go back to old version of compiler, cause I would have and not learned what I have. Man and I'll tell you from A novices perspective that upgrade has caused me more pain than I ever imagined I could get from writting my simple code. I think there is a new book out something like MFC from the ground up for VS2005, if that's the case I would really like to get a copy of that.
It's people like you and Pallini that make me come here when I need help. You folks are awesome keep up the good work and thank you.
Okay I am trying to lock CD drive (F: here) with the code shown. But DeviceIoControl is returning "error 87: Parameter not correct". Please someone help me. I cannot find out which parameter is incorrcet.
Yes hVolume is right value. GetLastError returns 0.
GENERIC_READ already has FILE_READ_ATTRIBUTES
Tried using 0 for File sharing but still DeviceIoControl gives error 87 parameter not correct
Thanks for replying, I appreciate it.