Old 10-09-2009, 09:03 AM   #1
Padre_PC
Human being with feelings
 
Join Date: Sep 2009
Posts: 262
Default "MIDI Editor" Main_OnCommand() ?

I've been using Main_OnCommand() to run actions in the "Main" Section, but how do I run actions in other sections? I'm especially interested in the "MIDI Editor" section. I've assigned command IDs but even if the MIDI Editor window has focus they still run "Main" actions. I know there's an "int flags" parameter but I couldn't find documentation anywhere.
Padre_PC is offline   Reply With Quote
Old 10-09-2009, 09:13 AM   #2
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
Default

Quote:
Originally Posted by Padre_PC View Post
I've been using Main_OnCommand() to run actions in the "Main" Section, but how do I run actions in other sections? I'm especially interested in the "MIDI Editor" section. I've assigned command IDs but even if the MIDI Editor window has focus they still run "Main" actions. I know there's an "int flags" parameter but I couldn't find documentation anywhere.
A hack solution that might or might not work : find the HWND of the MIDI editor window you are interested in and do a SendMessage() win32 API call to it with the WM_COMMAND message.
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
Xenakios is offline   Reply With Quote
Old 10-09-2009, 09:14 AM   #3
schwa
Administrator
 
schwa's Avatar
 
Join Date: Mar 2007
Location: NY
Posts: 15,812
Default

You should be able to pass the command as a regular Windows WM_COMMAND message to the MIDI editor window.

... which isn't a hack the commands are designed to be used that way.
schwa is offline   Reply With Quote
Old 10-09-2009, 10:32 AM   #4
Padre_PC
Human being with feelings
 
Join Date: Sep 2009
Posts: 262
Default

Thanks, I've tried with FindWindow() then SendMessage(WM_COMMAND) and it works!

However... it worked because I knew the name of the window. It's gonna be hell if I want to make it automatic. Instead of using names I could look for the window which has focus but it would be dangerous since some "MIDI Editor" command IDs are also active in the "Main" window.
Padre_PC is offline   Reply With Quote
Old 10-09-2009, 01:20 PM   #5
Padre_PC
Human being with feelings
 
Join Date: Sep 2009
Posts: 262
Default

I think I can get away with EnumWindows() and an "MIDI take:" wildcard search, I'll try that out...
Padre_PC is offline   Reply With Quote
Old 10-09-2009, 01:24 PM   #6
schwa
Administrator
 
schwa's Avatar
 
Join Date: Mar 2007
Location: NY
Posts: 15,812
Default

The window class will be REAPERmidieditorwnd...
schwa is offline   Reply With Quote
Old 10-09-2009, 11:21 PM   #7
Padre_PC
Human being with feelings
 
Join Date: Sep 2009
Posts: 262
Default

Even better then:

void MIDI_OnCommand(int command, int flags)
{
HWND midiHwnd = FindWindow("REAPERmidieditorwnd", NULL);
if(midiHwnd)
SendMessage(midiHwnd, WM_COMMAND, command, flags);
}
Padre_PC is offline   Reply With Quote
Old 10-19-2009, 03:16 AM   #8
Jeffos
Mortal
 
Jeffos's Avatar
 
Join Date: Dec 2008
Location: France
Posts: 1,969
Default

If it exists, I'd like to know the class name of the track routing windows (I need that to prevent a crash described here: http://forum.cockos.com/showpost.php...2&postcount=15)
Jeffos is offline   Reply With Quote
Old 10-20-2009, 12:05 AM   #9
Jeffos
Mortal
 
Jeffos's Avatar
 
Join Date: Dec 2008
Location: France
Posts: 1,969
Default

ok, I tried:
REAPERroutingwnd
REAPERiownd
REAPERroutingdlg
REAPERiodlg
REAPERgimmesomefunk
REAPERgimmesomejazz
REAPERgimmesomemetal

... none is working. Any clue ? Do I really have to build all possible names (annoying: I also need to retreive "Controls for track x" dlgs) ?
Jeffos is offline   Reply With Quote
Old 10-20-2009, 12:57 AM   #10
Fabian
Human being with feelings
 
Fabian's Avatar
 
Join Date: Sep 2008
Location: Sweden
Posts: 7,431
Default

Quote:
Originally Posted by Jeffos View Post
If it exists, I'd like to know the class name of the track routing windows (I need that to prevent a crash described here: http://forum.cockos.com/showpost.php...2&postcount=15)
Can this help?
http://support.microsoft.com/kb/112649
http://geekswithblogs.net/rupreet/ar.../17/57204.aspx
__________________
// MVHMF
I never always did the right thing, but all I did wasn't wrong...
Fabian is offline   Reply With Quote
Old 10-20-2009, 04:53 AM   #11
Padre_PC
Human being with feelings
 
Join Date: Sep 2009
Posts: 262
Default

Found this:

http://msdn.microsoft.com/en-us/magazine/cc163617.aspx
Padre_PC is offline   Reply With Quote
Old 10-20-2009, 05:13 AM   #12
Fergo
Human being with feelings
 
Fergo's Avatar
 
Join Date: Mar 2009
Location: Curitiba - Brazil
Posts: 371
Default

There's a program called WindowHack which can help you a lot when dealing with Win32 GUI programming. You can get a lot of information from any window in the screen, like classname, handle, child windows, parent, send messages, etc. I really recommend it, even for testing purposes.

Example:

It can also grab windows like the VU Meter, TCP, etc.

You can get it here:
http://www.geocities.com/asmsoft3264/download.html#wh

Regards,
Fergo
__________________
My new application: Fergo JoystickMIDI - Send commands using your joystick/gamepad
Portfolio: www.fbirck.com
Homepage: www.fergonez.net - Programming stuff

Last edited by Fergo; 10-20-2009 at 05:21 AM.
Fergo is offline   Reply With Quote
Old 10-20-2009, 05:56 AM   #13
Jeffos
Mortal
 
Jeffos's Avatar
 
Join Date: Dec 2008
Location: France
Posts: 1,969
Default

Hey, thanks to all!
Fabian's links talk about spy++ that I don't have here (express edition), but it put me in the good direction => I also found a little comparable tool: http://www.dennisbabkin.com/php/download.php?what=WinID, works fine.
I'll also look to the others tools Fergo & Padre has posted in the meantime, thanks again!

[EDIT] I tried WindowHack: yes, its global "hierarchical view" of parent and child windows is great. However, it's unable to grab info on dialogs such as the routing ones: these dialogs disappear since WindowHack gets the focus... For the record, the WinID tool can do it.

about the pb itself [EDIT2], which is: "how do I know that a routing/control window is opened ?"[/EDIT2] as I was guessing, "Routing" and "Controls" windows are in fact dialog boxes, so I suppose there's no clean way to get them, i.e. I can only get them by name, full name (meaning that I have to build all possible titles), right ?

Last edited by Jeffos; 10-20-2009 at 06:47 AM.
Jeffos is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 11:17 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.