Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

button handle

Status
Not open for further replies.

hyonos

Technical User
Apr 2, 2003
46
IT
hi,
how to get button handle like thisform.HWnd ?
 
hyonos

Can you explain why you need that? Can you not use the name of it?

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
hyonos,
If I understand the question, unlike VB, VFP controls don't have handles - they are really just bitmaps, not "windows". While VFP 7 & 8 are "Microsoft Accessibility" aware, you can't send or intercept windows messages to individual controls - they don't really exist!

Rick
 
i have create 1 shape form.
in the init of the form i have this declaration:

DECLARE INTEGER SetLayeredWindowAttributes IN win32api;
INTEGER HWND, INTEGER crKey, INTEGER bAlpha, INTEGER dwFlags

DECLARE INTEGER SetWindowLong IN user32.DLL ;
INTEGER hWnd, INTEGER nIndex, INTEGER dwNewLong

DECLARE INTEGER GetWindowLong IN user32.DLL ;
INTEGER hWnd, INTEGER nIndex

DECLARE INTEGER GetActiveWindow IN user32


i have put a new method in the form "Makeirregular" and this is the code:


LPARAMETERS nHWND, nColor, nAction

*Constants for SetLayeredWindowAttributs
#DEFINE LWA_COLORKEY 1
#DEFINE LWA_ALPHA 2

*Constants for SetWindowLong and GetWindowLong
#DEFINE GWL_EXSTYLE -20
#DEFINE WS_EX_LAYERED 0x00080000

LOCAL lnFlags

*The form's window must be set to Layered, so that it is drawn
* in a separate layer.
do case
case nAction = 1 && Make Transparent
lnFlags = GetWindowLong(nHWND, GWL_EXSTYLE) &&Gets the existing flags from the window
*thisform.nFlags = lnFlags
lnFlags = BITOR(lnFlags, WS_EX_LAYERED) &&Appends the Layered flag to the existing ones
SetWindowLong(nHWND, GWL_EXSTYLE, lnFlags) &&Sets the new flags to the window
SetLayeredWindowAttributes(nHWND, nColor, 0, LWA_ALPHA)
case nAction = 2 && Make Opaque
SetWindowLong(nHWND, GWL_EXSTYLE, lnFlags) &&Sets the original flags to the window
SetLayeredWindowAttributes(nHWND, nColor, 0, 0)
endcase


for make irregular form i have put image on form picture property and in the init event i call:

Thisform.Makeirregular(Thisform.HWnd,RGB(0,0,255),1)

now, i have a shaped form and all work fine.

now, i want create a shaped button
i think the code for do this is the same but i must get the button handle.

for get button handle i use:

Declare Integer FindWindowEx In Win32API Integer, Integer, Integer, Integer

hB=FindWindowEx(thisform.HWnd,0,0,0)
This.Makeirregular(hB,RGB(0,0,255),,1)

but this code don't want work :(
why?
 
Like I said - forms are windows, buttons aren't! Unless you use an ActiveX button, it won't ever have a handle.

Rick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top