can anyone else verify that "NTK_SETPIXEL" correctly sets the requested colour?
e.g. from the NTK CORE documentation the following example in my own testing will not draw a red pixel, it will draw a black pixel: furthermore the return value of the call to NTK_SetPixel (whatever colour is requested) is always "4"
no problem with this function here - works as expected - plots dots using the right color. wilson
my code: function WndProc(hWnd, nMsg, nwParam, nlParam) static nCount := 0 local aPaint[PS_LENGTH], hDC, i, j Local hPen, hOldPen local nRed := RGB(255,0,0) local nGreen := RGB(0,255,0)
do case case nMsg == WM_LBUTTONDOWN // this is logically the 1st event we want to handle... nCount = 0 InvalidateRect(hWnd) return 0 // 0 means we processed the msg
case nMsg == WM_MOUSEMOVE // ... but it would be faster to put this first // (only matters on a _slow_ cpu) ... if C4W_And(nwParam, MOUSE_LBUTTON) != 0 .and. nCount < MAXPOINTS nCount++ aX[nCount] = c4w_LoWord(nlParam) aY[nCount] = c4w_HiWord(nlParam)
// leave a trail of red dots hDC = GetDC(hWnd) SetPixel(hDC, aX[nCount], aY[nCount], nRed) ReleaseDC(hWnd, hDC) endif return 0 // 0 means we processed the msg
case nMsg == WM_LBUTTONUP // ... then this is the last of the sequence, before... InvalidateRect(hWnd) return 0 // 0 means we processed the msg
case nMsg == WM_CTLCOLOR
case nMsg == WM_PAINT // ... now we join the dots in many ways! hDC = BeginPaint(hWnd, aPaint)
thank you very much xbasefan / Lucas: i will continue to explore what could be wrong in my own code then (i can circumvent the requirement fairly easily anyway)
the strange thing is the same section of code also uses the "NTK_POLYLINE" method and that is successfully drawing the correct colour
Hi there: I'm not a not a NTKCORE expert but I just replaced the winproc portion in my ..\contribs\c4W2ntk\Draw.Prg (joint-the-dots tutorial) with code from Wilson in the above. And no surprise - dots are properly drawn in red and when you release the mouse button the resulting shape is painted/flooded in green. So its Ok here. See attached. HTH -Chris
thanks very much for the help guys / confirming no issue with "NTK_SETPIXEL"
in my own code this issue just went away i.e. it now works correctly: i am in the middle of converting a fairly large old CLIPPER / CLIP4WIN application and cannot trace what exact change got this working but if i was to guess it would be tidy ups i made to the sub-classed procedure for the window where things were being drawn