RE: Win32lib (simple app) not working #2

new topic     » goto parent     » topic index » view thread      » older message » newer message

From: euman at bellsouth.net [mailto:euman at bellsouth.net]


> Well, I must agree Win32lib 59.1 is pretty useless.

Really?  With whom are you agreeing?  Actually, it loooks like the problem
you found has been there since v58.0.  It's a fairly obscure and not very
useful (to 99.9% of win32lib users) feature of the library.

> This doesn't work either because setWinMsgHandler()
> has a bug in it, ( "id" hasn't been declared)

Yes, setWinMsgHandler() should start:

global procedure setWinMsgHandler(object pId, object pMsg, integer pRoutine)
    integer lPosn
    integer id
    atom lMsg

    if not sequence(pId) then
        pId = {pId}
    end if


Also, you can't trap WM_CREATE this way, because you're setting the handler
after you've already created the window.  You should trap w32HActivate.
Really, there's no reason to trap WM_CREATE and WM_DESTROY this way, since
they're not going to be speed critical like WM_PAINT.  If you fix the
win32lib bug above, and change your code to what I have below, it works
fine:


function MainWnd_Proc( integer pSource, atom hWnd, atom iMsg, atom wParam,
atom lParam )
   
	hdc = w32Func( xBeginPaint, { hWnd, ps } )   
	junk = w32Func( xBitBlt, {hdc, 0, 0, vxScreen, vyScreen, memdc, 0,
0, SRCCOPY} )     
	w32Proc( xEndPaint, { hWnd, ps } )    

   return {0}
end function
setWinMsgHandler(MainWin, {WM_PAINT}, routine_id("MainWnd_Proc"))

procedure on_destroy( integer self, atom event, sequence params )
      junk = w32Func( xReleaseDC, {0, hdc} )
end procedure
setHandler( MainWin, w32HDestroy, routine_id("on_destroy"))

procedure on_activate( integer self, atom event, sequence params )
	atom hWnd
	hWnd = getHandle(self)
    hdc = w32Func( xGetDC, {hWnd} )
    memdc = w32Func( xCreateCompatibleDC, {hdc} )
    hbit = w32Func( xCreateCompatibleBitmap, { hdc, vxScreen, vyScreen } )
    junk = w32Func( xSelectObject, {memdc, hbit} ) 
    hbrush = w32Func( xGetStockObject, {WHITE_BRUSH}) 
    junk = w32Func( xSelectObject, {memdc, hbrush} ) 
        
    junk = w32Func( xPatBlt, {memdc, 0, 0, vxScreen, vyScreen, PATCOPY}) 


    setScrollRange ( {MainWin, SB_HORZ}, 1, vxScreen )
    setScrollRange ( {MainWin, SB_VERT}, 1, vyScreen )


    setPenColor( MainWin, Green )
    junk = w32Func(xRectangle, {memdc, 10, 10, 620, 460})
    junk = w32Func( xReleaseDC, {hWnd, hdc} )
    junk = w32Func( xInvalidateRect, {hWnd, NULL, 0} )
   
end procedure
setHandler( MainWin, w32HActivate, routine_id("on_activate"))

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu