Still trouble Transparent say in dialogs

Still trouble Transparent say in dialogs

Postby Richard Chidiak » Fri Feb 06, 2009 9: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

Code: Select all  Expand view
#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
User avatar
Richard Chidiak
 
Posts: 946
Joined: Thu Oct 06, 2005 7:05 pm
Location: France

Re: Still trouble Transparent say in dialogs

Postby byte-one » Fri Feb 06, 2009 9:31 am

Richard, please add this new fixsays to your code!
ANTONIO, this problem with the wordbreak should also from you adapted!

Code: Select all  Expand view
//*****************************************************
#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
Last edited by byte-one on Tue Feb 17, 2009 12:50 am, edited 1 time in total.
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria

Re: Still trouble Transparent say in dialogs

Postby Richard Chidiak » Fri Feb 06, 2009 9: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
User avatar
Richard Chidiak
 
Posts: 946
Joined: Thu Oct 06, 2005 7:05 pm
Location: France

Re: Still trouble Transparent say in dialogs

Postby Richard Chidiak » Fri Feb 06, 2009 9: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
User avatar
Richard Chidiak
 
Posts: 946
Joined: Thu Oct 06, 2005 7:05 pm
Location: France

Re: Still trouble Transparent say in dialogs

Postby Antonio Linares » Sat Feb 07, 2009 9:56 pm

Günther, Richard,

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

Some minor changes to get it properly compiled:
Code: Select all  Expand view
#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
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Still trouble Transparent say in dialogs

Postby E. Bartzokas » Thu Apr 09, 2009 3: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
User avatar
E. Bartzokas
 
Posts: 114
Joined: Tue Feb 14, 2006 8:13 am
Location: Corinth, Greece

Re: Still trouble Transparent say in dialogs

Postby Antonio Linares » Thu Apr 09, 2009 6:39 pm

Evans,

In the above C code, please modify this line:
Code: Select all  Expand view

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
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: nageswaragunupudi and 20 guests

cron