Control BUTTON, ON GOTFOCUS, ON LOSTFOCUS BUG?

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
User avatar
andyglezl
Posts: 1461
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Contact:

Control BUTTON, ON GOTFOCUS, ON LOSTFOCUS BUG?

Post by andyglezl »

Ya tenía rato que no utilizaba los BUTTON, (todo lo hacia con LABEL)
Y ahora. creo que algo anda mal con el Control BUTTON...
será el Windows 10 ?
Ustedes que piensan ?
*----------------------------------------------------
I had not used the BUTTONs for a long time, (I did everything with LABEL)
And now. believe something is wrong with the BUTTON Control ...
Will it be Windows 10?
What do you think ?

Code: Select all

#include <hmg.ch>

*--------------------------------------------------------------
FUNCTION Main() 

	DEFINE WINDOW FormMain AT 0 , 0 WIDTH 500 HEIGHT 300 MAIN  BACKCOLOR BLUE TITLE " BUTTON" 

				
	@ 040 , 100 BUTTON Btn_1 Of FormMain CAPTION '&1' ACTION ( MSGBOX() )  ;
				WIDTH 60 HEIGHT 23 FONT "Arial" SIZE 09 TOOLTIP "Nuevo Cliente"  ;
				ON GOTFOCUS CONTROLBACKGROUND( FormMain.Btn_1.Handle, {255,0,0} )
				SetWindowTheme( FormMain.Btn_1.Handle, 0, 0 )
				
	@ 140 , 100 BUTTON Btn_2 Of FormMain CAPTION '&2' ACTION ( MSGBOX() )  ;
				WIDTH 60 HEIGHT 23 FONT "Arial" SIZE 09 TOOLTIP "Nuevo Cliente"  ;
				ON GOTFOCUS  SetProperty( "FormMain", "Btn_2", "FONTBOLD", .T. ) ;
				ON LOSTFOCUS SetProperty( "FormMain", "Btn_2", "FONTBOLD", .F. )
		
		
	END WINDOW
	CENTER WINDOW FormMain
	ACTIVATE WINDOW FormMain
RETURN
*--------------------------------------------------------------
#pragma BEGINDUMP

#include "SET_COMPILE_HMG_UNICODE.ch"
#include "HMG_UNICODE.h"

#include <windows.h>
#include <commctrl.h>
#include <urlmon.h>
#include "hbapi.h"

HB_FUNC(CONTROLBACKGROUND)
{
   HWND hWnd;
   HDC  hDC;
   RECT rect;
   HBRUSH hbrush;
   PAINTSTRUCT ps;

   hWnd   = (HWND)    hb_parnl (1);
   GetClientRect(hWnd, &rect);
   hbrush = CreateSolidBrush( (COLORREF) RGB(hb_parvni(2, 1),
                                             hb_parvni(2, 2),
                                             hb_parvni(2, 3)) );
   hDC = BeginPaint (hWnd, &ps);
   FillRect(hDC,&rect,(HBRUSH) hbrush );
   ReleaseDC(hWnd, hDC);
}
Andrés González López
Desde Guadalajara, Jalisco. México.
User avatar
AUGE_OHR
Posts: 2093
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: Control BUTTON, ON GOTFOCUS, ON LOSTFOCUS BUG?

Post by AUGE_OHR »

hi,

BUTTON have no BACKCOLOR. what you "see" are Visual Style e.g. when "hover" Button.
so you need to disable Visual Style if you want Color using

Code: Select all

hWnd := GetControlHandle( "Btn_1", "FormMain" )
SetWindowTheme( hWnd, 0, 0 )

hWnd := GetControlHandle( "Btn_2", "FormMain" )
SetWindowTheme( hWnd, 0, 0 )
SetWindowTheme.jpg
SetWindowTheme.jpg (9.11 KiB) Viewed 1294 times
the HB_FUNC( CONTROLBACKGROUND ) does "paint" Backgroud. it does NOT "set" Background Color
if you want to change Color on API Level use GDI32

Code: Select all

SetBkColor()
SetTextColor()
https://docs.microsoft.com/en-us/window ... setbkcolor
https://docs.microsoft.com/en-us/window ... ttextcolor
have fun
Jimmy
User avatar
andyglezl
Posts: 1461
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Contact:

Re: Control BUTTON, ON GOTFOCUS, ON LOSTFOCUS BUG?

Post by andyglezl »

