1. User32 And GDI32 Wrapper Feedback

Hello All,

So has anyone used my wrappers or taken a look at them? I spent a lot of time writing them. I was also thinking of making some more wrappers. Any bugs or anything that I may have missed in my current wrappers? I know these were kinda of large projects to take on, but I had fun doing them and I learned some more about the windows API and euphoria. So any feedback?

new topic     » topic index » view message » categorize

2. Re: User32 And GDI32 Wrapper Feedback

Lone_EverGreen_Ranger said...

Hello All,

So has anyone used my wrappers or taken a look at them? I spent a lot of time writing them. I was also thinking of making some more wrappers. Any bugs or anything that I may have missed in my current wrappers? I know these were kinda of large projects to take on, but I had fun doing them and I learned some more about the windows API and euphoria. So any feedback?

I have not tried, but I looked at your code and it looks excellent.
without meaning to downgrade your effort, it is typical of the style of wrappers I have seen in this site, so it should work well.
If something does not work, blame Bill Gates because of changes in the never ending series of Windows versions.

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

3. Re: User32 And GDI32 Wrapper Feedback

EUWX said...
Lone_EverGreen_Ranger said...

Hello All,

So has anyone used my wrappers or taken a look at them? I spent a lot of time writing them. I was also thinking of making some more wrappers. Any bugs or anything that I may have missed in my current wrappers? I know these were kinda of large projects to take on, but I had fun doing them and I learned some more about the windows API and euphoria. So any feedback?

I have not tried, but I looked at your code and it looks excellent.
without meaning to downgrade your effort, it is typical of the style of wrappers I have seen in this site, so it should work well.
If something does not work, blame Bill Gates because of changes in the never ending series of Windows versions.

Thanks for the feedback. That sounds great. I may start work on a kerenl32 wrapper, as that would add tremendously to my already previous wrappers. I also have ideas for other wrappers as well. Thanks again for the feedback.

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

4. Re: User32 And GDI32 Wrapper Feedback

Lone_EverGreen_Ranger said...

Hello All,

So has anyone used my wrappers or taken a look at them? I spent a lot of time writing them. I was also thinking of making some more wrappers. Any bugs or anything that I may have missed in my current wrappers? I know these were kinda of large projects to take on, but I had fun doing them and I learned some more about the windows API and euphoria. So any feedback?

I fast look at user32.ew and found something doubtfull here:

procedure WinHelp(atom handle,sequence str,atom ex,atom ex2) 
	 
	 c_proc(xWinHelp,{handle,str,ex,ex2}) 
	 
end procedure 

You can't pass a string to a WIN32 API function. Windows knows nothing about euphoria sequence. this should be something like that:

procedure WinHelp(atom handle,sequence str,atom ex,atom ex2) 
atom pStr 
         pStr = allocate_string(str)	 
	 c_proc(xWinHelp,{handle,pStr,ex,ex2}) 
         free(pStr) 
	 
end procedure 
 

By the way I did a lot of win32 API wrapping in past years. Take a look at: win32 api wrappers. Others did alot of it too, look at Judith Evans IDE. WIN32 API is huge. You would better improve and expand what as already been done than starting all over.

This is not to critisize, this work is usefull.

Jacques

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

5. Re: User32 And GDI32 Wrapper Feedback

coconut said...
Lone_EverGreen_Ranger said...

Hello All,

So has anyone used my wrappers or taken a look at them? I spent a lot of time writing them. I was also thinking of making some more wrappers. Any bugs or anything that I may have missed in my current wrappers? I know these were kinda of large projects to take on, but I had fun doing them and I learned some more about the windows API and euphoria. So any feedback?

I fast look at user32.ew and found something doubtfull here:

procedure WinHelp(atom handle,sequence str,atom ex,atom ex2) 
	 
	 c_proc(xWinHelp,{handle,str,ex,ex2}) 
	 
end procedure 

You can't pass a string to a WIN32 API function. Windows knows nothing about euphoria sequence. this should be something like that:

procedure WinHelp(atom handle,sequence str,atom ex,atom ex2) 
atom pStr 
         pStr = allocate_string(str)	 
	 c_proc(xWinHelp,{handle,pStr,ex,ex2}) 
         free(pStr) 
	 
end procedure 
 

By the way I did a lot of win32 API wrapping in past years. Take a look at: win32 api wrappers. Others did alot of it too, look at Judith Evans IDE. WIN32 API is huge. You would better improve and expand what as already been done than starting all over.

This is not to critisize, this work is usefull.

Jacques

Right, I understand. While starting from scratch may not have been the best approach, it was something rewarding to do. And as you noted, I will go back and fix anything I have missed.

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

