I'm CC'ing the list. Please keep the discussion on the list.
On Oct 10, 2016, at 12:26 PM, A B dianaxxyyzz@gmail.com wrote:
If we run the command: wine program.exe , does wine save the hwnd of the main window for the program.exe ? And how to get it ? For example if I want to printf in wine logs ,the hwnd of the main window of program.exe , is this hwnd saved somewhere in a wine variable ?
The concept of "main window" of a program is purely a human interpretation. There's no such concept in the Win32 API. Therefore, there's no specific variable in Wine which holds the "main" window's handle.
You can collect a +win debug log and you'll see the window handle of all of the windows created by the program (along with a lot of activity related to them). It's up to you to determine which is the main window.
-Ken
Thank you for your response. I ' m trying to send WM_QUIT before send WM_CLOSE,when a user click on X ,but only when he close the main window . This is a ugly patch that prevent visual studio 6 to crash if a menu is opened and user click on X . That way I need to know if the hwnd from handle_wm_protocols() is the one of the main window or not , cause I need to send WM_QUIT only if user close his main program window.
On Mon, Oct 10, 2016 at 9:07 PM, Ken Thomases ken@codeweavers.com wrote:
I'm CC'ing the list. Please keep the discussion on the list.
On Oct 10, 2016, at 12:26 PM, A B dianaxxyyzz@gmail.com wrote:
If we run the command: wine program.exe , does wine save the hwnd of the
main window for the program.exe ? And how to get it ? For example if I want to printf in wine logs ,the hwnd of the main window of program.exe , is this hwnd saved somewhere in a wine variable ?
The concept of "main window" of a program is purely a human interpretation. There's no such concept in the Win32 API. Therefore, there's no specific variable in Wine which holds the "main" window's handle.
You can collect a +win debug log and you'll see the window handle of all of the windows created by the program (along with a lot of activity related to them). It's up to you to determine which is the main window.
-Ken
Thinking from wine perspective , what will be the logic to find out if a hwnd is for the main window of a program ?
There will be no such logic to find out if a windows is the "main". The concept doesn't exist in the Windows API, and thus trying to add such a concept will likely cause all sorts of problems.
If a program has such an internal concept, great! But Wine nor the X desktop will know this, since there simply isn't any reliable mechanism to determine this. You could add per-application hacks, but 1. that's not the goal of the Wine project and 2. this would be an extreme amount of work (years) for very little end-user benefit, while also risking breaking applications.
-- Kirn Gill II Mobile (SMS only): +1 813-330-8354 <+18133308354> VoIP: +1 813-704-0420 BBM: 7B963E04 Email: segin2005@gmail.com LinkedIn: http://www.linkedin.com/pub/kirn-gill/32/49a/9a6
On Mon, Oct 10, 2016 at 1:20 PM, A B dianaxxyyzz@gmail.com wrote:
Thinking from wine perspective , what will be the logic to find out if a hwnd is for the main window of a program ?
On Oct 10, 2016, at 1:15 PM, A B dianaxxyyzz@gmail.com wrote:
Thank you for your response. I ' m trying to send WM_QUIT before send WM_CLOSE,when a user click on X ,but only when he close the main window . This is a ugly patch that prevent visual studio 6 to crash if a menu is opened and user click on X . That way I need to know if the hwnd from handle_wm_protocols() is the one of the main window or not , cause I need to send WM_QUIT only if user close his main program window.
Rather than sending WM_QUIT, I recommend that you try sending WM_CANCELMODE. You can send that to any window which the window manager closes without unintended consequences, so you don't need to attempt to determine which is the "main" window. In fact, this may not even be a hack; it might be the right thing to do.
On Oct 10, 2016, at 1:20 PM, A B dianaxxyyzz@gmail.com wrote:
Thinking from wine perspective , what will be the logic to find out if a hwnd is for the main window of a program ?
There is no logic to find that out because "main window" is not a well-defined concept and means nothing in terms of Wine/Windows internals. Visual Studio itself may consider one of its windows "main", but that is not exposed to Wine. The only significance is how VS behaves.
-Ken
I made it to finnaly work for visual studio 6 , to do not crash if user click X ,and a menu is oppened. I had to send WM_KILLFOCUS . I know this is a ugly patch but somebody maybe inspire and make the correct fix. Is just what works for me till now .Must be improved.
I modified user32/message.c
Here are all mods I did :
void DoSomething(HWND hwnd); BOOL CALLBACK DoSomethingHelper(HWND hwnd, LPARAM lParam); void DoSomethingToWindowTree(HWND hwndRoot);
void DoSomething(HWND hwnd) {
WCHAR str[80];
PostMessageW( hwnd, WM_KILLFOCUS, WM_SETFOCUS ,0);
GetWindowTextW( hwnd, str, sizeof(str)/sizeof(WCHAR) ); printf("\n Window name: %s " , debugstr_w(str) );
}
BOOL CALLBACK DoSomethingHelper(HWND hwnd, LPARAM lParam) { DoSomething(hwnd);
return TRUE; }
void DoSomethingToWindowTree(HWND hwndRoot) {
DWORD pid;
EnumThreadWindows( GetWindowThreadProcessId(hwndRoot, &pid) , DoSomethingHelper, 0); }
/*********************************************************************** * SendMessageW (USER32.@) */ LRESULT WINAPI SendMessageW( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam ) { DWORD_PTR res = 0; struct send_message_info info;
info.type = MSG_UNICODE; info.hwnd = hwnd; info.msg = msg; info.wparam = wparam; info.lparam = lparam; info.flags = SMTO_NORMAL; info.timeout = 0;
if ( msg == WM_CLOSE) { DoSomethingToWindowTree(hwnd); PostMessageW( hwnd, WM_CLOSE, 0 ,0); return TRUE; }
send_message( &info, &res, TRUE ); return res; }
On Mon, Oct 10, 2016 at 9:30 PM, Ken Thomases ken@codeweavers.com wrote:
On Oct 10, 2016, at 1:15 PM, A B dianaxxyyzz@gmail.com wrote:
Thank you for your response. I ' m trying to send WM_QUIT before send WM_CLOSE,when a user click on X
,but only when he close the main window . This is a ugly patch that prevent visual studio 6 to crash if a menu is opened and user click on X .
That way I need to know if the hwnd from handle_wm_protocols() is the
one of the main window or not , cause I need to send WM_QUIT only if user close his main program window.
Rather than sending WM_QUIT, I recommend that you try sending WM_CANCELMODE. You can send that to any window which the window manager closes without unintended consequences, so you don't need to attempt to determine which is the "main" window. In fact, this may not even be a hack; it might be the right thing to do.
On Oct 10, 2016, at 1:20 PM, A B dianaxxyyzz@gmail.com wrote:
Thinking from wine perspective , what will be the logic to find out if a
hwnd is for the main window of a program ?
There is no logic to find that out because "main window" is not a well-defined concept and means nothing in terms of Wine/Windows internals. Visual Studio itself may consider one of its windows "main", but that is not exposed to Wine. The only significance is how VS behaves.
-Ken