Non-Movable Dialog Box

Non-Movable Dialog Box

Postby Jeff Barnes » Sat Nov 06, 2010 1:06 am

Hi,

Is it possible to create a dialog box that cannot be moved if the user tries?
I'm not talking about re-sizing, I actually want to put a dialog box in a certain position on the screen an have it stay in the one spot.
Thanks,
Jeff Barnes

(FWH 16.11, xHarbour 1.2.3, Bcc730)
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada

Re: Non-Movable Dialog Box

Postby fraxzi » Sat Nov 06, 2010 7:18 am

Dear Jeff,

if dialogs caption/min/max is not important.. you can use the style WS_POPUP on your resource.. then move that dialog to your desired coordinates.


Just my 2cents.


Kind Regards,
Frances
Kind Regards,
Frances

Fivewin for xHarbour v18.07
xHarbour v1.2.3.x
BCC 7.3 + PellesC8 ( Resource Compiler only)
ADS 10.1 / MariaDB
Crystal Reports 8.5/9.23 DE
xMate v1.15
User avatar
fraxzi
 
Posts: 811
Joined: Tue May 06, 2008 4:28 am
Location: Philippines

Re: Non-Movable Dialog Box

Postby Jeff Barnes » Sat Nov 06, 2010 3:05 pm

Hi Frances,

I already have the dialogs placed where I need them and I do require the caption.
I just don't want the end user being able to move them from their original locations.
Thanks,
Jeff Barnes

(FWH 16.11, xHarbour 1.2.3, Bcc730)
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada

Re: Non-Movable Dialog Box

Postby ukoenig » Sat Nov 06, 2010 3:59 pm

Hello Jeff,
Fixed Positions of Dialogs with a extra painted Titel :
Delete / disable all Dialog-title-settings using only a Frame / Border.
Next draw Your own Title. Your Title can have a Tooltip and any Action.

The Dialog is calculated to a fixed Position and cannot be moved.
Because I had to calculate from the right to left, I used a Factor for the different Screen-resolutions,
to keep the Dialog-Position

aRect3 := GetSysmetrics( 1 ) // Screen-Height
aRect4 := GetSysmetrics( 0 ) // Screen-Width

1024 nFACTOR5 := 0
1152 nFACTOR5 := 10
1280 nFACTOR5 := 20

675 = Start left-position with Screen : 1024 x 768

ACTIVATE DIALOG oDlg1 NOWAIT ;
ON INIT oDlg1:Move( 50, aRect4 - (675 + nFACTOR5), NIL, NIL, .T. )

Image

The Resource :

Image

Code: Select all  Expand view

// ---------------- IMAGE ------------------------------

FUNCTION MAIN_DLG4( oWnd, oBrush1, oFont2 )
LOCAL hDC, oBrush, oTITLE, oBtn, oBtn1, oBMP, oIMAGE

lACTIVATE[1] = .T.

DEFINE DIALOG oDlg1 RESOURCE "Painter3" OF oWnd BRUSH oBrush1

// For Title-painting You can use any small Bitmap
// You can define a Action as well ( on Title-Click ).
// --------------------------------------------------------
REDEFINE BITMAP oTITLE  ID 100  ADJUST  RESOURCE "Blanc"  OF oDlg1
oTITLE:cTooltip := "Please select a Button"

// Action :
oTITLE:bLclicked := { |hDC| MsgAlert( "Test", "Attention" ) } //  bRClicked

oTITLE:bPainted := { |hDC| ;
DRAW_TITLE( oTITLE, ;       // BMP
     hDC, ;            // hDC
     .T., ;         // Horiz. or Vert.
     14853684, ;        // 1. Grad-Color
     16314573, ;        // 2. Grad-Color
     0.50, ;            // Color-Pos.
     0, ;           // Text-Pos from left ( 0 = centered )
     oFont2, ;          // Font
     128, ;         // Font-Color
     "Dialog Image ...") }   // The Title-text  

...
...
...

ACTIVATE DIALOG oDlg1 NOWAIT ;
ON INIT oDlg1:Move( 50, aRect4 - (675 + nFACTOR5), NIL, NIL, .T. ) // calculated Dialog-position

RETURN NIL

//------------- Gradient / Color- TITLE-function -----------

FUNCTION DRAW_TITLE( oBitmap, hDC, lDirect, nVColor, ;
     nBColor, nMove, nLeft, oFont, nTColor, cTitle )

LOCAL aGrad := { { nMove, nVColor, nBColor }, { nMove, nBColor, nVColor } }
LOCAL aRect := GETCLIENTRECT( oBitmap:hWnd )
LOCAL oNewBrush, oBtn1

