FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Still trouble Transparent say in dialogs
Posts: 946
Joined: Thu Oct 06, 2005 07:05 PM
Still trouble Transparent say in dialogs
Posted: Fri Feb 06, 2009 09:24 AM
Antonio

Say strings are not correcty drawn when transparent clause is used on dialogs. this is an old problem

In the sample below, the say string is truncated with the transparent and adjust , it should be on 2 lines if we remove all reference to transparent

can tou please check with and without Transparent to see the problem ?

Thanks

FWH 9.01

Richard

#include "FiveWin.ch"

function Main()
LOCAL ODLG,OSAY,OGET1

DEFINE DIALOG ODLG RESOURCE "TEST" TRANSPARENT
REDEFINE SAY OSAY  ID 401 OF ODLG  TRANSPARENT ADJUST
REDEFINE GET OGET1 ID 201 OF ODLG

ACTIVATE DIALOG ODLG CENTERED
return nil

TEST DIALOG 2, 12, 144, 91
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX
FONT 12, "Tahoma"
{
 EDITTEXT 201, 53, 2, 67, 18
 DEFPUSHBUTTON "&OK", IDOK, 1, 62, 35, 24
 PUSHBUTTON "Cancel", IDCANCEL, 106, 64, 36, 24
 CTEXT "L1 AND LINE2", 401, 2, 1, 42, 21, SS_CENTER | WS_BORDER | WS_GROUP
}
http://www.cbati.com

Uestudio
Fwh 13.05 Harbour 3.2 MSVC 2013
Posts: 1048
Joined: Mon Oct 24, 2005 09:54 AM
Re: Still trouble Transparent say in dialogs
Posted: Fri Feb 06, 2009 09:31 AM
Richard, please add this new fixsays to your code!
ANTONIO, this problem with the wordbreak should also from you adapted!

Code (fw): Select all Collapse
//*****************************************************
#PRAGMA BEGINDUMP

#include <WinTen.h>
#include <windows.h>
#include <ClipApi.h>

//typedef int (FAR WINAPI *FARPROC)();


void WindowBoxBlack( HDC hDC, RECT * pRect );

LRESULT static CALLBACK LabelProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
   if( uMsg == WM_ERASEBKGND )
   {
      return 1;
   }

   else if( uMsg == WM_UPDATEUISTATE ) // SAYs were erased when pressing ALT
   {
      LONG lResult = CallWindowProc( ( FARPROC ) GetProp( hWnd, "__FWTRANS" ), hWnd, uMsg, wParam, lParam );
      InvalidateRect( hWnd, NULL, TRUE );
      return lResult;
   }

   else if( uMsg == WM_PAINT )
   {
      PAINTSTRUCT ps;
      char text[ 256 ];
      RECT rct;
      HDC hDC = BeginPaint( hWnd, &ps );
      HGDIOBJ hOldFont;

      GetWindowText( hWnd, text, 255 );
      GetClientRect( hWnd, &rct );
      SetBkMode( hDC, TRANSPARENT );
      SelectObject( hDC, GetStockObject( DEFAULT_GUI_FONT ) );

      SendMessage( GetParent( hWnd ), WM_CTLCOLORSTATIC, ( WPARAM ) hDC, ( LPARAM ) hWnd );
      hOldFont = SelectObject( hDC, ( HGDIOBJ ) SendMessage( hWnd, WM_GETFONT, 0, 0 ) );

      if( ( GetWindowLong( hWnd, GWL_STYLE ) & SS_BLACKFRAME ) ==   SS_BLACKFRAME )
      {
         RECT rct;

         GetClientRect( hWnd, &rct );
         WindowBoxBlack( hDC, &rct );
      }

      else if( GetWindowLong( hWnd, GWL_STYLE ) & SS_CENTER   )
         DrawText( hDC, text, lstrlen( text ), &rct,  DT_CENTER | DT_WORDBREAK );

      else if( GetWindowLong( hWnd, GWL_STYLE ) & SS_RIGHT   )
         DrawText( hDC, text, lstrlen( text ), &rct,  DT_RIGHT | DT_WORDBREAK );

      else if( GetWindowLong( hWnd, GWL_STYLE ) & SS_LEFTNOWORDWRAP   )
         DrawText( hDC, text, lstrlen( text ), &rct,  DT_LEFT );

      else
         DrawText( hDC, text, lstrlen( text ), &rct,  DT_LEFT | DT_WORDBREAK );

      SelectObject( hDC, hOldFont );

      EndPaint( hWnd, &ps );

      return 0;
   }
   else
      return CallWindowProc( ( FARPROC ) GetProp( hWnd, "__FWTRANS" ), hWnd, uMsg, wParam, lParam );
}


