1. Win32Lib bug in registerControl()

So I've been playing around with custom controls, and I'm pretty sure I found bug. The documentation for registerControl() states:

classType
return the control type the library should consider your control to belong to. Default is -1. For instance, return RichEdit if your contol is to be sent RichEdit-specific messages.

However, in the code (around line 26296), there is this:

26296    lClass = call_func(pRID[kCRID_Control], {"classType", -1}) 
26297    classAlias[lControl] = lClass 
26298    classType[lControl] = classType[lClass] 

If the "Control" routine returns the default -1 as stated in the docs, the application crashes since it is trying to use lClass as an index into classType.

C:\EUPHORIA\Win32Lib\Include\win32lib.ew:26298 in function registerControl() 
subscript value -1 is out of bounds, reading from a sequence of length 62 

And I'm honestly not too sure how to go about fixing it. getlost

-Greg

new topic     » topic index » view message » categorize

2. Re: Win32Lib bug in registerControl()

ghaberek said...

And I'm honestly not too sure how to go about fixing it. getlost

Ok, that's my problem. I'll fix it tonight (in about 6-8 hours from now).

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

3. Re: Win32Lib bug in registerControl()

DerekParnell said...

Ok, that's my problem. I'll fix it tonight (in about 6-8 hours from now).

Poking around, I thought I could just add an if statement like this:

if lClass != -1 then 
    classType[lControl] = classType[lClass] 
end if 

...then things broke even worse later on. getlost

C:\EUPHORIA\Win32Lib\Include\win32lib.ew:26314 in function registerControl() 
subscript value -1 is out of bounds, reading from a sequence of length 62 

Which is this line:

26314    classKbdInput[lControl] = call_func(pRID[kCRID_Control], {"classKbdInput", classKbdInput[lClass]}) 

-Greg

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

4. Re: Win32Lib bug in registerControl()

To recap on what I was doing (and perhaps provide some context on fixing the issue), I'm trying to create a custom Window class. One thing I noticed almost immediately is that I'm not receiving any thing into the "Process" routine, and I believe it's because I'm passing Window back for "controlType".

The question is, should I be receiving those messages using the Window type, or should I be passing back -1 for "controlType" to define my control as a "new" type? You can download what I've started on here:

Download: w32custom.zip (2 KB)

-Greg

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

5. Re: Win32Lib bug in registerControl()

ghaberek said...

So I've been playing around with custom controls, and I'm pretty sure I found bug. The documentation for registerControl() states:

classType
return the control type the library should consider your control to belong to. Default is -1. For instance, return RichEdit if your contol is to be sent RichEdit-specific messages.

However, in the code (around line 26296), there is this:

26296    lClass = call_func(pRID[kCRID_Control], {"classType", -1}) 
26297    classAlias[lControl] = lClass 
26298    classType[lControl] = classType[lClass] 

If the "Control" routine returns the default -1 as stated in the docs, the application crashes since it is trying to use lClass as an index into classType.

C:\EUPHORIA\Win32Lib\Include\win32lib.ew:26298 in function registerControl() 
subscript value -1 is out of bounds, reading from a sequence of length 62 

And I'm honestly not too sure how to go about fixing it. getlost

-Greg

The fix is simple. The documentation is wrong. It should read ...

classType
This is mandatory. Return the control type the library should consider your control to belong to. For instance, return RichEdit if your contol is to be sent RichEdit-specific messages.

In other words, your new control must return a valid class type. If your new control's registration routine fails to do that, your application will crash.

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

6. Re: Win32Lib bug in registerControl()

ghaberek said...

To recap on what I was doing (and perhaps provide some context on fixing the issue), I'm trying to create a custom Window class. One thing I noticed almost immediately is that I'm not receiving any thing into the "Process" routine, and I believe it's because I'm passing Window back for "controlType".

Yep, this is a bug. There is a one-line change required in win32lib.ew.

Find the routine called "MessageProcessor" and look for the line ...

lTemp = ctrl_Type[id] 

and change it to ...

lTemp = ctrl_ActualClass[id] 
new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu