This is the mail archive of the cygwin@sources.redhat.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Patch for setup window hiding


RE: <http://cygwin.com/ml/cygwin/2000-11/msg00810.html>

I've attached a patch for this, based on the solution of using a parent 
window.  I did discover one side effect of this though, which may or many 
not be considered a problem.

For the download and install windows (geturl.cc, install.cc) the dialog box 
is created with CreateDialog() as a modeless dialog instead of using 
DialogBox() as all the other windows do to create a modal dialog.  It also 
creates these dialogs in a newly spawned thread.

For whatever reason, if you specify the parent_wnd with the CreateDialog() 
instead of just a null pointer, the window wont response to user input.
ie. You can't click the cancel button or move the window.  It does redraw 
it's progress bars and such no problem however.

In the attached patch, I left the CreateDialog() calls with a null parent 
window pointer.  The side effect of this is that while the download or 
install window is visible, there are two entries in the windows task bar 
for setup, one for the dialog, and the other for the invisible main 
window.  It does appear to still fix the behaviour of the windows dropping 
down in the z order which was the whole point of this in the first place.

If the above behaviour is acceptable, then go ahead and apply the 
patch.  If not (and noone else has an idea of how to fix it), then is the 
consensus that we want to go with SetForegroundWindow() calls or leave 
setup with the z order problem?

Regards

E. 
? config.log
? config.cache
Index: choose.cc
===================================================================
RCS file: /cvs/src/src/winsup/cinstall/choose.cc,v
retrieving revision 2.10
diff -c -r2.10 choose.cc
*** choose.cc	2000/10/23 19:46:01	2.10
--- choose.cc	2000/12/08 09:53:57
***************
*** 757,763 ****
      read_installed_db ();
    build_labels ();
  
!   rv = DialogBox (h, MAKEINTRESOURCE (IDD_CHOOSE), 0, dialog_proc);
    if (rv == -1)
      fatal (IDS_DIALOG_FAILED);
  
--- 757,763 ----
      read_installed_db ();
    build_labels ();
  
!   rv = DialogBox (h, MAKEINTRESOURCE (IDD_CHOOSE), parent_wnd, dialog_proc);
    if (rv == -1)
      fatal (IDS_DIALOG_FAILED);
  
Index: desktop.cc
===================================================================
RCS file: /cvs/src/src/winsup/cinstall/desktop.cc,v
retrieving revision 2.6
diff -c -r2.6 desktop.cc
*** desktop.cc	2000/11/09 01:40:15	2.6
--- desktop.cc	2000/12/08 09:54:00
***************
*** 477,483 ****
    
    int rv = 0;
  
!   rv = DialogBox (h, MAKEINTRESOURCE (IDD_DESKTOP), 0, dialog_proc);
    if (rv == -1)
      fatal (IDS_DIALOG_FAILED);
  }
--- 477,483 ----
    
    int rv = 0;
  
!   rv = DialogBox (h, MAKEINTRESOURCE (IDD_DESKTOP), parent_wnd, dialog_proc);
    if (rv == -1)
      fatal (IDS_DIALOG_FAILED);
  }
Index: dialog.h
===================================================================
RCS file: /cvs/src/src/winsup/cinstall/dialog.h,v
retrieving revision 2.1
diff -c -r2.1 dialog.h
*** dialog.h	2000/09/07 03:09:30	2.1
--- dialog.h	2000/12/08 09:54:01
***************
*** 16,21 ****
--- 16,24 ----
  /* global instance for the application; set in main.cc */
  extern HINSTANCE hinstance;
  
+ /* parent window for all dialog windows. */
+ extern HWND parent_wnd;
+ 
  /* used by main.cc to select the next do_* function */
  extern int next_dialog;
  
