Page 1 of 1

Window API + Button Processing

Posted: Wed Jul 09, 2003 2:14 pm
by DarthPuff
=\ How do I get if a button has been clicked...

Code: Select all

Procedure WndProc(hWnd, uMsg, wParam, lParam)
  result = #PB_ProcessPureBasicEvents
  Select uMsg
    Case #BN_CLICKED
      ProcedureReturn 1
  EndSelect
EndProcedure

ProcedureDLL GadgetI(GadgetID,WinID)
  If Check
    UpdateWindow_(WinID)
  EndIf
  SendMessage_(GadgetID, #EM_SETEVENTMASK, 0, #BN_CLICKED|SendMessage_(GadgetID, #EM_GETEVENTMASK, 0, 0)) 
  If SetWindowCallback(@WndProc())=1
      ProcedureReturn 1
    Else
      ProcedureReturn 0
  EndIf
EndProcedure
I tried this but its obviously wrong...

Posted: Wed Jul 09, 2003 3:13 pm
by LarsG
You should look up the WindowEvent() command in the help file (under the window "catalogue")

-Lars

Posted: Thu Jul 10, 2003 1:42 am
by DarthPuff
I don't think that will work... heres how I create buttons

Code: Select all

ProcedureDLL ButtonG(GadgetID, WinID, X, Y, Width, Height, Text.s, Flag.s)
  hWndMain = WinID
  
  t=0
  Repeat
    sV.s=StringField(Flag.s,t,"|")
    If sV.s<>""
    Select sV.s
      Case "#WS_CHILD"
        lFlag.l=lFlag | #WS_CHILD
      Case "#WS_VISIBLE"
        lFlag.l=lFlag | #WS_VISIBLE
      Case "#WS_CLIPCHILDREN"
        lFlag.l=lFlag | #WS_CLIPCHILDREN
    EndSelect
    t+1
    EndIf
  Until sV.s=""
  
  WinID2.l = CreateWindowEx_(0, "Button", Text.s, lFlag.l , X, Y, Width, Height, hWndMain, 0, 0, 0)
  
  currstyle.l = GetWindowLong_(hWndMain,#GWL_STYLE);
  SetWindowLong_(hWndMain,#GWL_STYLE,currstyle.l | #WS_CLIPCHILDREN);
  ShowWindow_(hWndMain,  #SW_SHOWDEFAULT) 
  UpdateWindow_(hWndMain);
  ProcedureReturn WinID2.l
EndProcedure
=\ Do you guys have any idea how to get a button being clicked from the windows api?

Posted: Thu Jul 10, 2003 8:48 am
by Fred
It's a WM_COMMAND message. I suggest you to read some book about Windows programming, as it's really the start :)

Posted: Thu Jul 10, 2003 8:57 am
by DarthPuff
Ahhh... =\ but what do I do after that... I send a message for #WM_COMMAND then I test in windowcallback() to see if its #BN_CLICKED... ???

Posted: Thu Jul 10, 2003 9:08 am
by Edwin Knoppert
You must use the hiword and loword on wparam
wParam has 2 parts during wm_command

msdn:
The high-order word specifies the notification code if the message is from a control

The low-order word specifies the identifier of the menu item, control, or accelerator

Hiword:
( wParam >> 16 & $ffff )

(When do we ... get these calls in PB?)

Posted: Thu Jul 10, 2003 9:09 am
by Edwin Knoppert
Loword:
wParam & $ffff

Posted: Thu Jul 10, 2003 12:56 pm
by DarthPuff
Thank you for the help ... but =P A lil more detail plzzzz... ;) I'm not to great with this stuff...