HARBOUR HB_FUN_FIXSAYS()
{
   HWND hDlg = ( HWND ) _parnl( 1 );
   HWND hCtrl = GetWindow( hDlg, GW_CHILD );
   char className[ 64 ];
   WNDPROC pLabelProc = NULL;

   while( hCtrl != NULL )
   {
      GetClassName( hCtrl, className, sizeof( className ) );

      if( ! lstrcmp( "Static", className ) && ! ( ( GetWindowLong( hCtrl, GWL_STYLE ) & SS_ICON ) == SS_ICON ) )
      {
            if( GetWindowLong( hCtrl, GWL_WNDPROC ) != ( LONG ) LabelProc )
            {
               pLabelProc = ( WNDPROC ) SetWindowLong( hCtrl, GWL_WNDPROC,
                                                       ( LONG ) LabelProc );
               SetProp( hCtrl, "__FWTRANS", ( HANDLE ) pLabelProc );
            }
      }
      hCtrl = GetWindow( hCtrl, GW_HWNDNEXT );
   }
}

#PRAGMA ENDDUMP
Regards,
Günther
---------------------------------
office@byte-one.com
Posts: 946
Joined: Thu Oct 06, 2005 07:05 PM
Re: Still trouble Transparent say in dialogs
Posted: Fri Feb 06, 2009 09:43 AM

Thanks Gunther

I am still missing the define for WM_UPDATEUISTATE

Can you post it here ?

TIA

Richard

http://www.cbati.com

Uestudio
Fwh 13.05 Harbour 3.2 MSVC 2013
Posts: 946
Joined: Thu Oct 06, 2005 07:05 PM
Re: Still trouble Transparent say in dialogs
Posted: Fri Feb 06, 2009 09:50 AM

i found it searching the forum

Antonio , can you commit this fix in further release ?

Thanks

http://www.cbati.com

Uestudio
Fwh 13.05 Harbour 3.2 MSVC 2013
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Still trouble Transparent say in dialogs
Posted: Sat Feb 07, 2009 09:56 PM
Günther, Richard,

Yes, we are going to include it in next FWH build.

Some minor changes to get it properly compiled:
#PRAGMA BEGINDUMP

#include <hbapi.h>
#include <windows.h>

void WindowBoxBlack( HDC hDC, RECT * pRect );

