FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour Window VS Dialog ( To Antonio )
Posts: 603
Joined: Sun May 04, 2008 08:44 PM
Window VS Dialog ( To Antonio )
Posted: Sun Sep 20, 2009 06:46 AM
Antonio,

estoy usando la solucion que me passou essa:
Code (fw): Select all Collapse
// Moving a window, with the mouse, without a caption

#include "FiveWin.ch"

function Main()

   local oWnd, nRowPos, nColPos, lDrag := .F., oCrsHand, oBmp

   DEFINE CURSOR oCrsHand HAND

   DEFINE BITMAP oBmp FILENAME "test.bmp"

   DEFINE WINDOW oWnd STYLE WS_POPUP COLOR "W/R"

   oWnd:bLClicked := { | nRow, nCol | nRowPos := nRow, nColPos := nCol, lDrag := .T., oWnd:oCursor := oCrsHand }
      
   oWnd:bMMoved = { | nRow, nCol | If( lDrag, oWnd:Move( oWnd:nTop + nRow - nRowPos,;
                                         oWnd:nLeft + nCol - nColPos,,, .T. ),) }   

   oWnd:bLButtonUp := { || lDrag := .F., oWnd:oCursor := nil }

   oWnd:SetSize( 221, 221 )
   oWnd:Center()

   ACTIVATE WINDOW oWnd ;
      ON INIT  SetTransparent( oWnd ) ; 
      ON PAINT PaintTransparent( hDC, oBmp:hBitmap, 0, 0 ) ;
      ON RIGHT CLICK oWnd:End()

   oBmp:End()

return nil

#define LWA_COLORKEY  1 
#define GWL_EXSTYLE   -20 
#define WS_EX_LAYERED 524288 

STATIC FUNCTION SETTRANSPARENT( oDlg ) 

   SETWINDOWLONG( oDlg:hWnd, GWL_EXSTYLE, NOR( GETWINDOWLONG( oDlg:hWnd, GWL_EXSTYLE ), WS_EX_LAYERED ) ) 

   SETLAYEREDWINDOWATTRIBUTES( oDlg:hWnd, CLR_RED,, LWA_COLORKEY ) 

RETURN NIL

function PaintTransparent( hDC, hBitmap, nRow, nCol )

   local hBmpOld := SelectObject( hDC, hBitmap )
   local nZeroZeroClr := GetPixel( hDC, 0, 0 )
   local nOldClr 

   SelectObject( hDC, hBmpOld )
   nOldClr = SetBkColor( hDC, nRGB( 255, 255, 255 ) )
   TransBmp( hBitmap, nBmpWidth( hBitmap ), nBmpHeight( hBitmap ),;
             nZeroZeroClr, hDC, nRow, nCol, nBmpWidth( hBitmap ), nBmpHeight( hBitmap ) )
   SetBkColor( hDC, nOldClr )          

return nil


yo Gostaria de usar em una Dialog, pero no achei forma de fazer isso funcionar,
tu poderia ajudar ? em la dialog parece que lo PaintTransparent nao funciona, i nem a settransparent :-)

gracias.

estoy tentando hacer asi com dialog
Code (fw): Select all Collapse
#include "FiveWin.ch"

function Main()

   local oWnd, nRowPos, nColPos, lDrag := .F., oCrsHand, oBmp

   DEFINE CURSOR oCrsHand HAND

   DEFINE BITMAP oBmp FILENAME "res1.bmp"

   DEFINE Dialog oWnd;
   STYLE WS_POPUP COLOR CLR_BLACK,nRGB(255,0,255)

   oWnd:bLClicked := { | nRow, nCol | nRowPos := nRow, nColPos := nCol, lDrag := .T., oWnd:oCursor := oCrsHand }
      
   oWnd:bMMoved = { | nRow, nCol | If( lDrag, oWnd:Move( oWnd:nTop + nRow - nRowPos,;
                                         oWnd:nLeft + nCol - nColPos,,, .T. ),) }   

   oWnd:bLButtonUp := { || lDrag := .F., oWnd:oCursor := nil }

   oWnd:SetSize( 221, 221 )
   oWnd:Center()

   ACTIVATE Dialog oWnd ;
      ON INIT  SetTransparent( oWnd ) ; 
      ON PAINT PaintTransparent( hDC, oBmp:hBitmap, 0, 0 ) ;
      ON RIGHT CLICK oWnd:End()

   oBmp:End()

return nil

#define LWA_COLORKEY  1 
#define GWL_EXSTYLE   -20 
#define WS_EX_LAYERED 524288 

STATIC FUNCTION SETTRANSPARENT( oDlg ) 

   SETWINDOWLONG( oDlg:hWnd, GWL_EXSTYLE, NOR( GETWINDOWLONG( oDlg:hWnd, GWL_EXSTYLE ), WS_EX_LAYERED ) ) 

   SETLAYEREDWINDOWATTRIBUTES( oDlg:hWnd, nRGB(255,0,255),, LWA_COLORKEY ) 

RETURN NIL

function PaintTransparent( hDC, hBitmap, nRow, nCol )

   local hBmpOld := SelectObject( hDC, hBitmap )
   local nZeroZeroClr := GetPixel( hDC, 0, 0 )
   local nOldClr 

   SelectObject( hDC, hBmpOld )
   nOldClr = SetBkColor( hDC, nRGB( 255, 255, 255 ) )
   TransBmp( hBitmap, nBmpWidth( hBitmap ), nBmpHeight( hBitmap ),;
             nZeroZeroClr, hDC, nRow, nCol, nBmpWidth( hBitmap ), nBmpHeight( hBitmap ) )
   SetBkColor( hDC, nOldClr )          

return nil


Pero no funciona...
Posts: 603
Joined: Sun May 04, 2008 08:44 PM
Re: Window VS Dialog ( To Antonio )
Posted: Tue Sep 22, 2009 02:20 AM

Someone ?

Posts: 2365
Joined: Wed Nov 02, 2005 11:46 PM
Re: Window VS Dialog ( To Antonio )
Posted: Tue Sep 22, 2009 03:00 AM

lailton...

you should put oWnd:SetSize( 221, 221 ) into "on int" or use : DEFINE DIALOG ... SIZE X, Y

the dialogs are created ( hWnd ) in method activate, SetSize set a new size from window handle (hWnd) and it no exist before call activate command

Posts: 603
Joined: Sun May 04, 2008 08:44 PM
Re: Window VS Dialog ( To Antonio )
Posted: Tue Sep 22, 2009 06:11 AM

Solved too

thanks.

Continue the discussion