In order for this site to work correctly we need to store a small file (called a cookie) on your computer. Most every site in the world does this, however since the 25th of May 2011, by law we have to get your permission first. Please abandon the forum if you disagree.

Para que este foro funcione correctamente es necesario guardar un pequeño fichero (llamado cookie) en su ordenador. La mayoría de los sitios de Internet lo hacen, no obstante desde el 25 de Marzo de 2011 y por ley, necesitamos de su permiso con antelación. Abandone este foro si no está conforme.

'Screen Prompt' class based on TLabel ....

Xailer professional forum in English
ChrisGillard
Posts: 384
Joined: Tue May 01, 2007 5:49 pm

'Screen Prompt' class based on TLabel ....

Postby ChrisGillard » Thu Sep 08, 2016 7:28 pm

I am attempting to make a 'Screen Prompt' class which responds to mouse clicks and key presses including ALT+Key combinations.

It is based on a TLabel for its onclick event and I am using Form:FormKeyDown() and WMSysKeyDown() to detect the ALT key .... my prototype enhanced label is basically working, see below.

2016-09-08_18-00-36.jpg
2016-09-08_18-00-36.jpg (20.26 KiB) Viewed 3682 times


In our [x]Harbour applications we have similar 'Screen Prompts' class and we are show the keyboard letter/letters in a different colour, see below

2016-09-08_17-57-26.jpg
2016-09-08_17-57-26.jpg (110.5 KiB) Viewed 3682 times


I would like to do the same thing with the text on my enhanced TLabel.

My plan at the moment is to display the whole text in the default colour and then try to overwrite a part of the string in the 'Action' colour.

This is where I get stuck!!

How to place some coloured text over a small section of the main text ..... to make it worse the action colour letters are not always at the beginning of the prompt.

Any thoughts on whether this is possible and how to start doing it would be appreciated.

Thank you.

Chris
User avatar
ignacio
Site Admin
Posts: 8545
Joined: Mon Apr 06, 2015 8:00 pm
Location: Madrid, Spain
Contact:

Re: 'Screen Prompt' class based on TLabel ....

Postby ignacio » Fri Sep 09, 2016 9:49 am

Hello Chris,

Maybe I'm missing something, but it seems you can use a TLabelEx control in conjuntion with its OnLinkClick event.

Regards,
Ignacio Ortiz de Zúñiga
[Equipo de Xailer / Xailer team]
http://www.xailer.com
http://www.xailer.info
ChrisGillard
Posts: 384
Joined: Tue May 01, 2007 5:49 pm

Re: 'Screen Prompt' class based on TLabel ....

Postby ChrisGillard » Sun Sep 11, 2016 3:31 pm

Hi Ignacio,

Thanks for your thoughts on this one.

2016-09-11_13-56-26_2.jpg
2016-09-11_13-56-26_2.jpg (35.47 KiB) Viewed 3624 times


I have had a go with TlabelEx and the basic HTML ability gives me the exact style I am looking for with the highlighted letter/s within the label .... example 2.

If I use <a><a/> to achieve an action link then I may struggle to get the colours I want and I did try ..... example 1.

The big problem with <a></a> is that it only gives me the click action on the highlighted letters ... as you would expect.

My wish is to have the whole region of the control clickable with a simple onClick() event but this does not appear to work, although it is in the property editor of the IDE.

Example 2 is the visual I want but with the whole region of the control clickable ... is there any chance of that?

This style of 'mouse and keyboard aware' prompt or button would allow us to consider migrating our major systems to a 21st century GUI using Xailer .... it is very important to me to give my business systems a future.

Any help would be appreciated.

Thanks

Chris

My simple test code is attached
Attachments
2016-09-11_14-10-17_2.jpg
2016-09-11_14-10-17_2.jpg (77.93 KiB) Viewed 3624 times
ChrisGillard
Posts: 384
Joined: Tue May 01, 2007 5:49 pm

Re: 'Screen Prompt' class based on TLabel ....

Postby ChrisGillard » Mon Sep 12, 2016 1:13 pm

