I've only been using PureBasic for a few weeks and have been loving it. I have wanted to learn more about the Windows API for a long time, and it's been an unexpected bonus to find so much Win API help in the PB forums, in addition to PB help.
My question...
I've tried to implement a modified version of Sparkie's example from his post at: viewtopic.php?p=59741#59741 But, it's not working for me using an EditorGadget, instead of a StringGadget.
Is this because a different API call should be used, or is it a problem with the EditorGadget? BTW, I have checked out Sparkie's other recommendation posted just prior to the other one at the link above. That will work for me as well, but I would really like to use the Win API call.
Since I'm only barely scratching the surface of learning Win API calls, I would really appreciate some help. Here's my usage of Sparkie's code, where I've inserted an EditorGadget.
Code: Select all
Enumeration 
  #Window_0 
EndEnumeration 
Enumeration 
  #Edit_0 
  #String_0
  #String_1 
EndEnumeration 
Global OldCallback 
Procedure.l MyWindowCallBack(hwnd, msg, wParam, lParam) 
  
  Select msg 
    Case #WM_CONTEXTMENU 
      ;If hwnd = GadgetID(#String_0)
      If hwnd = GadgetID(#Edit_0) 
        msg = #WM_KEYDOWN 
        wParam = #VK_ESCAPE 
        lParam = 0 
      EndIf 
    Case #WM_PASTE 
      ;If hwnd = GadgetID(#String_0) :  ProcedureReturn : EndIf 
      If hwnd = GadgetID(#Edit_0) :  ProcedureReturn : EndIf 
    Case #WM_COPY
      ;If hwnd = GadgetID(#String_0) :  ProcedureReturn : EndIf 
      If hwnd = GadgetID(#Edit_0) :  ProcedureReturn : EndIf 
    Case #WM_CUT
      ;If hwnd = GadgetID(#String_0) :  ProcedureReturn : EndIf
      If hwnd = GadgetID(#Edit_0) :  ProcedureReturn : EndIf 
  EndSelect 
  
  ProcedureReturn CallWindowProc_(OldCallback, hwnd, msg, wParam, lParam) 
EndProcedure 
If OpenWindow(#Window_0, 0, 0, 300, 100,  #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_TitleBar , "Disable cut, copy, paste") 
  If CreateGadgetList(WindowID())
    ;StringGadget(#String_0, 50, 20, 200, 20, "Cut, Copy, Paste DISABLED")
    EditorGadget(#Edit_0, 50, 20, 200, 20) 
    StringGadget(#String_1, 50, 50, 200, 20, "Cut, Copy, Paste ENABLED")
    ;ActivateGadget(#String_0)
    ActivateGadget(#Edit_0)
    ;OldCallback = SetWindowLong_(GadgetID(#String_0), #GWL_WNDPROC, @MyWindowCallBack())
    OldCallback = SetWindowLong_(GadgetID(#Edit_0), #GWL_WNDPROC, @MyWindowCallBack()) 
  EndIf 
EndIf 
Quit = #False 
Repeat 
  event = WaitWindowEvent() 
  
  Select event 
    
    Case #PB_EventCloseWindow 
      Quit = #True 
      
  EndSelect 
Until Quit 
End
