Mandar foco para bottonex
Moderador: Moderadores
Mandar foco para bottonex
Pessoal,
Vocês teriam algum exemplo de como dar foco para um botão bottonex ?
Vocês teriam algum exemplo de como dar foco para um botão bottonex ?
►Harbour 3.x | Minigui xx-x | HwGui◄
Pense nas possibilidades abstraia as dificuldades.
Não corrigir nossas falhas é o mesmo que cometer novos erros.
A imaginação é mais importante que o conhecimento. (Albert Einstein)
Pense nas possibilidades abstraia as dificuldades.
Não corrigir nossas falhas é o mesmo que cometer novos erros.
A imaginação é mais importante que o conhecimento. (Albert Einstein)
- Pablo César
- Usuário Nível 7

- Mensagens: 5312
- Registrado em: 31 Mai 2006 10:22
- Localização: Curitiba - Paraná
Mandar focus para buttonex
Você quis dizer Buttonex. Olh aqui tem um exemplo em MiniGui que tem bastante semelhança com HwGui que utiliza o focus e que pode vir a servir de referência, veja se isso te ajuda:
O exemplo acima está pasta C:\MiniGUI\SAMPLES\BASIC\ButtonEx e anexei o executável para facilitar.
Código: Selecionar todos
/*
* MINIGUI - Harbour Win32 GUI library
* Copyright 2002 Roberto Lopez <harbourminigui@gmail.com>
* http://harbourminigui.googlepages.com/
*/
#include "minigui.ch"
Function Main()
DEFINE WINDOW Form_1 ;
AT 0,0 WIDTH 458 HEIGHT 362 ;
MAIN ;
ICON "pressit" TITLE 'ButtonEx with color gradient background'
DEFINE MAIN MENU
POPUP "AllButtons"
ITEM "Enable all buttons" ACTION EnableAllButtons()
ITEM "Disable all buttons" ACTION DisableAllButtons()
END POPUP
POPUP "OwnerButton"
ITEM "Set button text 6 to Globe" ACTION {|| Form_1.OButton_6.Caption := "Globe"}
ITEM "Set button text 6 to an empty value" ACTION {|| Form_1.OButton_6.Caption := ""}
SEPARATOR
ITEM "Set OButton_6 button icon to arrow.ico" ACTION {|| Form_1.OButton_6.Icon := "res\arrow.ico"}
ITEM "Get OButton_6 button icon " ACTION {|| MsgBox(Form_1.OButton_6.Icon)}
END POPUP
END MENU
// vertical buttonex with icons
@ 10, 35 BUTTONEX OButton_1 ;
CAPTION "&Down" ;
ICON "res\arrow.ico" ;
VERTICAL ;
UPPERTEXT ;
WIDTH 80 ;
HEIGHT 80 ;
FONT "MS Sans serif" ;
SIZE 11 ;
FONTCOLOR {0,128,0} ;
BACKCOLOR {240,255,240} ;
BOLD ;
ACTION TONE(100)
TOOLTIP "OButton_1 BUTTONEX with icon - vertical"
@ 10, 120 BUTTONEX OButton_2 ;
WIDTH 80 ;
HEIGHT 80 ;
CAPTION "Press" ;
ICON "pressit" ;
LEFTTEXT ;
BACKCOLOR YELLOW ;
FLAT ;
FONT "MS Sans serif" ;
SIZE 11 ;
FONTCOLOR RED ;
BOLD ;
TOOLTIP "OButton_2 BUTTONEX with icon - horizontal - lefttext - flat" ;
ACTION {|| TONE(500)}
DEFINE BUTTONEX OButton_3
ROW 160
COL 35
WIDTH 80
HEIGHT 30
CAPTION "OK"
PICTURE "OK"
FONTNAME "MS Sans serif"
FONTSIZE 9
FONTBOLD .t.
LEFTTEXT .t.
BACKCOLOR {240,255,240}
END BUTTONEX
@ 160, 130 BUTTONEX OButton_4 ;
CAPTION "&Login" ;
ICON "res\keys.ico" ;
FLAT WIDTH 80 HEIGHT 30 FONT "MS Sans serif" SIZE 9 ;
FONTCOLOR BLUE ;
BOLD ;
BACKCOLOR WHITE ;
ACTION {|| TONE(800)} TOOLTIP "BUTTONEX 4 with Bitmap - horizontal"
DEFINE BUTTONEX OButton_5
ROW 10
COL 205
WIDTH 80
HEIGHT 80
CAPTION "Computer"
VERTICAL .t.
ICON "res\comp.ico"
FLAT .f.
FONTNAME "MS Sans serif"
FONTSIZE 9
FONTCOLOR {0,128,0}
FONTBOLD .t.
BACKCOLOR {240,255,240}
UPPERTEXT .t.
TOOLTIP "OButton_5 button with icon - vertical - uppertext - nohotlight - noxpstyle"
NOHOTLIGHT .F.
NOXPSTYLE .t.
END BUTTONEX
@ 10, 295 BUTTONEX OButton_6 ;
CAPTION "Sheep" ;
ICON "sheep" ;
VERTICAL ;
FLAT ;
WIDTH 80 ;
HEIGHT 80 ;
FONT "MS Sans serif" SIZE 9 ;
FONTCOLOR {128,0,0} ;
BOLD ;
BACKCOLOR WHITE ;
ACTION {|| TONE(600)} TOOLTIP "OButton_6 Image button (icon) - vertical - flat"
END WINDOW
CENTER WINDOW Form_1
ACTIVATE WINDOW Form_1
Return NIL
Function DisableAllButtons()
Local i
For i = 1 to len( _HMG_aControlType)
if AT("BUTTON", _HMG_aControlType [i]) >0
_DisableControl ( _HMG_aControlNames[i] , "Form_1" )
endif
next i
Return NIL
Function EnableAllButtons()
Local i
For i = 1 to len( _HMG_aControlType)
if AT("BUTTON", _HMG_aControlType [i]) >0
_EnableControl ( _HMG_aControlNames[i] , "Form_1" )
endif
next i
Return NIL
/* ----------------------------------------------------------- */
#define PBS_NORMAL 1
#define PBS_HOT 2
#define PBS_PRESSED 3
#define PBS_DISABLED 4
#define PBS_DEFAULTED 5
#define ODT_BUTTON 4
#define ODS_SELECTED 1
#define ODS_GRAYED 2
#define ODS_DISABLED 4
#define ODS_CHECKED 8
#define ODS_FOCUS 16
#define ODS_DEFAULT 32
#define ODS_COMBOBOXEDIT 4096
#define ODS_HOTLIGHT 64
#define ODS_INACTIVE 128
#define DFCS_BUTTONPUSH 16
#define DFCS_INACTIVE 256
#define COLOR_HIGHLIGHTTEXT 14
#define COLOR_BTNFACE 15
#define COLOR_BTNSHADOW 16
#define COLOR_GRAYTEXT 17
#define COLOR_BTNTEXT 18
#define COLOR_INACTIVECAPTIONTEXT 19
#define COLOR_BTNHIGHLIGHT 20
#define COLOR_3DDKSHADOW 21
#define COLOR_3DLIGHT 22
#define COLOR_INFOTEXT 23
#define COLOR_INFOBK 24
#define COLOR_HOTLIGHT 26
#define COLOR_GRADIENTACTIVECAPTION 27
#define COLOR_GRADIENTINACTIVECAPTION 28
#define COLOR_DESKTOP COLOR_BACKGROUND
#define COLOR_3DFACE COLOR_BTNFACE
#define COLOR_3DSHADOW COLOR_BTNSHADOW
#define COLOR_3DHIGHLIGHT COLOR_BTNHIGHLIGHT
#define COLOR_3DHILIGHT COLOR_BTNHIGHLIGHT
#define COLOR_BTNHILIGHT COLOR_BTNHIGHLIGHT
#define DT_TOP 0
#define DT_LEFT 0
#define DT_CENTER 1
#define DT_RIGHT 2
#define DT_VCENTER 4
#define DT_BOTTOM 8
#define DT_SINGLELINE 32
#define DFCS_PUSHED 512
#define DFCS_CHECKED 1024
#define DFCS_TRANSPARENT 2048
#define DFCS_HOT 4096
#define DFCS_ADJUSTRECT 8192
#define DFCS_FLAT 16384
#define DFCS_MONO 32768
#define TRANSPARENT 1
#define DST_COMPLEX 0
#define DST_TEXT 1
#define DST_PREFIXTEXT 2
#define DST_ICON 3
#define DST_BITMAP 4
// State type
#define DSS_NORMAL 0
#define DSS_UNION 16 // Gray string appearance
#define DSS_DISABLED 32
#define DSS_MONO 128
#define DSS_HIDEPREFIX 512
#define DSS_PREFIXONLY 1024
#define DSS_RIGHT 32768
/*
* Owner draw actions
*/
#define ODA_DRAWENTIRE 1
#define ODA_SELECT 2
#define ODA_FOCUS 4
#define WM_COMMAND 0x0111
#define WM_SETFOCUS 7
#define WM_DRAWITEM 43
#define WM_LBUTTONDOWN 513
#define WM_MOUSELEAVE 675
#define WM_MOUSEMOVE 512
/* Ascpects for owner butons */
#define OBT_HORIZONTAL 0
#define OBT_VERTICAL 1
#define OBT_LEFTTEXT 2
#define OBT_UPTEXT 4
#define OBT_HOTLIGHT 8
#define OBT_FLAT 16
#define OBT_NOTRANSPARENT 32
#define OBT_NOXPSTYLE 64
#define OBT_ADJUST 128
#define BS_NOTIFY 0x00004000
#define BS_PUSHBUTTON 0x00000000
#define BS_FLAT 0x00008000
#define BS_BITMAP 0x00000080
#define WS_TABSTOP 0x00010000
#define WS_VISIBLE 0x10000000
#define WS_CHILD 0x40000000
* HMG 1.0 Experimental Build 9a (JK)
* (C) 2005 Jacek Kubica <kubica@wssk.wroc.pl>
*------------------------------------------------------------------------------*
FUNCTION OwnButtonPaint( pdis )
*------------------------------------------------------------------------------*
Local hDC, itemState, itemAction, i, rgbTrans, hWnd, lFlat, lNotrans
Local oldBkMode, oldTextColor , hOldFont, hBrush,nFreeSpace:=0
Local x1:=0, y1:=0, x2:=0, y2:=0, xp1:=0, yp1:=0, xp2:=0, yp2:=0
Local aBmp:={},aMetr:={},aBtnRc:={}
LOCAL lDisabled, lSelected, lFocus, lDrawEntire, loFocus, loSelect
LOCAL hTheme, nStyle, lnoxpstyle:=.f.
LOCAL pozYpic := 0, pozYtext:=0, xPoz:=0, dState := 0
Local nCRLF, lXPThemeActive := .f.
hDC := GETOWNBTNDC( pdis )
if empty( hDC ) .or. hDC == 0
return ( 1 )
endif
IF GETOWNBTNCTLTYPE( pdis ) <> ODT_BUTTON
return ( 1 )
endif
itemAction := GETOWNBTNITEMACTION ( pdis )
lDrawEntire := AND( itemAction, ODA_DRAWENTIRE ) == ODA_DRAWENTIRE
loFocus := AND( itemAction, ODA_FOCUS ) == ODA_FOCUS
loSelect := AND( itemAction, ODA_SELECT ) == ODA_SELECT
if ! lDrawEntire .and. ! loFocus .and. ! loSelect
return ( 1 )
endif
hWnd := GETOWNBTNHANDLE( pdis )
aBtnRc := GETOWNBTNRECT( pdis )
itemState := GETOWNBTNSTATE( pdis )
i := ascan ( _HMG_aControlHandles , hWnd )
if ( i <= 0 .or. _HMG_aControlType[ i ] <> "OBUTTON" )
return ( 1 )
endif
nCRLF := CountIt( _HMG_aControlCaption[ i ] ) + 1
lDisabled := AND( itemState, ODS_DISABLED ) == ODS_DISABLED
lSelected := AND( itemState, ODS_SELECTED ) == ODS_SELECTED
lFocus := AND( itemState, ODS_FOCUS ) == ODS_FOCUS
lFlat := AND( _HMG_aControlSpacing [ i ], OBT_FLAT ) == OBT_FLAT
lNotrans := AND( _HMG_aControlSpacing [ i ], OBT_NOTRANSPARENT ) == OBT_NOTRANSPARENT
lnoxpstyle := AND( _HMG_aControlSpacing [ i ], OBT_NOXPSTYLE ) == OBT_NOXPSTYLE
if ! lNotrans
rgbTrans := NIL
else
if ! EMPTY( _HMG_aControlBkColor [ i ] ) .and. ! lXPThemeActive
rgbTrans := RGB( _HMG_aControlBkColor [ i, 1 ], _HMG_aControlBkColor [ i, 2 ], _HMG_aControlBkColor [ i, 3 ] )
else
rgbTrans := GetSysColor ( COLOR_BTNFACE )
endif
endif
hOldFont := SelectObject( hDC, _HMG_aControlFontHandle [ i ] )
aMetr := GetTextMetric( hDC )
oldBkMode := SetBkMode( hDC, TRANSPARENT )
oldTextColor := SetTextColor( hDC, GetRed ( GetSysColor ( COLOR_BTNTEXT ) ) , GetGreen ( GetSysColor ( COLOR_BTNTEXT ) ) , GetBlue ( GetSysColor ( COLOR_BTNTEXT ) ) )
if ! lDisabled
if EMPTY( _HMG_aControlFontColor [ i ] )
SetTextColor( hDC, GetRed ( GetSysColor ( COLOR_BTNTEXT ) ) , GetGreen ( GetSysColor ( COLOR_BTNTEXT ) ) , GetBlue ( GetSysColor ( COLOR_BTNTEXT ) ) )
else
SetTextColor( hDC, _HMG_aControlFontColor [ i, 1 ], _HMG_aControlFontColor [ i, 2 ], _HMG_aControlFontColor [ i, 3 ] )
endif
if ! EMPTY( _HMG_aControlBkColor [ i ] ) .and. ! lXPThemeActive
// paint button background
if lSelected
FillGradient( hDC, aBtnRc[ 2 ], aBtnRc[ 1 ], aBtnRc[ 3 ], aBtnRc[ 3 ], .T., RGB(203, 225, 252), RGB(126, 166, 225))
elseif ! ( _HMG_aControlRangeMax [ i ] == 1 )
FillGradient( hDC, aBtnRc[ 2 ], aBtnRc[ 1 ], aBtnRc[ 4 ], aBtnRc[ 3 ], .T., RGB(255, 255, 220), RGB(247, 192, 91))
else
FillGradient( hDC, aBtnRc[ 2 ], aBtnRc[ 1 ], aBtnRc[ 4 ], aBtnRc[ 3 ], .T., RGB(239, 150, 21), RGB(251, 230, 148))
endif
endif
endif
if _HMG_aControlMiscData1 [ i ] == 0 .and. ! EMPTY( _HMG_aControlBrushHandle [ i ] )
aBmp := GetBitmapSize( _HMG_aControlBrushHandle [ i ] )
elseif _HMG_aControlMiscData1 [ i ] == 1 .and. ! EMPTY( _HMG_aControlBrushHandle [ i ] )
aBmp := GetIconSize( _HMG_aControlBrushHandle [ i ] )
endif
if AND( _HMG_aControlSpacing [ i ], OBT_VERTICAL ) == OBT_VERTICAL
// vertical text/picture aspect
x1 := aBtnRc[ 1 ] + 2
y2 := aMetr[ 1 ]*nCRLF
y1 := Round( ( aBtnRc[ 4 ] - aBtnRc[ 2 ] - aMetr[ 1 ] ) / 2, 0 )
x2 := aBtnRc[ 3 ] - 2
yp1 := Round( y1 / 2, 0 )
xp2 := IIF( ! EMPTY( aBmp ), aBmp[ 1 ], 0 ) // picture width
yp2 := IIF( ! EMPTY( aBmp ), aBmp[ 2 ], 0 ) // picture height
xp1 := ROUND( ( aBtnRc[ 3 ] / 2 ) - ( xp2 / 2 ), 0 )
If AT( CRLF, _HMG_aControlCaption[ i ] ) <= 0
nFreeSpace := ROUND( ( aBtnRc[ 4 ] - 4 - ( aMetr[ 4 ] + yp2 ) ) / 3, 0 )
nCRLF:=1
else
y1 := max( ( ( aBtnRc[ 4 ] ) / 2 ) - ( nCRLF * aMetr[ 1 ] ) / 2, 1 )
nFreeSpace := ROUND( ( aBtnRc[ 4 ] - 4 - ( y2 + yp2 ) ) / 3, 0 )
endif
if !EMPTY( _HMG_aControlCaption[ i ] ) // button has caption
If !EMPTY( _HMG_aControlBrushHandle [ i ] )
if !( AND( _HMG_aControlSpacing [ i ], OBT_UPTEXT ) == OBT_UPTEXT ) // upper text aspect not set
pozYpic := max( aBtnRc[ 2 ] + nFreeSpace, 5 )
pozYtext := aBtnRc[ 2 ] + IIF( ! EMPTY( aBmp ), nFreeSpace, 0 ) + yp2 + IIF( ! EMPTY( aBmp ), nFreeSpace, 0 ) //+ nFreeSpace+2 // +ROUND(aMetr[1]/2,0)
else
pozYtext := max( aBtnRc[ 2 ] + nFreeSpace, 5 )
aBtnRc[ 4 ] := nFreeSpace + ( ( aMetr[ 1 ] ) * nCRLF ) + nFreeSpace
pozYpic := aBtnRc[ 4 ]
endif
else
pozYpic := 0
pozYtext := ROUND((aBtnRc[ 4 ] - y2) / 2,0)
endif
else // button without caption
if ! ( AND( _HMG_aControlSpacing [ i ], OBT_ADJUST ) == OBT_ADJUST )
pozYpic := Round( ( ( aBtnRc[ 4 ] / 2 ) - ( yp2 / 2 ) ), 0 )
pozYtext := 0
else // strech image
pozYpic := 1
endif
endif
if ! lDisabled
if lSelected // vertical selected
If ! lXPThemeActive
xp1 ++
xPoz := 2
pozYtext ++
pozYpic ++
else
xPoz := 0
endif
if ! ( AND( _HMG_aControlSpacing [ i ], OBT_ADJUST ) == OBT_ADJUST )
DrawGlyph( hDC, xp1, pozYpic , xp2, yp2 , _HMG_aControlBrushHandle [ i ] , rgbTrans , .f., .f. )
DrawText( hDC, _HMG_aControlCaption[ i ], xPoz , pozYtext-1 , x2, aBtnRc[ 4 ] , DT_CENTER )
else
DrawGlyph( hDC, aBtnRc[ 1 ] + 4, aBtnRc[ 2 ] + 4 , aBtnRc[ 3 ] - 6, aBtnRc[ 4 ] - 6 , _HMG_aControlBrushHandle [ i ] , rgbTrans , .f., .t. )
endif
else // vertical non selected
if ! ( AND( _HMG_aControlSpacing [ i ], OBT_ADJUST ) == OBT_ADJUST )
DrawGlyph( hDC, xp1, pozYpic, xp2, yp2 , _HMG_aControlBrushHandle [ i ] , rgbTrans , .f., .f. )
DrawText( hDC, _HMG_aControlCaption[ i ], 0 , pozYtext-1 , x2, aBtnRc[ 4 ], DT_CENTER )
else
DrawGlyph( hDC, aBtnRc[ 1 ] + 3, aBtnRc[ 2 ] + 3 , aBtnRc[ 3 ] - 6, aBtnRc[ 4 ] - 6 , _HMG_aControlBrushHandle [ i ] , rgbTrans , .f., .t. )
endif
endif
else // vertical disabled
if ! ( AND( _HMG_aControlSpacing [ i ], OBT_ADJUST ) == OBT_ADJUST )
DrawGlyph( hDC, xp1, pozYpic, xp2, yp2 , _HMG_aControlBrushHandle [ i ] , , .t., .f. )
// disabled vertical
SetTextColor( hDC, GetRed ( GetSysColor ( COLOR_3DHILIGHT ) ) , GetGreen ( GetSysColor ( COLOR_3DHILIGHT ) ) , GetBlue ( GetSysColor ( COLOR_3DHILIGHT ) ) )
DrawText( hDC, _HMG_aControlCaption[ i ], 2, pozYtext + 1 , x2, aBtnRc[ 4 ] + 1, DT_CENTER )
SetTextColor( hDC, GetRed ( GetSysColor ( COLOR_3DSHADOW ) ) , GetGreen ( GetSysColor ( COLOR_3DSHADOW ) ) , GetBlue ( GetSysColor ( COLOR_3DSHADOW ) ) )
DrawText( hDC, _HMG_aControlCaption[ i ], 0, pozYtext, x2, aBtnRc[ 4 ], DT_CENTER )
else
DrawGlyph( hDC, aBtnRc[ 1 ] + 4, aBtnRc[ 2 ] + 4 , aBtnRc[ 3 ] - 6, aBtnRc[ 4 ] - 6 , _HMG_aControlBrushHandle [ i ] , , .t., .t. )
endif
endif
else
if ! EMPTY( _HMG_aControlBrushHandle [ i ] ) // horizontal
if ! EMPTY( _HMG_aControlCaption[ i ] )
if ! ( AND( _HMG_aControlSpacing [ i ], OBT_LEFTTEXT ) == OBT_LEFTTEXT )
xp1 := 5
xp2 := IIF( ! EMPTY( aBmp ), aBmp[ 1 ], 0 )
yp2 := IIF( ! EMPTY( aBmp ), aBmp[ 2 ], 0 )
yp1 := Round( ( ( aBtnRc[ 4 ] / 2 ) - ( yp2 / 2 ) ), 0 )
x1 := aBtnRc[ 1 ] + xp1 + xp2
y1 := Round( aBtnRc[ 4 ] / 2, 0 ) - ( aMetr[ 1 ] - 10 )
x2 := aBtnRc[ 3 ] - 2
y2 := y1 + aMetr[ 1 ]
else
xp1 := aBtnRc[ 3 ] - IIF( ! EMPTY( aBmp ), aBmp[ 1 ], 0 ) - 5
xp2 := IIF( ! EMPTY( aBmp ), aBmp[ 1 ], 0 )
yp2 := IIF( ! EMPTY( aBmp ), aBmp[ 2 ], 0 )
yp1 := Round( ( ( aBtnRc[ 4 ] / 2 ) - ( yp2 / 2 ) ), 0 )
x1 := 3
y1 := Round( aBtnRc[ 4 ] / 2, 0 ) - ( aMetr[ 1 ] - 10 )
x2 := aBtnRc[ 3 ] - xp2
y2 := y1 + aMetr[ 1 ]
endif
else
x1 := aBtnRc[ 1 ] + xp1 + xp2
y1 := Round( aBtnRc[ 4 ] / 2, 0 ) - ( aMetr[ 1 ] - 10 )
x2 := aBtnRc[ 3 ] - 2
y2 := y1 + aMetr[ 1 ]
xp2 := IIF( ! EMPTY( aBmp ), aBmp[ 1 ], 0 ) // picture width
yp2 := IIF( ! EMPTY( aBmp ), aBmp[ 2 ], 0 ) // picture height
xp1 := ROUND( ( aBtnRc[ 3 ] / 2 ) - ( xp2 / 2 ), 0 )
yp1 := Round( ( ( aBtnRc[ 4 ] / 2 ) - ( yp2 / 2 ) ), 0 )
endif
else
xp1 := 2
xp2 := 0
yp1 := 0
yp2 := 0
x1 := aBtnRc[ 1 ] + xp1 + xp2
y1 := Round( aBtnRc[ 4 ] / 2, 0 ) - ( aMetr[ 1 ] - 10 )
x2 := aBtnRc[ 3 ] - 2
y2 := y1 + aMetr[ 1 ]
endif
if ! ( AND( _HMG_aControlSpacing [ i ], OBT_ADJUST ) == OBT_ADJUST )
y1 := max(( ( ( aBtnRc[ 4 ] ) / 2 ) - ( nCRLF * aMetr[ 1 ] ) / 2)-1, 1 )
y2 := ( aMetr[ 1 ] + aMetr[ 5 ] ) * nCRLF
else
pozYpic := 1
endif
if ! lDisabled
if lSelected
If ! lXPThemeActive
x1 := x1 + 2
// y1 := 3
xp1 ++
yp1 ++
else
// y1 := 1
xPoz := 0
endif
if ! ( AND( _HMG_aControlSpacing [ i ], OBT_ADJUST ) == OBT_ADJUST )
DrawGlyph( hDC, xp1, yp1, xp2, yp2 , _HMG_aControlBrushHandle [ i ] , rgbTrans, .f., .f. )
DrawText( hDC, _HMG_aControlCaption[ i ], x1, y1 + 1, x2, y1 + y2 , DT_CENTER )
else
DrawGlyph( hDC, aBtnRc[ 1 ] + 4, aBtnRc[ 2 ] + 4 , aBtnRc[ 3 ] - 6, aBtnRc[ 4 ] - 6 , _HMG_aControlBrushHandle [ i ] , rgbTrans , .f., .t. )
endif
else
if ! ( AND( _HMG_aControlSpacing [ i ], OBT_ADJUST ) == OBT_ADJUST )
DrawGlyph( hDC, xp1, yp1, xp2, yp2 , _HMG_aControlBrushHandle [ i ] , rgbTrans , .f., .f. )
DrawText( hDC, _HMG_aControlCaption[ i ], x1, y1, x2, y1 + y2, DT_CENTER )
else
DrawGlyph( hDC, aBtnRc[ 1 ] + 3, aBtnRc[ 2 ] + 3 , aBtnRc[ 3 ] - 6, aBtnRc[ 4 ] - 6 , _HMG_aControlBrushHandle [ i ] , rgbTrans , .f., .t. )
endif
endif
else
// disabled horizontal
if ! ( AND( _HMG_aControlSpacing [ i ], OBT_ADJUST ) == OBT_ADJUST )
DrawGlyph( hDC, xp1, yp1, xp2, yp2 , _HMG_aControlBrushHandle [ i ] , , .t., .f. )
SetTextColor( hDC, GetRed ( GetSysColor ( COLOR_3DHILIGHT ) ) , GetGreen ( GetSysColor ( COLOR_3DHILIGHT ) ) , GetBlue ( GetSysColor ( COLOR_3DHILIGHT ) ) )
DrawText( hDC, _HMG_aControlCaption[ i ], x1 + 1, y1 + 1, x2 + 1, y1 + y2 + 1, DT_CENTER )
SetTextColor( hDC, GetRed ( GetSysColor ( COLOR_3DSHADOW ) ) , GetGreen ( GetSysColor ( COLOR_3DSHADOW ) ) , GetBlue ( GetSysColor ( COLOR_3DSHADOW ) ) )
DrawText( hDC, _HMG_aControlCaption[ i ], x1, y1, x2, y1 + y2 , DT_CENTER )
else
DrawGlyph( hDC, aBtnRc[ 1 ] + 3, aBtnRc[ 2 ] + 3 , aBtnRc[ 3 ] - 6, aBtnRc[ 4 ] - 6 , _HMG_aControlBrushHandle [ i ] , , .t., .t. )
endif
endif
endif
if ( lSelected .or. lFocus ) .and. ! lDisabled .and. ! lXPThemeActive
SetTextColor( hDC, GetRed ( GetSysColor ( COLOR_BTNTEXT ) ) , GetGreen ( GetSysColor ( COLOR_BTNTEXT ) ) , GetBlue ( GetSysColor ( COLOR_BTNTEXT ) ) )
DrawFocusRect( pdis )
endif
SelectObject( hDC, hOldFont )
SetBkMode( hDC, oldBkMode )
SetTextColor( hDC, oldTextColor )
return ( 1 )
*-----------------------------------------------------------------------------*
Static Function CountIt(cText)
*-----------------------------------------------------------------------------*
Local nPoz := 1, nCount := 0
If At(CRLF, cText) > 0
Do while .t.
nPoz := At(CRLF, cText)
if nPoz > 0
nCount++
cText := Substr(cText, nPoz+2)
else
exit
endif
enddo
endif
Return nCount- Anexos
-
demo4.rar- (481.5 KiB) Baixado 268 vezes
Um clip-abraço !
Pablo César Arrascaeta
Compartilhe suas dúvidas e soluções com todos os colegas aqui do fórum.
Evite enviar as dúvidas técnicas por MPs ou eMails, assim todos iremos beneficiar-nos.
Pablo César Arrascaeta
Compartilhe suas dúvidas e soluções com todos os colegas aqui do fórum.
Evite enviar as dúvidas técnicas por MPs ou eMails, assim todos iremos beneficiar-nos.
- Toledo
- Administrador

