October 30, 2025, 12:38:17 PM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Problem with custom control & Messagebox

Started by LarryMc, September 12, 2008, 09:16:32 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

LarryMc

I have a custom control that ACTs like a button but is not a subclassed button.
The following code controls 2 flags:
#g_dat.b_hover
#g_dat.b_press
which in turn control the border of my button in the WM_PAINT handler.
Problem is when button is pressed and WM_COMMAND message is sent to parent and parent opens a Messagebox my control quits updating.
The code below makes the button that calls the Messagebox work properly but on a button that doesn't call a Messagebox doesn't at properly.  The sequence of event for a non-messagebox button is:
Quoteborder changes to mouseover color when cursor is moved into region
button down changes border to button-pressed color
button up changes border to non pressed/non mouseover color.
any movement of mouse button goes to mouseover color.
The sequence of events for the messagebox button is:
Quoteborder changes to mouseover color when cursor is moved into region
button down changes border to button-pressed color
button up changes border to non pressed/non mouseover color.
messagebox appears.
If I change the code so that the non-messagebox button works correctly then the messagebox button is stuck in the button-pressed color when the messagebox appears.  And closing the messagebox leaves the calling button in the pressed state, even when mousedover, until another button is moused over.


I had thought setcapture would help me but the messagebox appears to be taking that over.

Any help would be appreciated.

case @IDMOUSEMOVE
       ' button mouseover effect
pt.x=mousex
pt.y=mousey
ScreenToClient(hWnd,pt)
GetClientRect(hWnd, rc)
if PtInRegion(#g_dat.hRgn, pt.x, pt.y)
if #g_dat.b_hover =0
setcapture(hwnd)
#g_dat.b_hover = 1
_SetWindowLong(hWnd, GWL_USERDATA, g_dat)
InvalidateRect(hWnd, NULL, FALSE)
endif
Else
'if #g_dat.b_hover =1
ReleaseCapture()
#g_dat.b_hover = 0
#g_dat.b_press = 0
_SetWindowLong(hWnd, GWL_USERDATA, g_dat)
InvalidateRect(hWnd, NULL, FALSE)
'endif
Endif
return 0

case @IDLBUTTONDN
pt.x=mousex
pt.y=mousey
ScreenToClient(hWnd,pt)
if PtInRegion(#g_dat.hRgn, pt.x, pt.y)
#g_dat.b_press = 1
'setcapture(hwnd)
_SetWindowLong(hWnd, GWL_USERDATA, g_dat)
InvalidateRect(hWnd, NULL, FALSE)
endif
return 0

case @IDLBUTTONUP
#g_dat.b_press = 0
#g_dat.b_hover = 0
_SetWindowLong(hWnd, GWL_USERDATA, g_dat)
InvalidateRect(hWnd, NULL, FALSE)
SendMessage(GetParent(hWnd),WM_COMMAND,_GetDlgCtrlID(hWnd),hWnd)


Larry


LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

LarryMc

Just discovered the WM_CAPTURECHANGED message.

With a little code rework that might do it for me.

Larry
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

LarryMc

WM_CAPTURECHANGED and a slight code change cleared the problem up.

Larry
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Boris

Thank you for not breeding