position of a dialog near to a get

position of a dialog near to a get

Postby Silvio » Wed Apr 27, 2011 9:20 pm

How show a dialog near the get ( get ...bitmap) near to button of the get ?
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: position of a dialog near to a get

Postby Marcelo Via Giglio » Thu Apr 28, 2011 2:37 am

Silvio,

try to get the coords with getWndRect( oGet:hWnd ) and you can apply the get's width and height too if you need other coords

I think what you want to do is a datepicker, but I have problem to close the dialog (cal) when click outside it

Code: Select all  Expand view  RUN

#include "FiveWin.ch"
#include "calendar.ch"

FUNCTION main()
LOCAL oDlg
LOCAL fecha := DATE()

   SET DATE TO BRITISH
   SET EPOCH TO 1980      

DEFINE DIALOG oDlg FROM 10,10 TO 200,300 PIXEL

@ 20,20 GET fecha SIZE 100,22 OF oDlg PIXEL ACTION cal( fecha, self ) BITMAP  "close.bmp"

ACTIVATE DIALOG oDlg

RETURN NIL

FUNCTION cal( fecha, oGet )
   LOCAL oWnd, oCal, aRect
   LOCAL dHoy := fecha, lOk := .T.

   aRect := getWndRect( oGet:hWnd )

   DEFINE DIALOG oWnd FROM 0, 0 TO 150, 174 PIXEL STYLE WS_CHILD | WS_POPUP | WS_VISIBLE
 
   @ 0, 0 CALENDAR oCal VAR dHoy OF oWnd PIXEL DAYSTATE size 87,75 DBLCLICK oWnd:end()

   oWnd:bLostFocus := {|| oWnd:end() }
   oCal:bLostFocus := {|| oWnd:end() }
   oCal:bKeyDown   := {|nkey| IF( nKey = 13 .OR. nKey = 32, oWnd:end(), ) }
   
   ACTIVATE DIALOG oWnd ON INIT oWnd:move(aRect[1] + oGet:nHeight ,aRect[2] )

   IF lOk      
      oGet:cText := dHoy
      oGet:refresh()
   ENDIF
 
RETURN NIL
 
Marcelo Via Giglio
 
Posts: 1071
Joined: Fri Oct 07, 2005 3:33 pm
Location: Cochabamba - Bolivia

Re: position of a dialog near to a get

Postby Marcelo Via Giglio » Thu Apr 28, 2011 3:06 am

A possible solution is change the dialog by window, but now don't work ESC to close the calendar

Code: Select all  Expand view  RUN

#include "FiveWin.ch"
#include "calendar.ch"

FUNCTION main()
LOCAL oDlg
LOCAL fecha := DATE()

   SET DATE TO BRITISH
   SET EPOCH TO 1980      

DEFINE DIALOG oDlg FROM 10,10 TO 200,300 PIXEL

@ 20,20 GET fecha SIZE 100,22 OF oDlg PIXEL ACTION cal( fecha, self ) BITMAP  "close.bmp"

ACTIVATE DIALOG oDlg

RETURN NIL

FUNCTION cal( fecha, oGet )
   LOCAL oWnd, oCal, aRect
   LOCAL dHoy := fecha, lOk := .T., lLostFocus := .F.

   aRect := getWndRect( oGet:hWnd )

   DEFINE WINDOW oWnd FROM 0, 0 TO 150, 174 PIXEL STYLE WS_CHILD | WS_POPUP | WS_VISIBLE
 
   @ 0, 0 CALENDAR oCal VAR dHoy OF oWnd PIXEL DAYSTATE size 150,174 DBLCLICK oWnd:end()  //87,75

   oCal:bLostFocus := {|| lLostFocus := .T., oWnd:end() }
   oCal:bKeyDown   := {|nkey| IF( nKey = 13 .OR. nKey = 32, oWnd:end(),  ) }

   oWnd:oClient := oCal
   
   ACTIVATE WINDOW oWnd ;
           ON INIT oWnd:move(aRect[1] + oGet:nHeight ,aRect[2] ) ;
         VALID IF( lOk .AND. ! lLostFocus .AND. ! GetKeyState( VK_ESCAPE ), ( oGet:cText := dHoy, oGet:refresh(), .T. ), .T. )
 
RETURN NIL
 
Marcelo Via Giglio
 
Posts: 1071
Joined: Fri Oct 07, 2005 3:33 pm
Location: Cochabamba - Bolivia

Re: position of a dialog near to a get

Postby Marcelo Via Giglio » Thu Apr 28, 2011 3:26 am

Ok,

this work, but I don't know if it's the best solution

Code: Select all  Expand view  RUN

#include "FiveWin.ch"
#include "calendar.ch"

FUNCTION main()
LOCAL oDlg
LOCAL fecha := DATE()

   SET DATE TO BRITISH
   SET EPOCH TO 1980      

DEFINE DIALOG oDlg FROM 10,10 TO 200,300 PIXEL

@ 20,20 GET fecha SIZE 100,22 OF oDlg PIXEL ACTION cal( fecha, self ) BITMAP  "close.bmp"