DEFINE BRUSH oNewBrush ;
COLOR GradientFill( hDC,  0, 0, aRect[3], aRect[4], aGrad, lDirect )

hOldFont := SelectObject( hDC, oFont:hFont )
nTXTLG :=  GettextWidth( hDC, cTitle )
nBMPLONG  := oBitmap:Super:nWidth()
nBMPHIGHT := oBitmap:Super:nHeight()
nFONTHIGHT := oFont:nInpHeight * -1
IF nLEFT = 0
    nLEFT := (nBMPLONG - nTXTLG) / 2  
ENDIF
nNEWHIGHT := nFONTHIGHT
nTOP := (nBMPHIGHT - nNEWHIGHT) / 2
SetTextColor( hDC,nTColor)
SetBkMode( oBitmap:hDC, 0 )
TextOut( hDC, nTOP, nLEFT, cTitle )
RELEASE BRUSH oNewbrush

RETURN NIL

// The Resource :
// ------------------

PAINTER3 DIALOG -4, 13, 138, 158
STYLE WS_POPUP | WS_VISIBLE | WS_DLGFRAME | WS_THICKFRAME
FONT 12, "MS Sans Serif"
{
 EDITTEXT 210, 4, 53, 130, 12
 CONTROL "", 310, "TBitmap", 0 | WS_CHILD | WS_VISIBLE, 4, 69, 130, 85
 CONTROL "", 110, "TBtnBmp", 0 | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 4, 27, 64, 23
 CONTROL "", 100, "TBitmap", 0 | WS_CHILD | WS_VISIBLE, -1, -1, 139, 19
 CONTROL "", 900, "TBtnBmp", 0 | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 72, 27, 62, 23
}
 


From Code ( with different Title-function ) :

Code: Select all  Expand view

// ---------------- IMAGE ------------------------------

FUNCTION MAIN_DLG4( oWnd, oBrush1, oFont2 )
LOCAL hDC, oBrush, oTITLE, oBtn, oBtn1, oBMP, oIMAGE

DEFINE DIALOG oDlg1 FROM 5, 5 TO 200, 400  ;
STYLE nOr( WS_POPUP, WS_VISIBLE, WS_DLGFRAME, WS_THICKFRAME )  PIXEL

@ 0, 0 BITMAP oTITLE FILE "Colors.bmp" SIZE oDlg1:nWidth, 25 OF oDlg1 ADJUST
oTITLE:cTooltip := "Please select a Button"

oTITLE:bPainted := { |hDC| ;
DRAW_TITLE( oTITLE, ;       // BMP
  hDC, ;            // hDC
 .T., ;         // Horiz. or Vert.
 14853684, ;        // 1. Grad-Color
 16314573, ;        // 2. Grad-Color
 0.50, ;            // Color-Pos.
 oDlg1:nWidth, ;    // Title Width
 0, ;          // Text-Pos from left ( 0 = centered )
 oFont2, ;          // Font
 128, ;         // Font-Color
 "Dialog Image ...") }     

ACTIVATE DIALOG oDlg1 NOWAIT ;
ON INIT oDlg1:Move( 50, 50, NIL, NIL, .T. )

RETURN NIL

//------------- Gradient / Color- TITLE-function  DIFFERENT from RESOURCE !!!! -----------

FUNCTION DRAW_TITL1( oBitmap, hDC, lDirect, nVColor, ;
          nBColor, nMove, nWidth, nLeft, oFont, nTColor, cTitle )

LOCAL aGrad := { { nMove, nVColor, nBColor }, { nMove, nBColor, nVColor } }
LOCAL oNewBrush, oBtn1

nBMPHIGHT := oBitmap:Super:nHeight()
DEFINE BRUSH oNewBrush ;
COLOR GradientFill( hDC,  0, 0, nBMPHIGHT, nWidth, aGrad, lDirect )
hOldFont := SelectObject( hDC, oFont:hFont )
nTXTLG :=  GettextWidth( hDC, cTitle )
nFONTHIGHT := oFont:nInpHeight * -1
IF nLEFT = 0
    nLEFT := (nWidth - nTXTLG) / 2  
ENDIF
nNEWHIGHT := nFONTHIGHT
nTOP := (nBMPHIGHT - nNEWHIGHT) / 2
SetTextColor( hDC,nTColor)
SetBkMode( oBitmap:hDC, 0 )
TextOut( hDC, nTOP, nLEFT, cTitle )
RELEASE BRUSH oNewbrush

RETURN NIL
 


Best Regards
Uwe :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: nageswaragunupudi and 99 guests

cron