mol wrote: ↑Mon Mar 30, 2020 11:22 pm
I've tried, not working...

AUGE_OHR » Tue Mar 31, 2020 3:42 am
this Sample i use to "paint" Darkmode (some Control have no Color Option)
Solo estoy probando lo que sugeriste, a falta de algún ejemplo...
Además de el segundo BUTTON tampoco funciona bien el ON GOTFOCUS, ON LOSTFOCUS
ya que no ejecuta el BOLD OFF.
*--------------------------------------------------------------------------------------------------------------
I'm just testing what you suggested, for lack of an example ...
Besides the second BUTTON, the ON GOTFOCUS, ON LOSTFOCUS does not work well either.
since it does not execute the BOLD OFF.


En mi caso, tengo que dar click en el botón para que se ejecute lo que hay en ON GOTFOCUS, ON LOSTFOCUS,
( por eso preguntaba si era el Win10 ).
En tu caso, si se ejecuta correctamente cuando pasas el ratón por el botòn ?
*----------------------------------------------------------------------------------------------------------------------------------
In my case, I have to click on the button to execute what is in ON GOTFOCUS, ON LOSTFOCUS,
(That's why I was asking if it was Win10).
In your case, if it runs correctly when you mouse over the button?


BUTTON have no BACKCOLOR. what you "see" are Visual Style e.g. when "hover" Button.
so you need to disable Visual Style if you want Color using

hWnd := GetControlHandle( "Btn_1", "FormMain" )
SetWindowTheme( hWnd, 0, 0 )

hWnd := GetControlHandle( "Btn_2", "FormMain" )
SetWindowTheme( hWnd, 0, 0 )
De la forma como lo puse, funciona igual:
*----------------------------------------------------------------------------
The way I put it, it works the same:

CONTROLBACKGROUND( FormMain.Btn_1.Handle, {255,0,0} )
SetWindowTheme( FormMain.Btn_1.Handle, 0, 0 )
Last edited by andyglezl on Fri Apr 03, 2020 4:21 pm, edited 1 time in total.
Andrés González López
Desde Guadalajara, Jalisco. México.
User avatar
AUGE_OHR
Posts: 2093
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: Control BUTTON, ON GOTFOCUS, ON LOSTFOCUS BUG?

Post by AUGE_OHR »

hi,

sorry i´m still a harbour / HMG Newbie and not sure what is implement.

i use Ownerdraw / Customdraw and wrote my own native Control, using Ot4xb, for Xbase++
for Visual Effect ( not visual Style ) i use Windows Message like

Code: Select all

  WM_MOUSEMOVE
  WM_MOUSELEAVE
  WM_MOUSEHOVER
which is different to

Code: Select all

  WM_SETFOCUS	-> GETFOCUS
  WM_KILLFOCUS	-> LOSTFOCUS 
so if you want to track Mouse you need those Mouse Event and TRACKMOUSEEVENT() Structure or "CREATE EVENT" on HMG Level

---

if Control get WM_MEASUREITEM / WM_DRAWITEM than User have "full-Control" and MUST "paint" self ... not sure how to do in HMG.

HB_FUNC(CONTROLBACKGROUND) is a Sample for Background but how about Font / Color or Image ... all must be HB_FUNC() Level. HMG Syntax does "wrap" those Step, using #xcommand, into HB_FUNC() so you can write your "own Syntax"

that is what MiniGUI do with ONMOUSEHOVER / ONMOUSELEAVE which made it easy for User to handle it :D
have fun
Jimmy
User avatar
andyglezl
Posts: 1461
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Contact:

Re: Control BUTTON, ON GOTFOCUS, ON LOSTFOCUS BUG?

Post by andyglezl »

HB_FUNC(CONTROLBACKGROUND) is a Sample for Background but how about Font / Color or Image ... all must be HB_FUNC() Level.
HMG Syntax does "wrap" those Step, using #xcommand, into HB_FUNC() so you can write your "own Syntax"
Ese el el punto, yo vengo de Clipper, no pase por Harbour como tal, soy usuario final de HMG,
y muchas cosas que mencionas me dejan con dudas porque las desconozco.

Soy un simple mortal ... :?
*------------------------------------------------------------------------------------------------------------------
That the point, I come from Clipper, do not go through Harbor as such, I am an end user of HMG,
and many things you mention leave me in doubt because I don't know them.

I am a mere mortal ... :?
Andrés González López
Desde Guadalajara, Jalisco. México.
Post Reply