- Mensagens: 3133
- Registrado em: 22 Jul 2003 18:39
- Localização: Araçatuba - SP
- Contato:
Mandar foco para bottonex
Alexandre, você já tentou usar nomedobotao:setfocus()?
Abraços,
Abraços,
Toledo - Clipper On Line
toledo@pctoledo.com.br
Harbour 3.2/MiniGui/HwGui
Faça uma doação para o fórum, clique neste link: http://www.pctoledo.com.br/doacao
toledo@pctoledo.com.br
Harbour 3.2/MiniGui/HwGui
Faça uma doação para o fórum, clique neste link: http://www.pctoledo.com.br/doacao
Mandar foco para bottonex
Tentei, e nada acontece!Toledo escreveu:Alexandre, você já tentou usar nomedobotao:setfocus()?
Vou tentar pelo seu exemplo.
►Harbour 3.x | Minigui xx-x | HwGui◄
Pense nas possibilidades abstraia as dificuldades.
Não corrigir nossas falhas é o mesmo que cometer novos erros.
A imaginação é mais importante que o conhecimento. (Albert Einstein)
Pense nas possibilidades abstraia as dificuldades.
Não corrigir nossas falhas é o mesmo que cometer novos erros.
A imaginação é mais importante que o conhecimento. (Albert Einstein)
Mandar foco para bottonex
Toledo esta é a função que eu estou tentando colocar o foco no botão sair.
Código: Selecionar todos
FUNCTION ConsultaCep( cVar0, cVar1, cVar2, cVar3, cVar4 )
LOCAL oDlg, oEdit, oHttp, cMess:="", oPg
LOCAL oIconSair := HIcon():AddResource("ICON_SAIR")
LOCAL oIconExportar:= HIcon():AddResource("ICON_EXPORTAR")
IF Empty(cVar0)
RETURN .T.
ENDIF
INIT DIALOG oDlg TITLE "Consulta por CEP" ;
ICON HIcon():AddResource("ICON_CEP") ;
AT 0,0 SIZE 605,200 ;
FONT HFont():Add( 'Courier New',0,-13,500,,,) CLIPPER NOEXIT ;
STYLE DS_CENTER +WS_SYSMENU+WS_VISIBLE
SetToolTipBalloon(.t.)
oPg:=Win_OleCreateObject("Microsoft.XMLHTTP")
oPg:Open("GET","http://cep.republicavirtual.com.br/web_cep.php?cep=" + cVar0 + "&formato=xml",.F.)
oPg:Send()
oXMLDoc:=oPg:responseXML //Resposta Document Object Model XML//responseBody //ResponseText
lResp :=IIF(oXMLDoc:getElementsByTagName( "resultado" ):item(0):Text="1",.T.,.F.)
IF !lResp
Pare("CEP nÆo encontrado.")
cVar0 :=Space(8)
cCid :="RIO DE JANEIRO"
cUF :="RJ"
EndDialog()
RETURN .T.
ENDIF
cResTxt:=Upper(oXMLDoc:getElementsByTagName( "resultado_txt" ):item(0):Text)
cTipo :=Upper(oXMLDoc:getElementsByTagName( "tipo_logradouro" ):item(0):Text)
cEnd :=RetiraAcentos(Upper(cTipo+" "+oXMLDoc:getElementsByTagName( "logradouro" ):item(0):Text))
cBai :=RetiraAcentos(Upper(oXMLDoc:getElementsByTagName( "bairro" ):item(0):Text))
cCid :=RetiraAcentos(Upper(oXMLDoc:getElementsByTagName( "cidade" ):item(0):Text))
cUF :=Upper(oXMLDoc:getElementsByTagName( "uf" ):item(0):Text)
cMess += "Resposta do servidor.: "+HB_OemtoAnsi(cResTxt) + HB_OsNewLine()
cMess += "Tipo de logradouro...: "+HB_OemtoAnsi(cTipo) + HB_OsNewLine()
cMess += "Logradouro...........: "+HB_OemtoAnsi(cEnd) + HB_OsNewLine()
cMess += "Bairro...............: "+HB_OemtoAnsi(cBai) + HB_OsNewLine()
cMess += "Cidade...............: "+HB_OemtoAnsi(cCid) + HB_OsNewLine()
cMess += "UF...................: "+HB_OemtoAnsi(cUF) + HB_OsNewLine()
@ 10, 10 EDITBOX oEdit CAPTION cMess SIZE 580, 95 STYLE + ES_MULTILINE + ES_READONLY + WS_BORDER ;
COLOR RGB(0,0,254) ;
FONT HFont():Add( 'Courier New',0,-15,500,,,);
ON GETFOCUS { || Focaliza(), SendMessage( oEdit:handle, EM_SETSEL, 0, 0 )};
BACKCOLOR RGB(211,237,250)
@ 10,120 BUTTONEX btnExportar CAPTION "&Exportar" ON CLICK { || cVar1:=PADR(cEnd,40," "), cVar2:=PADR(cBai,12," "), cVar3:=PADR(cCid,16," "), cVar4:=PADR(cUF,2," "), EndDialog()} SIZE 110, 40 ;
ICON oIconExportar:handle ;
TOOLTIP 'Clique aqui para exportar os dados da consulta.'
@ 475,120 BUTTONEX btnSair CAPTION "Sair" ON CLICK { || EndDialog()} SIZE 110, 40 ;
ICON oIconSair:handle ;
TOOLTIP 'Clique aqui para sair.'
oDlg:Activate()
RETURN .T.
FUNCTION Focaliza()
btnSair:setfocus()
Return .T.
►Harbour 3.x | Minigui xx-x | HwGui◄
Pense nas possibilidades abstraia as dificuldades.
Não corrigir nossas falhas é o mesmo que cometer novos erros.
A imaginação é mais importante que o conhecimento. (Albert Einstein)
Pense nas possibilidades abstraia as dificuldades.
Não corrigir nossas falhas é o mesmo que cometer novos erros.
A imaginação é mais importante que o conhecimento. (Albert Einstein)
-
alxsts
- Colaborador

