Old 09-16-2018, 03:32 PM   #1
doppelganger
Human being with feelings
 
Join Date: Feb 2017
Posts: 312
Default hwnd questions, track to hwnd ?

Hi! I can get track's pointer from hwnd using GetWindowLongPtr(hwnd, GWLP_USERDATA)
but how can i get hwnd from track's pointer? Can somebody help please?

Last edited by doppelganger; 11-09-2018 at 01:43 AM.
doppelganger is offline   Reply With Quote
Old 09-16-2018, 03:37 PM   #2
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 2,246
Default

You can do it by iterating over all windows until you find the one that points to the track. This is what SWS does: https://github.com/reaper-oss/sws/bl...Util.cpp#L2887.
cfillion is online now   Reply With Quote
Old 09-16-2018, 03:42 PM   #3
doppelganger
Human being with feelings
 
Join Date: Feb 2017
Posts: 312
Default

yeah, i found this, i thought maybe there is easy direct way without iterating through hundred of windows.

Last edited by doppelganger; 09-16-2018 at 04:04 PM.
doppelganger is offline   Reply With Quote
Old 09-18-2018, 04:14 AM   #4
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 7,390
Default

I've always found it curious the tracks even have separate HWNDs, it seems like an Reaper internal implementation detail 3rd party developers probably shouldn't rely on...Cockos might at any time decide they no longer want to do it that way for example because it wastes the available window handles.
__________________
For info on SWS Reaper extension plugin (including Xenakios' previous extension/actions) :
http://www.sws-extension.org/
https://github.com/Jeff0S/sws
--
Xenakios blog (about HourGlass, Paul(X)Stretch and λ) :
http://xenakios.wordpress.com/
Xenakios is offline   Reply With Quote
Old 09-18-2018, 06:26 AM   #5
doppelganger
Human being with feelings
 
Join Date: Feb 2017
Posts: 312
Default

Quote:
Originally Posted by Xenakios View Post
I've always found it curious the tracks even have separate HWNDs, it seems like an Reaper internal implementation detail 3rd party developers probably shouldn't rely on...Cockos might at any time decide they no longer want to do it that way for example because it wastes the available window handles.
it works at the moment and looks like works already for years, that's all i need for my use. If at some point developers of reaper will replace it with something else, then 3rd party function will be removed/deprecated/replaced/etc.

Last edited by doppelganger; 09-18-2018 at 07:01 AM.
doppelganger is offline   Reply With Quote
Old 09-18-2018, 11:04 AM   #6
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 2,246
Default

Quote:
Originally Posted by doppelganger View Post
that's all i need for my use.
Out of curiosity, what do you need it for?
cfillion is online now   Reply With Quote
Old 09-18-2018, 11:32 AM   #7
doppelganger
Human being with feelings
 
Join Date: Feb 2017
Posts: 312
Default

Quote:
Originally Posted by cfillion View Post
Out of curiosity, what do you need it for?
i made simple script for myself, which i use all the time:
https://forum.cockos.com/showthread.php?t=210987
This function helped my to fix one very annoying bug in my script (at the moment only in ubuntu version). Also it helped to make one small function inside the same script to be 100 times !! more efficient, than with workaround before it, so i don't see a point to disregard such advantage. Also function only gets data and doesn't set anything, so i don't see a reason to panic too

But if it disturbs anyone, just say, i'll remove it from public pull request, no problem
doppelganger is offline   Reply With Quote
Old 09-18-2018, 11:49 AM   #8
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 2,246
Default

It looks awesome!
cfillion is online now   Reply With Quote
Old 11-09-2018, 02:02 AM   #9
doppelganger
Human being with feelings
 
Join Date: Feb 2017
Posts: 312
Default

1 more question about REAPER's windows gnaws me, is there a way to open send/recv/HWout Controls window?
As i see every send/recv/hwout in track routing window are separate small windows, which can be opened separately as "Controls for track N"
I can't find a way to make open/close them, is it possible?

Also, if i have a func: void Example(HWND hwnd, int* valueOut)

and i want to get nil instead of 0 as a return in Lua, if value < 0, is it possible?.
Do i need to tweak it's value in vararg function, or maybe it's not very good idea and simply return -1 instead of nil and not to bother?

Last edited by doppelganger; 11-09-2018 at 02:42 AM.
doppelganger 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 10:04 PM.


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