Index: geturl.cc
===================================================================
RCS file: /cvs/src/src/winsup/cinstall/geturl.cc,v
retrieving revision 2.2
diff -c -r2.2 geturl.cc
*** geturl.cc	2000/08/30 01:05:42	2.2
--- geturl.cc	2000/12/08 09:54:02
***************
*** 77,83 ****
    int rv = 0;
    MSG m;
    HANDLE gw_dialog = CreateDialog (hinstance, MAKEINTRESOURCE (IDD_DLSTATUS),
! 				   0, dialog_proc);
    ShowWindow (gw_dialog, SW_SHOWNORMAL);
    UpdateWindow (gw_dialog);
    while (GetMessage (&m, 0, 0, 0) > 0) {
--- 77,83 ----
    int rv = 0;
    MSG m;
    HANDLE gw_dialog = CreateDialog (hinstance, MAKEINTRESOURCE (IDD_DLSTATUS),
! 				   0 /* parent_wnd*/, dialog_proc);
    ShowWindow (gw_dialog, SW_SHOWNORMAL);
    UpdateWindow (gw_dialog);
    while (GetMessage (&m, 0, 0, 0) > 0) {
Index: install.cc
===================================================================
RCS file: /cvs/src/src/winsup/cinstall/install.cc,v
retrieving revision 2.9
diff -c -r2.9 install.cc
*** install.cc	2000/11/09 01:40:15	2.9
--- install.cc	2000/12/08 09:54:04
***************
*** 100,106 ****
    int rv = 0;
    MSG m;
    HANDLE ins_dialog = CreateDialog (hinstance, MAKEINTRESOURCE (IDD_INSTATUS),
! 				   0, dialog_proc);
    if (ins_dialog == 0)
      fatal ("create dialog");
    ShowWindow (ins_dialog, SW_SHOWNORMAL);
--- 100,106 ----
    int rv = 0;
    MSG m;
    HANDLE ins_dialog = CreateDialog (hinstance, MAKEINTRESOURCE (IDD_INSTATUS),
! 				   0 /* parent_wnd */, dialog_proc);
    if (ins_dialog == 0)
      fatal ("create dialog");
    ShowWindow (ins_dialog, SW_SHOWNORMAL);
Index: localdir.cc
===================================================================
RCS file: /cvs/src/src/winsup/cinstall/localdir.cc,v
retrieving revision 2.1
diff -c -r2.1 localdir.cc
*** localdir.cc	2000/09/07 03:09:30	2.1
--- localdir.cc	2000/12/08 09:54:05
***************
*** 157,163 ****
  do_local_dir (HINSTANCE h)
  {
    int rv = 0;
!   rv = DialogBox (h, MAKEINTRESOURCE (IDD_LOCAL_DIR), 0, dialog_proc);
    if (rv == -1)
      fatal (IDS_DIALOG_FAILED);
  
--- 157,163 ----
  do_local_dir (HINSTANCE h)
  {
    int rv = 0;
!   rv = DialogBox (h, MAKEINTRESOURCE (IDD_LOCAL_DIR), parent_wnd, dialog_proc);
    if (rv == -1)
      fatal (IDS_DIALOG_FAILED);
  
Index: main.cc
===================================================================
RCS file: /cvs/src/src/winsup/cinstall/main.cc,v
retrieving revision 2.4
diff -c -r2.4 main.cc
*** main.cc	2000/09/07 03:09:30	2.4
--- main.cc	2000/12/08 09:54:06
***************
*** 46,52 ****
--- 46,60 ----
  int exit_msg = 0;
  
  HINSTANCE hinstance;
+ HWND parent_wnd = 0;
  
+ static HWND
+ init_parent();
+ 
+ static long PASCAL
+ message_handler( HWND window, UINT message, WPARAM wparam, LPARAM lparam );
+ 
+ 
  int WINAPI
  WinMain (HINSTANCE h,
  	 HINSTANCE hPrevInstance,
***************
*** 54,59 ****
--- 62,69 ----
  	 int cmd_show)
  {
    hinstance = h;
+   if (( parent_wnd = init_parent() ) == 0 )
+     return FALSE;
  
    next_dialog = IDD_SPLASH;
  
***************
*** 89,93 ****
--- 99,168 ----
  	}
      }
  
+   if ( parent_wnd != 0 ) {
+     DestroyWindow(parent_wnd);
+     MSG msg;
+ 
+     while ( GetMessage(&msg, 0, 0, 0) != 0 ) {
+       TranslateMessage(&msg);
+       DispatchMessage(&msg);
+     }
+   }
+ 
    exit_setup (0);
  }
+ 
+ static long PASCAL
+ message_handler( HWND window, UINT message, WPARAM wparam, LPARAM lparam )
+ {
+   switch(message)
+   {
+   case WM_DESTROY:
+     PostQuitMessage(0);
+     break;
+   default:
+     return DefWindowProc(window, message, wparam, lparam);
+   }
+   return 0;
+ }
+ 
+ //-----------------------------------------------------------------------------
+ static HWND
+ init_parent()
+ {
+   WNDCLASS	wc;
+   HWND		window;
+ 
+   wc.style		= 0;
+   wc.lpfnWndProc	= message_handler;
+   wc.cbClsExtra		= 0;
+   wc.cbWndExtra		= 0;
+   wc.hInstance		= hinstance;
+   wc.hIcon		= LoadIcon(hinstance, MAKEINTRESOURCE(IDI_CYGWIN));
+   wc.hCursor		= 0;
+   wc.hbrBackground	= 0;
+   wc.lpszMenuName	= 0;
+   wc.lpszClassName	= "cygwin_setup";
+   RegisterClass(&wc);
+ 
+   window = CreateWindowEx(
+     0 //WS_EX_TRANSPARENT	// Extended sytle
+   , "cygwin_setup"		// Name of registered class
+   , "Cygwin Setup"		// Name of window
+   , WS_POPUP | WS_CAPTION | WS_SYSMENU	// Window style
+   , 0				// X position of window
+   , 0				// Y position of window
+   , 0				// Width of window
+   , 0				// Height of window
+   , 0				// Parent window
+   , 0				// Child or menu window
+   , hinstance			// Application Instance
+   , 0);				// Window creation data
+ 
+   if (!window)
+     return 0;
+ 
+   ShowWindow(window, SW_SHOWNORMAL);
+   return window;
+ }
+ 
Index: net.cc
===================================================================
RCS file: /cvs/src/src/winsup/cinstall/net.cc,v
retrieving revision 2.3
diff -c -r2.3 net.cc
*** net.cc	2000/09/07 03:09:30	2.3
--- net.cc	2000/12/08 09:54:06
***************
*** 138,144 ****
  {
    int rv = 0;
  
!   rv = DialogBox (h, MAKEINTRESOURCE (IDD_NET), 0, dialog_proc);
    if (rv == -1)
      fatal (IDS_DIALOG_FAILED);
  
--- 138,144 ----
  {
    int rv = 0;
  
!   rv = DialogBox (h, MAKEINTRESOURCE (IDD_NET), parent_wnd, dialog_proc);
    if (rv == -1)
      fatal (IDS_DIALOG_FAILED);
  
Index: netio.cc
===================================================================
RCS file: /cvs/src/src/winsup/cinstall/netio.cc,v
retrieving revision 2.2
diff -c -r2.2 netio.cc
*** netio.cc	2000/08/30 01:05:42	2.2
--- netio.cc	2000/12/08 09:54:07
***************
*** 221,227 ****
  static int
  auth_common (HINSTANCE h, int id)
  {
!   return DialogBox (h, MAKEINTRESOURCE (id), 0, auth_proc);
  }
  
  int
--- 221,227 ----
  static int
  auth_common (HINSTANCE h, int id)
  {
!   return DialogBox (h, MAKEINTRESOURCE (id), parent_wnd, auth_proc);
  }
  
  int
Index: other.cc
===================================================================
RCS file: /cvs/src/src/winsup/cinstall/other.cc,v
retrieving revision 2.1
diff -c -r2.1 other.cc
*** other.cc	2000/08/25 01:32:08	2.1
--- other.cc	2000/12/08 09:54:07
***************
*** 96,102 ****
  do_other (HINSTANCE h)
  {
    int rv = 0;
!   rv = DialogBox (h, MAKEINTRESOURCE (IDD_OTHER_URL), 0, dialog_proc);
    if (rv == -1)
      fatal (IDS_DIALOG_FAILED);
  
--- 96,102 ----
  do_other (HINSTANCE h)
  {
    int rv = 0;
!   rv = DialogBox (h, MAKEINTRESOURCE (IDD_OTHER_URL), parent_wnd, dialog_proc);
    if (rv == -1)
      fatal (IDS_DIALOG_FAILED);
  
Index: root.cc
===================================================================
RCS file: /cvs/src/src/winsup/cinstall/root.cc,v
retrieving revision 2.3
diff -c -r2.3 root.cc
*** root.cc	2000/10/02 16:28:21	2.3
--- root.cc	2000/12/08 09:54:08
***************
*** 285,291 ****
    int rv = 0;
    if (!root_dir)
      read_mount_table ();
!   rv = DialogBox (h, MAKEINTRESOURCE (IDD_ROOT), 0, dialog_proc);
    if (rv == -1)
      fatal (IDS_DIALOG_FAILED);
  
--- 285,291 ----
    int rv = 0;
    if (!root_dir)
      read_mount_table ();
!   rv = DialogBox (h, MAKEINTRESOURCE (IDD_ROOT), parent_wnd, dialog_proc);
    if (rv == -1)
      fatal (IDS_DIALOG_FAILED);
  
Index: site.cc
===================================================================
RCS file: /cvs/src/src/winsup/cinstall/site.cc,v
retrieving revision 2.3
diff -c -r2.3 site.cc
*** site.cc	2000/09/11 23:38:48	2.3
--- site.cc	2000/12/08 09:54:09
***************
*** 326,332 ****
  
    get_initial_list_idx ();
  
!   rv = DialogBox (h, MAKEINTRESOURCE (IDD_SITE), 0, dialog_proc);
    if (rv == -1)
      fatal (IDS_DIALOG_FAILED);
  
--- 326,332 ----
  
    get_initial_list_idx ();
  
!   rv = DialogBox (h, MAKEINTRESOURCE (IDD_SITE), parent_wnd, dialog_proc);
    if (rv == -1)
      fatal (IDS_DIALOG_FAILED);
  
Index: source.cc
===================================================================
RCS file: /cvs/src/src/winsup/cinstall/source.cc,v
retrieving revision 2.2
diff -c -r2.2 source.cc
*** source.cc	2000/09/07 03:09:30	2.2
--- source.cc	2000/12/08 09:54:10
***************
*** 97,103 ****
  do_source (HINSTANCE h)
  {
    int rv = 0;
!   rv = DialogBox (h, MAKEINTRESOURCE (IDD_SOURCE), 0, dialog_proc);
    if (rv == -1)
      fatal (IDS_DIALOG_FAILED);
  
--- 97,103 ----
  do_source (HINSTANCE h)
  {
    int rv = 0;
!   rv = DialogBox (h, MAKEINTRESOURCE (IDD_SOURCE), parent_wnd, dialog_proc);
    if (rv == -1)
      fatal (IDS_DIALOG_FAILED);
  
Index: splash.cc
===================================================================
RCS file: /cvs/src/src/winsup/cinstall/splash.cc,v
retrieving revision 2.3
diff -c -r2.3 splash.cc
*** splash.cc	2000/11/17 22:45:09	2.3
--- splash.cc	2000/12/08 09:54:11
***************
*** 69,75 ****
  do_splash (HINSTANCE h)
  {
    int rv = 0;
!   rv = DialogBox (h, MAKEINTRESOURCE (IDD_SPLASH), 0, dialog_proc);
    if (rv == -1)
      fatal (IDS_DIALOG_FAILED);
  }
--- 69,75 ----
  do_splash (HINSTANCE h)
  {
    int rv = 0;
!   rv = DialogBox (h, MAKEINTRESOURCE (IDD_SPLASH), parent_wnd, dialog_proc);
    if (rv == -1)
      fatal (IDS_DIALOG_FAILED);
  }
--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]