1. Win32Lib Error Fixes

Hello All,

Today I began using the latest Win32Lib for Nexus Radio and I found two errors. 

Look for the procedure setScrollRange and find: 
ctrl_Range[ id ][1] = { min, max }


Replace it with:
ctrl_Range[ id ][1] = { min, max }
ctrl_Range[ id ][2] = { min, max }


Also replace the DefProcessing function with the follow code:

-----------------------------------------------------------------------------
function DefProcessing(integer id, integer pSource, atom hWnd, atom iMsg, atom
wParam, atom lParam)
-----------------------------------------------------------------------------
atom lResult
lResult = 0

    if (id = 0) or (pSource = kMainMsg) then
        lResult = w32Func( xDefWindowProc, { hWnd, iMsg, wParam, lParam } )
    else
lResult = w32Func( xCallWindowProc, { ctrl_Function[id], hWnd, iMsg,
        wParam,
lParam } )
    end if

    if lResult = 0
      then
       return 0
        else
      return lResult
    end if
end function
r_defaultProcessing = routine_id("DefProcessing")


~ CBouzy

"If you do what you have always done, you will get what you always got."

new topic     » topic index » view message » categorize

2. Re: Win32Lib Error Fixes

C Bouzy wrote:
> 
> Hello All,
> 
> Today I began using the latest Win32Lib for Nexus Radio and I found two
> errors.
> 
> 
> Look for the procedure setScrollRange and find: 
> }}}
<eucode>
> ctrl_Range[ id ][1] = { min, max }
> </eucode>
{{{

> 
> Replace it with:
> }}}
<eucode>
> ctrl_Range[ id ][1] = { min, max }
> ctrl_Range[ id ][2] = { min, max }
> </eucode>
{{{

> 

Are you sure?
First, there are several instances of the statment in the routine. Which one is
supposed to be completed?
Second, ctrl_Range[id] holds either:
* for Window controls, a pair of ranges, for H and V scroll bars;
* For other usable controls, a single range, they have only one to monitor.

I checked further, and I think the error is in getScrollRange rather, which
should read as
global function getScrollRange( object id )

    -- Get the allowable range for a scroll bar
    atom lWhichBar

    if sequence(id) then
        lWhichBar = w32iff(find(id[2], {SB_VERT,SB_HORZ}), id[2], SB_VERT)
        id = id[1]
    else
        lWhichBar = SB_VERT
    end if
-- changed part
    if ctrl_Family[id]=WINDOW then
        if lWhichBar = SB_HORZ then
            return ctrl_Range[id][2]
        else
            return ctrl_Range[id][1]
        end if
    else
        return ctrl_Range[id][1]
    end if
end function


See if this isn't a better fix, I expect it is.

> Also replace the DefProcessing function with the follow code:
> 
> }}}
<eucode>
> -----------------------------------------------------------------------------
> function DefProcessing(integer id, integer pSource, atom hWnd, atom iMsg, atom
> wParam, atom
> lParam)
> -----------------------------------------------------------------------------
> atom lResult
> lResult = 0
> 
>     if (id = 0) or (pSource = kMainMsg) then
>         lResult = w32Func( xDefWindowProc, { hWnd, iMsg, wParam, lParam } )
>     else
>         lResult = w32Func( xCallWindowProc, { ctrl_Function[id], hWnd, iMsg,
>         wParam,
> lParam } )
>     end if
> 
>     if lResult = 0
>       then
>        return 0
>         else
>       return lResult
>     end if
> end function
> r_defaultProcessing = routine_id("DefProcessing")
> </eucode>
{{{

> 

The second chunk of code looks like an  uselessly complex way to return lResult.
Does it make a difference?
I added the lResult=0 initialisation.

CChris

> ~ CBouzy
> 
> "If you do what you have always done, you will get what you always got."

new topic     » goto parent     » topic index » view message » categorize

3. Re: Win32Lib Error Fixes

Hello CChris,

I have been using Win32Lib since 2001 for all of my apps :) The error is in
setScrollRange, just replace all 3 instances.

In regards to DefProcessing, the code I posted might seem redundant but it is
not. In some cases when running large complex Win32Lib apps on some machines you
will get a weird error, that simple piece of code fixes it.

~ C Bouzy

"If you do what you have always done, you will get what you always got."

new topic     » goto parent     » topic index » view message » categorize

4. Re: Win32Lib Error Fixes

C Bouzy wrote:
> 
> Hello CChris,
> 
> I have been using Win32Lib since 2001 for all of my apps :) The error is in
> setScrollRange, just replace all 3 instances.
> 

We are, I think, both right.
getScrollRange() checks whether the bar is horizontal or vertical, and returns
item 1 or 2 in ctrl_Range[id] accordingly. Since a progressbar or somesuch may be
either horizontal or vertical, both fields should be ranges, and your fix works.

However, all controls have one range to take care of, except Window. So, leaving
setScrollRange() alone and changing getScrollRange() should work just as well.

I prefer the latter as more consistent.
Could you tell me whether that way works for you?

CChris

> In regards to DefProcessing, the code I posted might seem redundant but it is
> not. In some cases when running large complex Win32Lib apps on some machines
> you will get a weird error, that simple piece of code fixes it.
> 

Ok, but is the error simply lResult being uninitialised, or lResult holding
something unexpected? Just curious here.

CChris

> ~ C Bouzy
> 
> "If you do what you have always done, you will get what you always got."

new topic     » goto parent     » topic index » view message » categorize

5. Re: Win32Lib Error Fixes

Hello CChris,

Actually it wouldn't hurt to put it in both places. In regards to the
Defprocessing error, lResult will return something unexpected or nothing at all.

~C Bouzy

"If you do what you have always done, you will get what you always got."

new topic     » goto parent     » topic index » view message » categorize

6. Re: Win32Lib Error Fixes

C Bouzy wrote:
> 
> Hello CChris,
> 
> Actually it wouldn't hurt to put it in both places. In regards to the
> Defprocessing
> error, lResult will return something unexpected or nothing at all.
> 
> ~C Bouzy
> 
> "If you do what you have always done, you will get what you always got."

It won't hurt, just perhaps a little puzzling for any future maintainer.
As for DefProcessing, then i'll put your code with a comment about the condition
you experienced. Doesn't this result from an OS thread switch, by any chance?

CChris

new topic     » goto parent     » topic index » view message » categorize

7. Re: Win32Lib Error Fixes

Hello CChris,

I wish I could tell you what causes the error, but I have never been able to
reproduce the error on-demand. It just happens randomly and only with certain
types of apps.

~C Bouzy

"If you do what you have always done, you will get what you always got."

new topic     » goto parent     » topic index » view message » categorize

8. Re: Win32Lib Error Fixes

C Bouzy wrote:
> 
> Hello CChris,
> 
> I wish I could tell you what causes the error, but I have never been able to
> reproduce the error on-demand. It just happens randomly and only with certain
> types of apps.
> 
> ~C Bouzy
> 
> "If you do what you have always done, you will get what you always got."

Ok; this confirms my gut feelings about a race condition. At any rate I have
include the code you posted, with a note for any future maintainer (or me 12
month from now).

CChris

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu