Window API + Button Processing

Windows specific forum
DarthPuff
User
User
Posts: 47
Joined: Sat Apr 26, 2003 2:51 am
Location: USA
Contact:

Window API + Button Processing

Post 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...
LarsG
Enthusiast
Enthusiast
Posts: 713
Joined: Mon Jun 02, 2003 1:06 pm
Location: Norway
Contact:

Post by LarsG »

You should look up the WindowEvent() command in the help file (under the window "catalogue")

-Lars

AMD Athlon XP2400, 512 MB RAM, Hercules 3D Prophet 9600 256MB RAM, WinXP
PIII 800MHz, 320 MB RAM, Nvidia Riva Tnt 2 Mach 64 (32MB), WinXP + Linux
17" iMac, 1.8 GHz G5, 512 MB DDR-RAM, 80 GB HD, 64 MB Geforce FX 5200, SuperDrive, OSX
DarthPuff
User
User
Posts: 47
Joined: Sat Apr 26, 2003 2:51 am
Location: USA
Contact:

Post 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?
Fred
Administrator
Administrator
Posts: 18350
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

It's a WM_COMMAND message. I suggest you to read some book about Windows programming, as it's really the start :)
DarthPuff
User
User
Posts: 47
Joined: Sat Apr 26, 2003 2:51 am
Location: USA
Contact:

Post 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... ???
Edwin Knoppert
Addict
Addict
Posts: 1073
Joined: Fri Apr 25, 2003 11:13 pm
Location: Netherlands
Contact:

Post 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?)
Edwin Knoppert
Addict
Addict
Posts: 1073
Joined: Fri Apr 25, 2003 11:13 pm
Location: Netherlands
Contact:

Post by Edwin Knoppert »

Loword:
wParam & $ffff
DarthPuff
User
User
Posts: 47
Joined: Sat Apr 26, 2003 2:51 am
Location: USA
Contact:

Post by DarthPuff »

Thank you for the help ... but =P A lil more detail plzzzz... ;) I'm not to great with this stuff...
Post Reply