X_Pos and Y_Pos ---> Button 1

Just starting out? Need help? Post your questions and find answers here.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: X_Pos and Y_Pos ---> Button 1

Post by netmaestro »

Code: Select all

Button1 = CreateWindowEx_(...
GetWindowRect_(Button1, @br.RECT)
x = br\left
y = br\top
BERESHEIT
User avatar
happer66
User
User
Posts: 33
Joined: Tue Jan 12, 2010 12:10 pm
Location: Sweden

Re: X_Pos and Y_Pos ---> Button 1

Post 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
Image If your code isn't clean atleast make sure it's pure!
Post Reply