6. Re: User32 And GDI32 Wrapper Feedback

coconut said...

You can't pass a string to a WIN32 API function. Windows knows nothing about euphoria sequence. this should be something like that:

procedure WinHelp(atom handle,sequence str,atom ex,atom ex2) 
atom pStr 
         pStr = allocate_string(str)	 
	 c_proc(xWinHelp,{handle,pStr,ex,ex2}) 
         free(pStr) 
	 
end procedure 

With euphoria 4.0, you can simplify this a bit so that you don't have to worry about memory management:

procedure WinHelp(atom handle,sequence str,atom ex,atom ex2) 
atom pStr 
	 c_proc(xWinHelp,{handle,allocate_string(str, 1),ex,ex2}) 
end procedure 

Adding the extra 1 to the allocate_string() call causes the pointer to be freed once there are no more euphoria references to it.

Matt

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

7. Re: User32 And GDI32 Wrapper Feedback

mattlewis said...
coconut said...

You can't pass a string to a WIN32 API function. Windows knows nothing about euphoria sequence. this should be something like that:

procedure WinHelp(atom handle,sequence str,atom ex,atom ex2) 
atom pStr 
         pStr = allocate_string(str)	 
	 c_proc(xWinHelp,{handle,pStr,ex,ex2}) 
         free(pStr) 
	 
end procedure 

With euphoria 4.0, you can simplify this a bit so that you don't have to worry about memory management:

procedure WinHelp(atom handle,sequence str,atom ex,atom ex2) 
atom pStr 
	 c_proc(xWinHelp,{handle,allocate_string(str, 1),ex,ex2}) 
end procedure 

Adding the extra 1 to the allocate_string() call causes the pointer to be freed once there are no more euphoria references to it.

Matt

Thanks for the tip, Matt. Although I had already gone and fixed things using the old way. Oh well, no biggie, I'll keep this in mind for next time.

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

8. Re: User32 And GDI32 Wrapper Feedback

mattlewis said...

With euphoria 4.0, you can simplify this a bit so that you don't have to worry about memory management:

procedure WinHelp(atom handle,sequence str,atom ex,atom ex2) 
atom pStr 
	 c_proc(xWinHelp,{handle,allocate_string(str, 1),ex,ex2}) 
end procedure 

Adding the extra 1 to the allocate_string() call causes the pointer to be freed once there are no more euphoria references to it.

I'm really loving this feature, by the way. Here's a neat trick for passing optional "text" parameters that also accept NULL. I used this a lot when wrapping Newt.

namespace newt 
public procedure PushHelpLine( object text = NULL ) 
    if sequence( text ) then text = allocate_string( text, 1 ) end if 
    c_proc( x_newtPushHelpLine, {text} ) 
end procedure 

So if you call newt:PushHelpLine() with no parameters, it passes NULL automatically, if you pass an atom (assumed to be a string pointer) it passes it through directly, and if you pass a sequence (a text string) it is allocated into memory, flagged for collection, and then passed to the function.

You could also pre-allocate your strings as constant pointers and let Euphoria clean them up when it's done, although I can't see a direct advantage to this one way or the other (unless you're using a lot of strings on a really really slow machine).

constant helpText = allocate_string( "This is my help text", 1 ) 
 
newt:Init(1) 
newt:PushHelpLine( helpText ) 
newt:WaitForKey() 
newt:Finished() 
 
-- helpText will be freed automatically when we're done 

-Greg

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

9. Re: User32 And GDI32 Wrapper Feedback

ghaberek said...

You could also pre-allocate your strings as constant pointers and let Euphoria clean them up when it's done, although I can't see a direct advantage to this one way or the other (unless you're using a lot of strings on a really really slow machine).

constant helpText = allocate_string( "This is my help text", 1 ) 
 
newt:Init(1) 
newt:PushHelpLine( helpText ) 
newt:WaitForKey() 
newt:Finished() 
 
-- helpText will be freed automatically when we're done 

Adding the parameter to set the pointers to auto-cleanup won't actually do anything in this case. Those constants don't get dereferenced at the end. They're simply released when all of your program's memory goes away. For a time, we tried dereferencing everything when a program exited, but it caused problems.

Matt

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

10. Re: User32 And GDI32 Wrapper Feedback

mattlewis said...

Adding the parameter to set the pointers to auto-cleanup won't actually do anything in this case. Those constants don't get dereferenced at the end. They're simply released when all of your program's memory goes away. For a time, we tried dereferencing everything when a program exited, but it caused problems.

So in that case I don't need to add the cleanup parameter? Good to know. I guess it always kind of worked that way, didn't it? getlost

-Greg

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

Search



Quick Links

User menu

Not signed in.

Misc Menu