[C\C++] SketchUp window handle
-
Here's a stack overflow thread I made earlier trying to work out how to get the window handle: http://stackoverflow.com/questions/4548354/win32-can-one-enumerate-the-windows-belonging-to-the-calling-thread
I've not implemented it yet though.
-
a note that on the C side of things, the constant NULL is set to the integer 0, which is what C will return for many Win API functions that are unsuccessful.
Win32API.so I don't think converts a C NULL into a Ruby
nil
-
@dan rathbun said:
Win32API.so I don't think converts a C NULL into a Ruby
nil
You're right. That was a wee bug in my code there. I compare against 0 elsewhere. Thanks for spotting that.
-
I have succeeded to find SU hwnd in a following way (pseudo-Ruby \ C++ code):
curr_proc_id = GetCurrentProcessId(); h = GetTopWindow(0); while ( h ) { pid=GetWindowThreadProcessId( h ); if ( pid == curr_proc_id ) { class_name=GetClassName( h ); if (class_name[0..2]=='Afx' && class_name[13]=='b') su_hwnd=h; } h = GetNextWindow( h ); } return su_hwnd;
p.s. I am a spoiled child. I want my Ruby back!!!
I hate defining almost every single byte in memory!
Mac OSX now...
-
The current pid in Ruby is the global
$$
, or a call to:Process.pid()
-
GetTopWindow(0)
What does this actually do?
-
@thomthom said:
GetTopWindow(0)
What does this actually do?
It gets "top most" window.
@unknownuser said:
If this parameter is NULL (0), the function returns a handle to the window at the top of the Z order.
The z-order of a window indicates the window's position in a stack of overlapping windows. This window stack is oriented along an imaginary axis, the z-axis, extending outward from the screen. The window at the top of the z-order overlaps all other windows. The window at the bottom of the z-order is overlapped by all other windows.
http://msdn.microsoft.com/en-us/library/windows/desktop/ms633514(v=vs.85).aspx
GetNextWindow
gets a window beneath.. till all windows examined. -
How fast is it to search through all the windows and do string comparison?
-
@thomthom said:
How fast is it to search through all the windows and do string comparison?
I haven't learned yet how to measure time in C (whole function is written in C), but I guess it is very fast.
-
Here's a way that doesn't iterate every windows there is. It enumerates the windows of the calling thread. Cuts down the searching and ensure that you don't get the wrong window.
Advertisement