1. Win32lib tweak

Hi EU people :) Apologies, not really sure who is maintaining win32lib or where I should be posting this but...

Not a big issue but I think the setTCVisible() procedure needs a slight tweak

procedure setTCVisible(integer TC_id,integer flag) 
    integer tab_id 
 
    if ctrl_Type[TC_id] = TabControl then 
        tab_id = getTabItem(TC_id) 
    end if 
    call_proc(r_setControlVisible,{ctrl_Group[tab_id],flag}) 
end procedure 

I'm unsure why the call_proc() would be outside of the if ctrl_Type[TC_id] = TabControl block as it uses tab_id for a parameter which would be unassigned if the test failed. It's also worth pointing out that this error has never occurred because test is itself redundant anyway as the only 2 source lines that call the procedure do it as a result of this same check so it will never fail.

getTabItem() returns 0 if there is no currently selected tab item in the control, so it is quite possible to get an OOB subscript crash just by creating a tab control and calling setVisible() on it.

I would suggest the following:

procedure setTCVisible(integer TC_id,integer flag) 
    integer tab_id 
 
    tab_id = getTabItem(TC_id) 
    if tab_id then 
	call_proc(r_setControlVisible,{ctrl_Group[tab_id],flag}) 
    end if 
end procedure 

Arguably there is no real need to call setVisible() on a tab control before it has an active tab item, but I don't think the lib should be crashing with an OOB subscript just because of that and it's cleaner code anyway.

new topic     » topic index » view message » categorize

2. Re: Win32lib tweak

Graeme said...

not really sure who is maintaining win32lib or where I should be posting this but...

I don't think anyone is actively maintaining it right now. Anyone who would like to volunteer could be given access to that project on SourceForge.

Graeme said...

I'm unsure why the call_proc() would be outside of the if ctrl_Type[TC_id] = TabControl block as it uses tab_id for a parameter which would be unassigned if the test failed. It's also worth pointing out that this error has never occurred because test is itself redundant anyway as the only 2 source lines that call the procedure do it as a result of this same check so it will never fail.

getTabItem() returns 0 if there is no currently selected tab item in the control, so it is quite possible to get an OOB subscript crash just by creating a tab control and calling setVisible() on it.

Arguably there is no real need to call setVisible() on a tab control before it has an active tab item, but I don't think the lib should be crashing with an OOB subscript just because of that and it's cleaner code anyway.

I would say you're correct that if ctrl_Type[TC_id] were to ever not be TabControl the whole thing would just crash because tab_id would have no value. That's a good catch!

Win32Lib is one of the oldest and largest Euphoria projects and I'm sure the deeper you dig, the more oddities like this you'll find. There's probably quite a lot of code that can be cut down.

Whenever we do get Euphoria 4.2 shipped, Win32Lib is going to need a major overhaul to support memstructs, which would then make it 64-bit compatible. Volunteers are always welcome!

-Greg

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

3. Re: Win32lib tweak

P.S. I edited your post to use <eucode> tags to format your code. You can also use {{{ for blocks of fixed-width text and ## for inline fixed-width text. If you click "Edit" on your post you'll see the changes I made. See CreoleHelp for more details.

-Greg

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

4. Re: Win32lib tweak

Hi

I wouldn't call myself a maintainer, but I did do a few tweaks to make it Eu 4.1 compatible. It is linked here.

Anybody is more than welcome to do whatever they like with it, it's certainly not mine. There are a few offshoots of this library, and perhaps they should be all brought together.

Even though I mostly use and play with Phix now, eu is still the 'fire up' program for .exw files, and win32lib still fires up beautifully.

I have also a worked on a (mostly) working Phix win32lib, but as always I get distracted by other stuff, and dip back into it every now and again.

The wiki would be a good place to put pointers and links to these libs, but it's quite hard to navigate and find stuff on in a logical way.

Cheers

Chris

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

5. Re: Win32lib tweak

ghaberek said...

P.S. I edited your post to use <eucode> tags to format your code. You can also use {{{ for blocks of fixed-width text and ## for inline fixed-width text. If you click "Edit" on your post you'll see the changes I made. See CreoleHelp for more details.

-Greg

Thanks Greg, yes that is much clearer.

ghaberek said...

Win32Lib is going to need a major overhaul to support memstructs, which would then make it 64-bit compatible. Volunteers are always welcome!

-Greg

It would be nice to have that kind of spare time. Over the years I have ended up wading through the code of various win32lib versions to tweak bits and pieces that wouldn't do the right thing for me. If I'm using it I will probably end up contributing a few small edits occasionally.

Years ago I made a scaled down version that used the same names and handled a small set of basic controls with a lot less overhead. It worked ok as a drop in replacement for small apps that didn't need anything fancy. I think it's in the corner of a dusty folder somewhere under a teetering pile of other unfinished projects.

ChrisB said...

Hi

I wouldn't call myself a maintainer, but I did do a few tweaks to make it Eu 4.1 compatible. It is linked here.

Anybody is more than welcome to do whatever they like with it, it's certainly not mine. There are a few offshoots of this library, and perhaps they should be all brought together.

Even though I mostly use and play with Phix now, eu is still the 'fire up' program for .exw files, and win32lib still fires up beautifully.

I have also a worked on a (mostly) working Phix win32lib, but as always I get distracted by other stuff, and dip back into it every now and again.

The wiki would be a good place to put pointers and links to these libs, but it's quite hard to navigate and find stuff on in a logical way.

Cheers

Chris

Cool. Yes that's the version I currently have. I have just been (finally) getting an EU4+ installation working on my win10 machine. I have only ever really used <= 3.1.1 on <= winXP before that. Have never really checked out Phix, but I was always a fan of Pete's work back in the day, so I would expect it's a good thing.

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

6. Re: Win32lib tweak

Phix has structs and objects, so rather than modifying Win32lib, it might be easier to do a complete re-write. Likely to be easier to use, as well. The only problem is the scale of the project. There are no longer enough programmers to get it done, and certainly not enough users to test it all.

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

7. Re: Win32lib tweak

irv said...

rather than modifying Win32lib, it might be easier to do a complete re-write.

Way back when, I was originally a win32lib user. I abandoned win32lib for arwen because the latter was maintainable/debuggable, the former not.
I abandoned arwen for IUP (aka pGUI) because the latter was portable, both 32/64 bit and win/lnx (the latter not without its troubles) and maybe even the browser...
Just sayin, there is only so long a sane person should cling onto a broken, unmaintained, and unportable old familiar friend.

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

8. Re: Win32lib tweak

irv said...

Phix has structs and objects, so rather than modifying Win32lib, it might be easier to do a complete re-write. Likely to be easier to use, as well. The only problem is the scale of the project. There are no longer enough programmers to get it done, and certainly not enough users to test it all.

Win32lib is a pretty big library. Doing a complete re-write would be a huge task. Though not impossible. I used it heavily back in the day. It proved to be pretty reliable. Granted there are some issues when using it with Eu4 and I assume Phix. Perhaps Win32lib with struct support would be handy. There is also WxWidgets. Regardless a complete re-write of win32lib would be a huge task.

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

9. Re: Win32lib tweak

All good Graeme. I should be maintaining the library as I've done at least half the work in it.

I'll take a look at what I can do.

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

Search



Quick Links

User menu

Not signed in.

Misc Menu