Help with ownerdraw custom edit gadget

Windows specific forum
User avatar
jacdelad
Addict
Addict
Posts: 1431
Joined: Wed Feb 03, 2021 12:46 pm
Location: Planet Riesa
Contact:

Help with ownerdraw custom edit gadget

Post by jacdelad »

I'm not firm with custom drawing windows controls. I just know that it opens the world for very powerful customizations. However, is it possible (with ownerdrawing) to extend an edit gadget with things like the clickable "X" on the right that erases the content or the spyglass in the left? I know I can do it with a canvas gadget and such, but an extended edit gadget would be much more comfortable.
PureBasic 6.04/XProfan X4a/Embarcadero RAD Studio 11/Perl 5.2/Python 3.10
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB
User avatar
chi
Addict
Addict
Posts: 1028
Joined: Sat May 05, 2007 5:31 pm
Location: Linz, Austria

Re: Help with ownerdraw custom edit gadget

Post by chi »

How about using a CanvasGadget as a container?

Code: Select all

OpenWindow(0, 0, 0, 320, 200, "", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)

CanvasGadget(0, 85, 85, 150, 21, #PB_Canvas_Container)
  EditorGadget(1, 25, 1, 100, 19)
CloseGadgetList()
  
StartDrawing(CanvasOutput(0))
  DrawingMode(#PB_2DDrawing_Transparent)
  DrawText(7, 2, "...", #Black)
  DrawText(134, 2, "x", #Black)
StopDrawing()

While WaitWindowEvent() <> #PB_Event_CloseWindow : Wend
Et cetera is my worst enemy
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4636
Joined: Sun Apr 12, 2009 6:27 am

Re: Help with ownerdraw custom edit gadget

Post by RASHAD »

Hi
You can use ButtonGadget() or ButtonImageGadget() too

Code: Select all

OpenWindow(0, 0, 0, 320, 200, "", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
  TextGadget(1,290,10,20,20,"X",#WS_CLIPSIBLINGS |#WS_BORDER|#SS_CENTER|#SS_CENTERIMAGE|#SS_NOTIFY)
  SetGadgetColor(1,#PB_Gadget_FrontColor,$0000FF)
  EditorGadget(0, 5, 5, 310, 190,#WS_CLIPSIBLINGS)

Repeat
  Select WaitWindowEvent()
    Case #PB_Event_CloseWindow
      Quit = 1
      
    Case #PB_Event_Gadget
      Select EventGadget()
        Case 0
        
        Case 1
          ClearGadgetItems(0)
        
      EndSelect
  EndSelect
Until Quit = 1
Egypt my love
User avatar
jacdelad
Addict
Addict
Posts: 1431
Joined: Wed Feb 03, 2021 12:46 pm
Location: Planet Riesa
Contact:

Re: Help with ownerdraw custom edit gadget

Post by jacdelad »

...and that's both things I didn't want to...
PureBasic 6.04/XProfan X4a/Embarcadero RAD Studio 11/Perl 5.2/Python 3.10
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB
Post Reply