Just to summarise ....

Seems what I really want is a TBtnEx inherited from TButton, but with the html text ability of TLabelEx.

A bit like the TBtnBmp ..... without the Bmp but with enhanced text from the html ability of TLabelEx to style the text, would not need the <a></a> ).

With some option for having the text 'centred' within the button.

But thats all well beyond my capability!!

Thats my ideal, just a thought.

Chris
User avatar
ignacio
Site Admin
Posts: 8545
Joined: Mon Apr 06, 2015 8:00 pm
Location: Madrid, Spain
Contact:

Re: 'Screen Prompt' class based on TLabel ....

Postby ignacio » Mon Sep 12, 2016 1:21 pm

Hello,

TLabelEx OnClick can be fixed with this two lines:

HB_FUNC_STATIC( XLABELEX_WMLBUTTONDOWN )
{
..............
..............

>>>> if( !bRet )
>>>> XA_ObjSendNL2( Self, "OnClick", pt.x, pt.y );
hb_xfree( aLink );
..............
..............
}

If you need the OBJ,0 files just let me know.

I include with this message a small project that may give you some clue. I hope so.

Regards,
Attachments
screenprompt.zip
(2.59 KiB) Downloaded 45 times
Ignacio Ortiz de Zúñiga
[Equipo de Xailer / Xailer team]
http://www.xailer.com
http://www.xailer.info
ChrisGillard
Posts: 384
Joined: Tue May 01, 2007 5:49 pm

Re: 'Screen Prompt' class based on TLabel ....

Postby ChrisGillard » Mon Sep 12, 2016 1:57 pm

Hi Ignacio,

Thank you for that fix .... it is almost perfect.

In the first example it works fine and gives me an OnClick event for the whole surface of the button.

With example 2 .... with no html link defined with <a></a> .... the code bypasses your new OnClick fix.

Something to do with it being in the 'if nCount' structure.

Can your fix be placed outside that if?

A code sample is always good for me.

Thanks

Chris
ChrisGillard
Posts: 384
Joined: Tue May 01, 2007 5:49 pm

Re: 'Screen Prompt' class based on TLabel ....

Postby ChrisGillard » Mon Sep 12, 2016 2:13 pm

Hi Ignacio,

I had not run your example project .... thats very much how I want this to look when it is finished.

Thinking about whether onclick needs to work even when there is no <a></a> defined ... In looking at your example I'm fairly happy to have the underline if you think it should work that way.

A great example project, which gives me a good lesson in Xailer programming.

Thank you.

Chris
User avatar
ignacio
Site Admin
Posts: 8545
Joined: Mon Apr 06, 2015 8:00 pm
Location: Madrid, Spain
Contact:

Re: 'Screen Prompt' class based on TLabel ....

Postby ignacio » Mon Sep 12, 2016 5:08 pm

Code: Select all

