Page 1 of 1

Re: X_Pos and Y_Pos ---> Button 1

Posted: Mon Jun 27, 2011 9:59 pm
by netmaestro

Code: Select all

Button1 = CreateWindowEx_(...
GetWindowRect_(Button1, @br.RECT)
x = br\left
y = br\top

Re: X_Pos and Y_Pos ---> Button 1

Posted: Wed Jun 29, 2011 2:40 am
by happer66
Do you mean something like this?
(Sorry for the sloppy code)

Code: Select all

Procedure WindowCallback(Window, Message, wParam, lParam)
  Select Message
    Case #WM_CLOSE
     
        DestroyWindow_(Window)
     
        Result  = 0

    Case #WM_DESTROY
      PostQuitMessage_(0)
      Result  = 0
    Default
      Result  = DefWindowProc_(Window, Message, wParam, lParam)
  EndSelect
  ProcedureReturn Result
EndProcedure

#Style  = #WS_VISIBLE | #WS_BORDER | #WS_SYSMENU
#StyleEx  = #WS_EX_TOOLWINDOW

WindowClass.s  = "MeinFenster"
wc.WNDCLASSEX
wc\cbsize  = SizeOf(WNDCLASSEX)
wc\lpfnWndProc  = @WindowCallback()
wc\hCursor  = LoadCursor_(0, #IDC_CROSS)

wc\hbrBackground  = #COLOR_WINDOW + 1
wc\lpszClassName  = @WindowClass
RegisterClassEx_(@wc)

hWndMain  = CreateWindowEx_(#StyleEx, WindowClass, "Test-Window", #Style, 10, 10, 200, 200, 0, 0, 0, 0)

m=CreateWindowEx_(0, "Button", "Button 1", #WS_CHILD | #WS_VISIBLE, 10, 10, 100, 20, hWndMain, 0, 0, 0)

GetWindowRect_(m, @br.RECT)
mPoint.POINT
mPoint\x = br\left
mPoint\y = br\top
ScreenToClient_(hWndMain, mPoint)
Debug x = br\left
Debug y = br\top
Debug mPoint\x
Debug mPoint\y

ShowWindow_(hWndMain,  #SW_SHOWDEFAULT)
UpdateWindow_(hWndMain);

While GetMessage_(msg.MSG, #Null, 0, 0 )
  TranslateMessage_(msg)
  DispatchMessage_(msg)
Wend