# App#process\_message

**URL:** <https://www.ruby-forum.com/t/app-process-message/138676>\
**Category:** wxRuby\
**Created:** [May 26, 2008, 4:47pm UTC](https://www.ruby-forum.com/t/app-process-message/138676 "2008-05-26T16:47:40Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![marlesson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/779978/32.png) [@marlesson](https://www.ruby-forum.com/u/marlesson)\
**Post date:** [May 26, 2008, 4:47pm UTC](https://www.ruby-forum.com/t/app-process-message/138676/1 "2008-05-26T16:47:40Z")

</div>

how can rewrite the App # process\_message to treat the messages of the  
system?

wxruby

---

<div class="post-metadata">

**Author:** ![marlesson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/779978/32.png) [@marlesson](https://www.ruby-forum.com/u/marlesson)\
**Post date:** [May 27, 2008, 9:57pm UTC](https://www.ruby-forum.com/t/app-process-message/138676/2 "2008-05-27T21:57:07Z")

</div>

Marlesson Santana wrote:

> how can rewrite the App # process\_message to treat the messages of the  
> system?  
> Could you explain a bit more about what you want. I read the wxWidgets  
> documentation for this method but I don’t know what a “Windows message”  
> is, or how you get one in Windows. We can’t wrap the method if we don’t  
> know what argument type it should take in Ruby.

alex

---

<div class="post-metadata">

**Author:** ![marlesson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/779978/32.png) [@marlesson](https://www.ruby-forum.com/u/marlesson)\
**Post date:** [May 31, 2008, 3:53pm UTC](https://www.ruby-forum.com/t/app-process-message/138676/3 "2008-05-31T15:53:45Z")

</div>

Alex F. wrote:

> Marlesson Santana wrote:
> 
> > how can rewrite the App # process\_message to treat the messages of the  
> > system?  
> > Could you explain a bit more about what you want. I read the wxWidgets  
> > documentation for this method but I don’t know what a “Windows message”  
> > is, or how you get one in Windows. We can’t wrap the method if we don’t  
> > know what argument type it should take in Ruby.
> 
> alex

Hi alex,

Our problem consist in communicate with an external device which connect  
through the ethernet port. we need to receive the messages sent by it so  
we can handle.

(those messages are events like keydown, keyup, mouse movement and etc.)

hope u can give me any direction.

gabriel

(ps: marlesson is my cowork)

---

<div class="post-metadata">

**Author:** ![marlesson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/779978/32.png) [@marlesson](https://www.ruby-forum.com/u/marlesson)\
**Post date:** [June 2, 2008, 1:37pm UTC](https://www.ruby-forum.com/t/app-process-message/138676/4 "2008-06-02T13:37:00Z")

</div>

Gabriel Rios wrote:

> Hi alex,
> 
> Our problem consist in communicate with an external device which connect  
> through the ethernet port. we need to receive the messages sent by it so  
> we can handle.
> 
> (those messages are events like keydown, keyup, mouse movement and etc.)
> 
> hope u can give me any direction.  
> This isn’t a wxRuby question I think. wxRuby provides a cross-platform  
> abstraction (Wx::Event etc) over GUI events, but if you want to access  
> native Windows messages, you should probably use ruby’s Win32API  
> library.

[http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/143459](http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/143459)

alex

---

<div class="post-metadata">

**Author:** ![marlesson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/779978/32.png) [@marlesson](https://www.ruby-forum.com/u/marlesson)\
**Post date:** [June 3, 2008, 3:43pm UTC](https://www.ruby-forum.com/t/app-process-message/138676/5 "2008-06-03T15:43:53Z")

</div>

ops, i put the link wrong it’s:

[http://wxruby.rubyforge.org/doc/app.html#App\_processmessage](http://wxruby.rubyforge.org/doc/app.html#App_processmessage)

---

<div class="post-metadata">

**Author:** ![marlesson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/779978/32.png) [@marlesson](https://www.ruby-forum.com/u/marlesson)\
**Post date:** [June 3, 2008, 3:42pm UTC](https://www.ruby-forum.com/t/app-process-message/138676/6 "2008-06-03T15:42:38Z")

</div>

Alex F. wrote:

> Gabriel Rios wrote:
> 
> > Hi alex,
> > 
> > Our problem consist in communicate with an external device which connect  
> > through the ethernet port. we need to receive the messages sent by it so  
> > we can handle.
> > 
> > (those messages are events like keydown, keyup, mouse movement and etc.)
> > 
> > hope u can give me any direction.  
> > This isn’t a wxRuby question I think. wxRuby provides a cross-platform  
> > abstraction (Wx::Event etc) over GUI events, but if you want to access  
> > native Windows messages, you should probably use ruby’s Win32API  
> > library.
> 
> [http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/143459](http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/143459)
> 
> alex

thx for that answer alex, this give us a light but im still curious  
about one thing.

You said that this isnt a wxRuby question, but at the documentation  
there’s the App#process\_message[1] that appear to be what we need on our  
project. But i a have a doubt related to it.

It’s implemented at the wxRuby or we should write it and then the wxRuby  
main\_loop will always call it? (is it already implemented at wxRuby?)

gabriel

(file:///home/gabriel/wxruby.rubyforge.org/doc/app.html#App\_processmessage)

---

<div class="post-metadata">

**Author:** ![marlesson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/779978/32.png) [@marlesson](https://www.ruby-forum.com/u/marlesson)\
**Post date:** [June 5, 2008, 4:17pm UTC](https://www.ruby-forum.com/t/app-process-message/138676/7 "2008-06-05T16:17:31Z")

</div>

What would be the function equal to MSWWindowProc() (  
[Windows FAQ - wxWidgets](http://www.wxwidgets.org/docs/faqmsw.htm#handlewm)) to wxruby?

2008/6/3 Alex F. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

---

<div class="post-metadata">

**Author:** ![marlesson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/779978/32.png) [@marlesson](https://www.ruby-forum.com/u/marlesson)\
**Post date:** [June 5, 2008, 5:20pm UTC](https://www.ruby-forum.com/t/app-process-message/138676/8 "2008-06-05T17:20:51Z")

</div>

Marlesson Santana wrote:

> What would be the function equal to MSWWindowProc()  
> ([http://www.wxwidgets.org/docs/faqmsw.htm#handlewm](http://www.wxwidgets.org/docs/faqmsw.htm#handlewm)) to wxruby?  
> I don’t believe there is an equivalent. Again, if you’re looking to deal  
> with Windows=specific features, I would say the various Win32 libraries  
> out there for ruby would be a better place to look.

wxRuby doesn’t aim to be a complete re-implementation of wxWidgets in  
Ruby. Rather it aims to provide a native, cross-platform GUI toolkit for  
Ruby by using parts of wxWidgets. So a lot of non-GUI and cross-platform  
stuff is omitted.

alex

---

<div class="post-metadata">

**Author:** ![marlesson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/779978/32.png) [@marlesson](https://www.ruby-forum.com/u/marlesson)\
**Post date:** [June 3, 2008, 4:03pm UTC](https://www.ruby-forum.com/t/app-process-message/138676/9 "2008-06-03T16:03:41Z")

</div>

Gabriel Rios wrote:

> > It’s implemented at the wxRuby or we should write it and then the wxRuby  
> > main\_loop will always call it? (is it already implemented at wxRuby?)

It’s not currently implemented and should be deleted from the docs. It’s  
%ignored in this file which generates theWx:: App class in ruby:  
[http://wxruby.rubyforge.org/svn/trunk/wxruby2/swig/classes/App.i](http://wxruby.rubyforge.org/svn/trunk/wxruby2/swig/classes/App.i)

I don’t know how it would work - but methods that work by being defined  
in Ruby and then called as required by wxRuby (for example,  
Wx::App#filter\_event) normally correspond to methods declared as  
“virtual” in the C++ API docs. The C++ method wxApp::ProcessMessage  
isn’t so I wonder if it in fact does what you think it does?

If you can set up a compiler toolchair (I recommend trying MingW) you  
could try it out, and if it works, I’d consider a patch. However it  
doesn’t seem to be a specifically GUI problem, which is why I’d  
recommend pursuing Win32API first.

alex

---

<div class="post-metadata">

**Author:** ![marlesson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/779978/32.png) [@marlesson](https://www.ruby-forum.com/u/marlesson)\
**Post date:** [June 5, 2008, 9:37pm UTC](https://www.ruby-forum.com/t/app-process-message/138676/10 "2008-06-05T21:37:37Z")

</div>

Hello Marlesson,

The best suggestion that we can truely make, is to use the  
Wx::Window#get\_handle() method, to retrive the actual native HWND of the  
window, and use that in cooperation of the Win32 libraries. You would  
need  
to be able to get he Current WndProc of the Window (Which is the  
wxWidget’s  
Window Procedure that is executed for the Main Loop), and create your  
own  
Custom WndProc to handle messages comming in to the window. If it’s a  
message that you need, then you process it like normal, in your own  
code,  
otherwise, you call the WndProc that was originally associated with the  
Window (The wxWidgets WndProc), with the un-modified values for HWND,  
iMsg,  
wParam, lParam.

Now, this is the only thing we can suggest. This is very much untested,  
and  
no garuntee’s that it would work in any case. For us to wrap  
MSWWindowProc(), would only be useful on Windows. We’d rather only port  
Methods that are useful across all platforms. And I must stress this,  
there  
is no garuntee this would work, and may have un-desired results. We  
cannot  
officially support this method in any way possible, outside of showing  
you  
the option. The details of the implementation is entirely up to you,  
and  
you will have to look through the documentation for the Win32 libraries,  
to  
see if you can find what you want to make this work.

Sorry we can’t be of much more help then this,

L8ers,