- Mensagens: 3092
- Registrado em: 12 Ago 2008 15:50
- Localização: São Paulo-SP-Brasil
Mandar foco para bottonex
Olá!
Chutando: tente colocar isto no botão STYLE WS_TABSTOP
Chutando: tente colocar isto no botão STYLE WS_TABSTOP
[]´s
Alexandre Santos (AlxSts)
Alexandre Santos (AlxSts)
Mandar foco para bottonex
Olá AlxSts,
Tentei o STYLE WS_TABSTOP e nada.
Uma coisa que eu estou percebendo é que tem um cursor no editbox
Vejam o cursor entre o R e o e de "R|esposta" e nenhum foco no botão Sair
Outra coisa, estou forçando no getfocus do editbox a função focaliza() que faz: btnsair:setfocus()

Tentei o STYLE WS_TABSTOP e nada.
Uma coisa que eu estou percebendo é que tem um cursor no editbox
Vejam o cursor entre o R e o e de "R|esposta" e nenhum foco no botão Sair
Outra coisa, estou forçando no getfocus do editbox a função focaliza() que faz: btnsair:setfocus()
Código: Selecionar todos
@ 10, 10 EDITBOX oEdit CAPTION cMess SIZE 580, 95 STYLE + ES_MULTILINE + ES_READONLY + WS_BORDER ;
COLOR RGB(0,0,254) ;
FONT HFont():Add( 'Courier New',0,-15,500,,,);
ON INIT {||btnSair:SetFocus()};
ON GETFOCUS { || Focaliza(), SendMessage( oEdit:handle, EM_SETSEL, 0, 0 )};
BACKCOLOR RGB(211,237,250)

