Página 1 de 1
'Screen Prompt' class based on TLabel ....
Publicado: Jue Sep 08, 2016 7:28 pm
por ChrisGillard
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 (20.26 KiB) Visto 10079 veces
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 (110.5 KiB) Visto 10079 veces
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
Re: 'Screen Prompt' class based on TLabel ....
Publicado: Vie Sep 09, 2016 9:49 am
por ignacio
Hello Chris,
Maybe I'm missing something, but it seems you can use a TLabelEx control in conjuntion with its OnLinkClick event.
Regards,
Re: 'Screen Prompt' class based on TLabel ....
Publicado: Dom Sep 11, 2016 3:31 pm
por ChrisGillard
Hi Ignacio,
Thanks for your thoughts on this one.

- 2016-09-11_13-56-26_2.jpg (35.47 KiB) Visto 10021 veces
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
Re: 'Screen Prompt' class based on TLabel ....
Publicado: Lun Sep 12, 2016 1:13 pm
por ChrisGillard
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
Re: 'Screen Prompt' class based on TLabel ....
Publicado: Lun Sep 12, 2016 1:21 pm
por ignacio
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,
Re: 'Screen Prompt' class based on TLabel ....
Publicado: Lun Sep 12, 2016 1:57 pm
por ChrisGillard
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
Re: 'Screen Prompt' class based on TLabel ....
Publicado: Lun Sep 12, 2016 2:13 pm
por ChrisGillard
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
Re: 'Screen Prompt' class based on TLabel ....
Publicado: Lun Sep 12, 2016 5:08 pm
por ignacio
Código: Seleccionar todo
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 );
}
}
Re: 'Screen Prompt' class based on TLabel ....
Publicado: Mar Sep 13, 2016 3:35 pm
por ChrisGillard
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
Re: 'Screen Prompt' class based on TLabel ....
Publicado: Vie Sep 30, 2016 12:46 pm
por ChrisGillard
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 (128.8 KiB) Visto 9099 veces
Re: 'Screen Prompt' class based on TLabel ....
Publicado: Lun Oct 03, 2016 12:22 pm
por ignacio
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,
Re: 'Screen Prompt' class based on TLabel ....
Publicado: Mar Oct 04, 2016 9:51 am
por ChrisGillard
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