LRESULT static CALLBACK LabelProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
   if( uMsg == WM_ERASEBKGND )
   {
      return 1;
   }

   else if( uMsg == WM_UPDATEUISTATE ) // SAYs were erased when pressing ALT
   {
      LONG lResult = CallWindowProc( ( WNDPROC ) GetProp( hWnd, "__FWTRANS" ), hWnd, uMsg, wParam, lParam );
      InvalidateRect( hWnd, NULL, TRUE );
      return lResult;
   }

   else if( uMsg == WM_PAINT )
   {
      PAINTSTRUCT ps;
      char text[ 256 ];
      RECT rct;
      HDC hDC = BeginPaint( hWnd, &ps );
      HGDIOBJ hOldFont;

      GetWindowText( hWnd, text, 255 );
      GetClientRect( hWnd, &rct );
      SetBkMode( hDC, TRANSPARENT );
      SelectObject( hDC, GetStockObject( DEFAULT_GUI_FONT ) );

      SendMessage( GetParent( hWnd ), WM_CTLCOLORSTATIC, ( WPARAM ) hDC, ( LPARAM ) hWnd );
      hOldFont = SelectObject( hDC, ( HGDIOBJ ) SendMessage( hWnd, WM_GETFONT, 0, 0 ) );

      if( ( GetWindowLong( hWnd, GWL_STYLE ) & SS_BLACKFRAME ) ==   SS_BLACKFRAME )
      {
         RECT rct;

         GetClientRect( hWnd, &rct );
         WindowBoxBlack( hDC, &rct );
      }

      else if( GetWindowLong( hWnd, GWL_STYLE ) & SS_CENTER   )
         DrawText( hDC, text, lstrlen( text ), &rct,  DT_CENTER | DT_WORDBREAK );

      else if( GetWindowLong( hWnd, GWL_STYLE ) & SS_RIGHT   )
         DrawText( hDC, text, lstrlen( text ), &rct,  DT_RIGHT | DT_WORDBREAK );

      else if( GetWindowLong( hWnd, GWL_STYLE ) & SS_LEFTNOWORDWRAP   )
         DrawText( hDC, text, lstrlen( text ), &rct,  DT_LEFT );

      else
         DrawText( hDC, text, lstrlen( text ), &rct,  DT_LEFT | DT_WORDBREAK );

      SelectObject( hDC, hOldFont );

      EndPaint( hWnd, &ps );

      return 0;
   }
   else
      return CallWindowProc( ( WNDPROC ) GetProp( hWnd, "__FWTRANS" ), hWnd, uMsg, wParam, lParam );
}


HB_FUNC( FIXSAYS )
{
   HWND hDlg = ( HWND ) hb_parnl( 1 );
   HWND hCtrl = GetWindow( hDlg, GW_CHILD );
   char className[ 64 ];
   WNDPROC pLabelProc;

   while( hCtrl != NULL )
   {
      GetClassName( hCtrl, className, sizeof( className ) );

      if( ! lstrcmp( "Static", className ) && ! ( ( GetWindowLong( hCtrl, GWL_STYLE ) & SS_ICON ) == SS_ICON ) )
      {
            if( GetWindowLong( hCtrl, GWL_WNDPROC ) != ( LONG ) LabelProc )
            {
               pLabelProc = ( WNDPROC ) SetWindowLong( hCtrl, GWL_WNDPROC,
                                                       ( LONG ) LabelProc );
               SetProp( hCtrl, "__FWTRANS", ( HANDLE ) pLabelProc );
            }
      }
      hCtrl = GetWindow( hCtrl, GW_HWNDNEXT );
   }
}

#PRAGMA ENDDUMP
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 114
Joined: Tue Feb 14, 2006 08:13 AM
Re: Still trouble Transparent say in dialogs
Posted: Thu Apr 09, 2009 03:09 PM

Hi all,

I have recently utilized the provided C code, to give my programs a new look and feel, and I managed to do it!
Thanks for the transparency to all involved persons.

My problem is one and only, which if I manage to resolve, it will make me happy, and will get off my shoulders
a whole lot of work...

Here's the situation...

In most of my dialogs I use Static says with and without a border (all of them created by resource).
1. Those which have no border, do not bother me, but those with borders most of the time (99%), have a
background color. Those without a border are most of the time black text colored.

How can I modify the (I guess just one line of code), to avoid giving the transparency effect to those
Static controls, which have a WS_BORDER clause ?

I will say Many Thanks to anyone who can provide me this solution.

Kind regards to all fellow-programmers.

Evans Bartzokas

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Still trouble Transparent say in dialogs
Posted: Thu Apr 09, 2009 06:39 PM
Evans,

In the above C code, please modify this line:
Code (fw): Select all Collapse
if( ! lstrcmp( "Static", className ) && ! ( ( GetWindowLong( hCtrl, GWL_STYLE ) & SS_ICON ) == SS_ICON ) && ! ( ( GetWindowLong( hCtrl, GWL_STYLE ) & WS_BORDER ) == WS_BORDER ) )
regards, saludos

Antonio Linares
www.fivetechsoft.com

Continue the discussion