HB_FUNC_STATIC( XLABELEX_WMLBUTTONDOWN )
{
   PHB_ITEM Self = hb_stackSelfItem(), tControl;
   HWND hWnd = GetHandleOf( Self );
   int wParam = hb_parnl( 1 ), lParam = hb_parnl( 2 );
   int bRet = FALSE;
   HDC hdc = CreateCompatibleDC( NULL );
   POINT pt;
   UINT nTextLen = 0;
   char *cText = XA_ObjGetCLen( Self, "cText", &nTextLen );
   int nLineSpacing = XA_ObjGetNL( Self, "nLineSpacing" ) & 1023;
   DT_LINK *aLink;
   int nCount = 0, n;
   RECT rect;

   if( XA_ObjGetL( Self, "lTabStop" ) )
      SetFocus( hWnd );

   GetClientRect( hWnd, &rect );
   XA_DrawTextEx( hdc, cText, nTextLen, &rect, DT_CALCRECT | nLineSpacing, 0, NULL, &nCount );
   if( nCount )
      {
      pt.x = LOWORD( lParam );
      pt.y = HIWORD( lParam );
      SelectObject( hdc, GetHandleOf( XA_ObjGetItem( Self, "GetFont" ) ) );
      aLink = hb_xgrab( sizeof( DT_LINK ) * nCount );
      XA_DrawTextEx( hdc, cText, nTextLen, &rect, DT_CALCRECT | nLineSpacing, 0, aLink, &nCount );

      pt.y -= XA_ObjGetNL( Self, "nClientTop" );
      for( n = 0; n < nCount; n++ )
         {
         if( PtInRect( &aLink[ n ].rect, pt ) )
            {
            cText = hb_xgrab( aLink[ n ].nTextLen + 1 );
            strncpy( cText, aLink[ n ].cText, aLink[ n ].nTextLen );
            cText[ aLink[ n ].nTextLen ] = 0;
            XA_ObjSendC( Self, "OnLinkClick", cText );
            hb_xfree( cText );
            bRet = TRUE;
            break;
            }
         }

      hb_xfree( aLink );
      }
     
   DeleteDC( hdc );

   if( !bRet )
      {
      tControl = XA_ObjGetItemCopy( Self, "TControl" );
      XA_ObjSendNL2( tControl, "WMSetCursor", wParam, lParam );
      hb_itemRelease( tControl );
      XA_ObjSendNL2( Self, "OnClick", pt.x, pt.y );
      }
}
Ignacio Ortiz de Zúñiga
[Equipo de Xailer / Xailer team]
http://www.xailer.com
http://www.xailer.info
ChrisGillard
Posts: 384
Joined: Tue May 01, 2007 5:49 pm

Re: 'Screen Prompt' class based on TLabel ....

Postby ChrisGillard » Tue Sep 13, 2016 3:35 pm

Hi Ignacio,

That last piece of code seems to fifish the job off.

It gets us started on a replacement GUI for our traditional applications, its going to take many months and up to a year to get something a customer can use but we have to start.

Thanks for your help

Chris
ChrisGillard
Posts: 384
Joined: Tue May 01, 2007 5:49 pm

Re: 'Screen Prompt' class based on TLabel ....

Postby ChrisGillard » Fri Sep 30, 2016 12:46 pm

Hi Ignacio,

Just a post to show progress on my ScreenPrompt and menus classes and request one improvement to TLabelEx maybe.

My request is more control the alignment of the text in the TLabelEx control to improve the appearance.

For the titles I might like a CENTER option, standard would be LEFT and maybe also useful RIGHT. This could be achieved as a Property or maybe within the text itself with some pseudo HTML?

It would also be useful to be able to move the text a number of pixels in from the left side of the Prompts to give some space there. This could be a 'Margin' or 'Indent' Property or maybe within the text itself with some pseudo HTML?

Anyway, it is certainly usable at the moment.

Thank you for your help.

Chris

2016-09-30_11-26-45.jpg
2016-09-30_11-26-45.jpg (128.8 KiB) Viewed 2702 times
User avatar
ignacio
Site Admin
Posts: 8545
Joined: Mon Apr 06, 2015 8:00 pm
Location: Madrid, Spain
Contact:

Re: 'Screen Prompt' class based on TLabel ....

Postby ignacio » Mon Oct 03, 2016 12:22 pm

Hello Chris,

>>My request is more control the alignment of the text in the TLabelEx control to improve the appearance.

I'm afraid that functionality is not available on TLabelEx, sorry. BTW in order to add a margin to all the card box elements you can use the property nCardMargin.

Regards,
Ignacio Ortiz de Zúñiga
[Equipo de Xailer / Xailer team]
http://www.xailer.com
http://www.xailer.info
ChrisGillard
Posts: 384
Joined: Tue May 01, 2007 5:49 pm

Re: 'Screen Prompt' class based on TLabel ....

Postby ChrisGillard » Tue Oct 04, 2016 9:51 am

Hi Ignacio,

Sounds like a move to CardBox class may be the way to go with Xailer 5.

Thank you for your help with these menus ... they are usable and I will move on to the next building blocks I need.

Chris

Return to “English”