-
If there's any men out there who want metaphoricly sorting out from the boys this should do it.
I'm making a usercontrol that you can move about at runtime just by dragging it and for various (good) reasons I'm doing it by subclassing the controll and it's parent, trapping the mousedown message to the control, setting the capture to it's parent then trapping the mouseup message for it's parent to move it.
for the good reasons I mentioned earlier I don't want to use the mousedown and mouseup VB events or intercept the Hittest message.
It's all working beutifly exept that I cant get the control to dissapear when the mouse goes down, I've tried
Code:
usercontrol.extender.visible=false
SetWindowLong Usercontrol.hwnd,GWL_STYLE,Getwindowlong(usercontrol.hwnd,GWL_STYLE) and (not WS_VISIBLE)
ShowWindow Usercontrol.hwnd,SW_HIDE
ShowWindowAsync Usercontrol.hwnd,SW_HIDE
I've tried putting these in the subsitute window procedures, both in the control mousedown and parent mousemove messages, and in the standard VB Mousedown events.
The Usercontrol_Hide event is firing but the controll isn't disapearing
I've even liberally spread Doevents and UpdateWindow everywhere and unspread them but I can't get the window to disapear, Any clues what's happening?
-
You have to use logical operator Xor if you want to exclude something from the Style.
So the correct way to exclude WS_VISIBLE would be like this:
Code:
Dim lStyle As Long
lStyle = Getwindowlong(usercontrol.hwnd,GWL_STYLE)
lStyle = lStyle Xor WS_VISIBLE
SetWindowLong Usercontrol.hwnd, GWL_STYLE, lStyle
Then, if you want to add WS_VISIBLE again, you would have to use logical Or operator.
-
I've solved it anyway, I wasn't refreshing the parent.(I hang my head in shame and look sheepish)
I'm not sure what you mean about XOR though, Wouldnt XOR make it visible if it was invisible and invisible if it was visible, And Not makes sure it's turned off.