ACTIVATE DIALOG oDlg

RETURN NIL

FUNCTION cal( fecha, oGet )
   LOCAL oWnd, oCal, aRect
   LOCAL dHoy := fecha, lOk := .T., lLostFocus := .F.

   aRect := getWndRect( oGet:hWnd )

   DEFINE WINDOW oWnd FROM 0, 0 TO 150, 174 PIXEL STYLE WS_CHILD | WS_POPUP | WS_VISIBLE
 
   @ 0, 0 CALENDAR oCal VAR dHoy OF oWnd PIXEL DAYSTATE size 150,174 DBLCLICK oWnd:end()  //87,75

   oCal:bLostFocus := {|| lLostFocus := .T., oWnd:end() }
   oCal:bKeyDown   := {|nkey| IF( nKey = 13 .OR. nKey = 32, oWnd:end(),  ) }

   oWnd:oClient := oCal
   oWnd:bKeyDown := {|nkey| IF( GetKeyState( VK_ESCAPE ), oWnd:end(), ) }
   
   ACTIVATE WINDOW oWnd ;
           ON INIT ( oWnd:move(aRect[1] + oGet:nHeight ,aRect[2] ), oCal:setFocus() ) ;
         VALID IF( lOk .AND. ! lLostFocus .AND. ! GetKeyState( VK_ESCAPE ), ( oGet:cText := dHoy, oGet:refresh(), .T. ), .T. )
 
RETURN NIL
 
Marcelo Via Giglio
 
Posts: 1071
Joined: Fri Oct 07, 2005 3:33 pm
Location: Cochabamba - Bolivia

Re: position of a dialog near to a get

Postby Silvio » Thu Apr 28, 2011 7:07 am

GOOD I'm trying your samples
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: position of a dialog near to a get

Postby Silvio » Thu Apr 28, 2011 2:39 pm

on W7 not run good I see only 5 days and not all lines
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: position of a dialog near to a get

Postby Marcelo Via Giglio » Thu Apr 28, 2011 5:57 pm

Hi,

it is strange, because I develop it in win7 32 bits

regards

Marcelo
Marcelo Via Giglio
 
Posts: 1071
Joined: Fri Oct 07, 2005 3:33 pm
Location: Cochabamba - Bolivia

Re: position of a dialog near to a get

Postby Silvio » Thu Apr 28, 2011 6:59 pm

I have

ASUS G73JW WITH 860 QM INTEL CORE 7
8 GIGA RAM
1,5 GIGA NVIDIA GEFORCE GTX440M
BLUE RAY WRITER
EAX 5.0

BUT WITH WINDOWS HOME PREMIUM 64 BIT


Image


Now I have this resolution of screen : default 125%

I tried also with 150% or 100%

with 100% I see all smaller
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: position of a dialog near to a get

Postby Marcelo Via Giglio » Fri Apr 29, 2011 9:51 pm

Silvio,

sorry I don't have win7 64.

This is an improve, now work properly when we are using themes

Code: Select all  Expand view  RUN

FUNCTION calendar( fecha, oGet )
//------------------------------------------------------------------------------
   LOCAL oWnd, oCal, aRect, w, h, x, y, cps
   LOCAL dHoy := fecha, lOk := .T., lLostFocus := .F.

   IF isAppthemed()
      w := 224; h := 159
   ELSE
      w := 174; h := 150
   ENDIF

   aRect := getWndRect( oGet:hWnd )
   y := aRect[1] + oGet:nHeight
   x := aRect[2]

   DEFINE WINDOW oWnd FROM y, x TO y + h, x + w PIXEL STYLE WS_CHILD | WS_POPUP | WS_VISIBLE

   @ 0, 0 CALENDAR oCal VAR dHoy OF oWnd PIXEL size h,w DBLCLICK oWnd:end() //87,75

   oCal:bLostFocus := {|| lLostFocus := .T., oWnd:end() }
   oCal:bKeyDown   := {|nkey| IF( nKey = 13 .OR. nKey = 32, oWnd:end(),  ) }

   oWnd:oClient := oCal
   oWnd:bKeyDown := {|nkey| IF( GetKeyState( VK_ESCAPE ), oWnd:end(), ) }

   ACTIVATE WINDOW oWnd ;
           ON INIT ( oWnd:move(aRect[1] + oGet:nHeight ,aRect[2] ), oCal:setFocus() ) ;
             VALID IF( lOk .AND. ! lLostFocus .AND. ! GetKeyState( VK_ESCAPE ), ( oGet:cText := dHoy, oGet:refresh(), .T. ), .T. )

RETURN NIL
 
Marcelo Via Giglio
 
Posts: 1071
Joined: Fri Oct 07, 2005 3:33 pm
Location: Cochabamba - Bolivia

Re: position of a dialog near to a get

Postby Silvio » Sat Apr 30, 2011 7:16 am

I understtod I cannot use this feature I must use dtpick only... on win7 64bit
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 87 guests

cron