►Harbour 3.x | Minigui xx-x | HwGui◄
Pense nas possibilidades abstraia as dificuldades.
Não corrigir nossas falhas é o mesmo que cometer novos erros.
A imaginação é mais importante que o conhecimento. (Albert Einstein)
Pense nas possibilidades abstraia as dificuldades.
Não corrigir nossas falhas é o mesmo que cometer novos erros.
A imaginação é mais importante que o conhecimento. (Albert Einstein)
Mandar foco para bottonex
@ 10, 10 EDITBOX oEdit CAPTION cMess SIZE 580, 95 STYLE + ES_MULTILINE + ES_READONLY + WS_BORDER ;
2 COLOR RGB(0,0,254) ;
3 FONT HFont():Add( 'Courier New',0,-15,500,,,);
4 ON INIT {||btnSair:SetFocus()};
5 ON GETFOCUS { || Focaliza(), SendMessage( oEdit:handle, EM_SETSEL, 0, 0 )};
6 BACKCOLOR RGB(211,237,250)
7
no init do editbox não ira setar o foco porque ele ocorr antes do init do dialog e quem set o foco inicial é o dialog
no getfocus coloque um .f. no final para ele não pegar o foco
5 ON GETFOCUS { || Focaliza(), SendMessage( oEdit:handle, EM_SETSEL, 0, 0 ),.F.};
NO buttonex É NECESSARIO O STYLE WS_TABSTOP
2 COLOR RGB(0,0,254) ;
3 FONT HFont():Add( 'Courier New',0,-15,500,,,);
4 ON INIT {||btnSair:SetFocus()};
5 ON GETFOCUS { || Focaliza(), SendMessage( oEdit:handle, EM_SETSEL, 0, 0 )};
6 BACKCOLOR RGB(211,237,250)
7
no init do editbox não ira setar o foco porque ele ocorr antes do init do dialog e quem set o foco inicial é o dialog
no getfocus coloque um .f. no final para ele não pegar o foco
5 ON GETFOCUS { || Focaliza(), SendMessage( oEdit:handle, EM_SETSEL, 0, 0 ),.F.};
NO buttonex É NECESSARIO O STYLE WS_TABSTOP
Luis Fernando Basso
Desenvolvedor VFP + XHARBOUR + HWGUI
lfbasso@gmail.com
http://www.engersoft.com.br
Desenvolvedor VFP + XHARBOUR + HWGUI
lfbasso@gmail.com
http://www.engersoft.com.br
Mandar foco para bottonex
Olá Esbasso,
Já havia colocado o STYLE WS_TABSTOP, mas não resolveu, o foco continua no EDITBOX
Mesmo informando o .F. no GETFOCUS o foco continua no EDITBOX.
Já havia colocado o STYLE WS_TABSTOP, mas não resolveu, o foco continua no EDITBOX
Mesmo informando o .F. no GETFOCUS o foco continua no EDITBOX.
Código: Selecionar todos
@ 10, 10 EDITBOX oEdit CAPTION cMess SIZE 580, 95 STYLE + ES_MULTILINE + ES_READONLY + WS_BORDER ;
COLOR RGB(0,0,254) ;
ON GETFOCUS { ||Focaliza(),.F.};
FONT HFont():Add( 'Courier New',0,-15,500,,,);
BACKCOLOR RGB(211,237,250)
@ 475,120 BUTTONEX btnSair CAPTION "Sair" ON CLICK { || EndDialog()} SIZE 110, 40 ;
ICON oIconSair:handle ;
TOOLTIP 'Clique aqui para sair.' ;
STYLE WS_TABSTOP
FUNCTION Focaliza()
btnSair:setfocus()
Return .F.
►Harbour 3.x | Minigui xx-x | HwGui◄
Pense nas possibilidades abstraia as dificuldades.
Não corrigir nossas falhas é o mesmo que cometer novos erros.
A imaginação é mais importante que o conhecimento. (Albert Einstein)
Pense nas possibilidades abstraia as dificuldades.
Não corrigir nossas falhas é o mesmo que cometer novos erros.
A imaginação é mais importante que o conhecimento. (Albert Einstein)
Mandar foco para bottonex
Esbasso,
Mudei o botão deposição e funcionou veja:
Pergunto: está certo isso? o foco não deveria ser em qualquer posição dos componentes? está dando a impressão que o editbox não esta "vendo" o botão porque ele estava após?
Mudei o botão deposição e funcionou veja:
Código: Selecionar todos
@ 475,120 BUTTONEX btnSair CAPTION "Sair" ON CLICK { || EndDialog()} SIZE 110, 40 ;
ICON oIconSair:handle ;
TOOLTIP 'Clique aqui para sair.' ;
STYLE WS_TABSTOP
@ 10, 10 EDITBOX oEdit CAPTION cMess SIZE 580, 95 STYLE ES_MULTILINE + ES_READONLY + WS_BORDER ;
COLOR RGB(0,0,254) ;
ON GETFOCUS { || SendMessage( oEdit:handle, EM_SETSEL, 0, 0 ),Focaliza(),.F.};
FONT HFont():Add( 'Courier New',0,-15,500,,,);
BACKCOLOR RGB(211,237,250)
►Harbour 3.x | Minigui xx-x | HwGui◄
Pense nas possibilidades abstraia as dificuldades.
Não corrigir nossas falhas é o mesmo que cometer novos erros.
A imaginação é mais importante que o conhecimento. (Albert Einstein)
Pense nas possibilidades abstraia as dificuldades.
Não corrigir nossas falhas é o mesmo que cometer novos erros.
A imaginação é mais importante que o conhecimento. (Albert Einstein)
Mandar foco para bottonex
mude o teu editbox para um get E O ON GETFOCUS PARA WHEN
@ 390,208 GET oMemo1 VAR vMemo1 SIZE 205,102 ;
@ 10, 10 GET oEdit VAR cMess SIZE 580, 95 STYLE ES_MULTILINE + ES_READONLY + WS_BORDER ;
07 COLOR RGB(0,0,254) ;
08 WHEN { || SendMessage( oEdit:handle, EM_SETSEL, 0, 0 ),Focaliza(),.F.};
09 FONT HFont():Add( 'Courier New',0,-15,500,,,);
10 BACKCOLOR RGB(211,237,250)
o foco na inicialização de um DIALOG é sempre posicionado no primeiro objeto que tem WS_TABSTOP.
Alguns objetos já tem WS_TABSTOP por DEFAULT
vOCE pode mudar o foco inicial ao carregar o DIALOG da seguinta forma
INIT DIALOG oDlg TITLE "Consulta por CEP" ;
11 ICON HIcon():AddResource("ICON_CEP") ;
12 AT 0,0 SIZE 605,200 ;
13 FONT HFont():Add( 'Courier New',0,-13,500,,,) CLIPPER NOEXIT ;
14 STYLE DS_CENTER +WS_SYSMENU+WS_VISIBLE;
ON INIT {| odlg | odlg:ninitfocus := btnsair
15
@ 390,208 GET oMemo1 VAR vMemo1 SIZE 205,102 ;
@ 10, 10 GET oEdit VAR cMess SIZE 580, 95 STYLE ES_MULTILINE + ES_READONLY + WS_BORDER ;
07 COLOR RGB(0,0,254) ;
08 WHEN { || SendMessage( oEdit:handle, EM_SETSEL, 0, 0 ),Focaliza(),.F.};
09 FONT HFont():Add( 'Courier New',0,-15,500,,,);
10 BACKCOLOR RGB(211,237,250)
o foco na inicialização de um DIALOG é sempre posicionado no primeiro objeto que tem WS_TABSTOP.
Alguns objetos já tem WS_TABSTOP por DEFAULT
vOCE pode mudar o foco inicial ao carregar o DIALOG da seguinta forma
INIT DIALOG oDlg TITLE "Consulta por CEP" ;
11 ICON HIcon():AddResource("ICON_CEP") ;
12 AT 0,0 SIZE 605,200 ;
13 FONT HFont():Add( 'Courier New',0,-13,500,,,) CLIPPER NOEXIT ;
14 STYLE DS_CENTER +WS_SYSMENU+WS_VISIBLE;
ON INIT {| odlg | odlg:ninitfocus := btnsair
15
Luis Fernando Basso
Desenvolvedor VFP + XHARBOUR + HWGUI
lfbasso@gmail.com
http://www.engersoft.com.br
Desenvolvedor VFP + XHARBOUR + HWGUI
lfbasso@gmail.com
http://www.engersoft.com.br
Mandar foco para bottonex
Olá Esbasso,
A sua dica já resolveu:
Voltei os componentes a sua ordem original e funcionou.
ON INIT {| oDlg | oDlg:ninitfocus:=btnsair}
A sua dica já resolveu:
Voltei os componentes a sua ordem original e funcionou.
ON INIT {| oDlg | oDlg:ninitfocus:=btnsair}
►Harbour 3.x | Minigui xx-x | HwGui◄
Pense nas possibilidades abstraia as dificuldades.
Não corrigir nossas falhas é o mesmo que cometer novos erros.
A imaginação é mais importante que o conhecimento. (Albert Einstein)
Pense nas possibilidades abstraia as dificuldades.
Não corrigir nossas falhas é o mesmo que cometer novos erros.
A imaginação é mais importante que o conhecimento. (Albert Einstein)