Minimize Dialog and Window too

Re: Minimize Dialog and Window too

Postby James Bott » Mon Jan 24, 2011 6:53 pm

Marco,

One side affect of your last code is that when you attempt to resize the window/dialog it minimizes. This is unexpected to the user.

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Minimize Dialog and Window too

Postby James Bott » Mon Jan 24, 2011 7:09 pm

Marco,

A solution to the problem is to add BORDER NONE to the DEFINE WINDOW line. This prevents resizing. You could also add the NOMAXIMIZE clause.

DEFINE WINDOW oWnd FROM 1000 , 1000 TO 1000 , 1000 nomaximize border none

Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Minimize Dialog and Window too

Postby James Bott » Mon Jan 24, 2011 7:19 pm

Marco,

I am wondering why you want to be able to minimize a dialog? Users will not expect to be able to do this as it is standard behavior for dialogs not to be minimizable.

If the issue is only the need and presence of the window, then what about just hiding the window?

oWnd:hide()

That provides you with the window that is required for a socket but the user cannot see the window--only the dialog.

Code: Select all  Expand view
#include "fivewin.ch"

function main()
   local oWnd
   define window oWnd from -100,-100 to -99,-99
   activate window oWnd on init Start()
return nil

function Start()
   local oDlg
   wndMain():hide()
   define dialog oDlg
   activate dialog oDlg center
   wndMain():end()
return nil

Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Minimize Dialog and Window too

Postby MarcoBoschi » Tue Jan 25, 2011 8:10 am

>One side affect of your last code is that when you attempt to resize the window/dialog it >minimizes. This is unexpected to the user.

It's a very simple program: no window, no menu only a dialog and user often iconize it.
User avatar
MarcoBoschi
 
Posts: 1025
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy

Re: Minimize Dialog and Window too

Postby nageswaragunupudi » Tue Jan 25, 2011 8:44 am

Code: Select all  Expand view
oWnd:hide()
It is better to ACTIVATE WINDOW oWnd HIDDEN. The window does not even flash.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10308
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Minimize Dialog and Window too

Postby nageswaragunupudi » Tue Jan 25, 2011 9:09 am

The main issue is that Mr. Marco wants to have a Socket client ( not server ) with Dialog only which can be minimized to taskbar. We are talking about creating a window and hiding it only because WndMain() is required.

The TSocket():New( nPort, oWnd ) accepts oWnd as second parameter.
Code: Select all  Expand view
METHOD New( nPort, oWnd ) CLASS TSocket

   DEFAULT oWnd := WndMain(), ::aSockets := {}

   if Len( ::aSockets ) == 0
      if WSAStartup() != 0
         MsgAlert( "WSAStartup error" )
      endif
   endif

   if ( ::nSocket := Socket( AF_INET, SOCK_STREAM, IPPROTO_IP ) ) == 0
      MsgAlert( "Socket creation error: " + Str( WsaGetLastError() ) )
   endif

   ::cIPAddr  = GetHostByName( GetHostName() )
   ::aBuffer  = {}
   ::lSending = .f.
   ::lDebug   = .f.

   if nPort != nil
      ::nPort = nPort
      BindToPort( ::nSocket, nPort )  // Bind is not needed for connect sockets
   endif

   AAdd( ::aSockets, Self )

   if oWnd != nil
      oWnd:bSocket = { | nSocket, nLParam | ::HandleEvent( nSocket,;
                         nLoWord( nLParam ), nHiWord( nLParam ) ) }

      WSAAsyncSelect( ::nSocket, oWnd:hWnd, WM_ASYNCSELECT,;
            nOr( FD_ACCEPT, FD_OOB, FD_READ, FD_CLOSE, FD_CONNECT, FD_WRITE ) )
   else
      MsgAlert( "You must create a main window in order to use a TSocket object" )
   endif

return Self

//----------------------------------------------------------------------------//
 

WndMain() is expected only if the second paramter oWnd is not supplied.
Have you tried creating socket client with TSocket():New( nPort, oDlg ) ?
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10308
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Minimize Dialog and Window too

Postby James Bott » Tue Jan 25, 2011 11:02 am

Rao,

It is better to ACTIVATE WINDOW oWnd HIDDEN. The window does not even flash.


I didn't know about the HIDDEN clause. That is why I drew the window off the screen so it doesn't flash.

Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Minimize Dialog and Window too

Postby MarcoBoschi » Tue Jan 25, 2011 3:33 pm

Probably I have to go in this direction:

- no initial Window so I have no problem When I iconize the dialog
- I Have to create a dummy window (or hide) when I create oTelnet object

IF oTelnet = NIL

oTelnet := TSocket():New( nPorta )
oTelnet:Connect( cIp )
oTelnet:lDebug := .T.

It looked like a small problem but...pain

Many thanks guys
User avatar
MarcoBoschi
 
Posts: 1025
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy

Re: Minimize Dialog and Window too

Postby MarcoBoschi » Tue Jan 25, 2011 3:58 pm

>WndMain() is expected only if the second paramter oWnd is not supplied.
>Have you tried creating socket client with TSocket():New( nPort, oDlg ) ?

It seems a good solution
Now I remove window and I review all involved functions
Thank You very much!
User avatar
MarcoBoschi
 
Posts: 1025
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy

Re: Minimize Dialog and Window too

Postby MarcoBoschi » Wed Jan 26, 2011 10:56 am

I confirm
In this way

IF oTelnet = NIL
oTelnet := TSocket():New( nPorta, oDlg )

now my program works fine without a window

Thanks again
marco
User avatar
MarcoBoschi
 
Posts: 1025
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy

Re: Minimize Dialog and Window too

Postby nageswaragunupudi » Wed Jan 26, 2011 2:48 pm

Glad to know it works.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10308
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Previous

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 51 guests