about the editor gadget
-
- User
- Posts: 15
- Joined: Sun Sep 12, 2004 6:41 am
about the editor gadget
Hello,about that editorgadget...is there any way to delete selected text,but not with back space,instead when a menuevent() happens..?
For windows, here is one way:
Tons of good stuff in the MS platform SDK help. Index search on EM_ for some useful SendMessage_( edit flags
Code: Select all
#_btnGad=1
winID=OpenWindow(0,0,0,300,300,#PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_SizeGadget|#PB_Window_TitleBar,"SOMETHING")
If winID
gadList=CreateGadgetList(WindowID(0))
If gadList
btnID=ButtonGadget(#_btnGad,10,1,50,20,"DELETE")
edGadID=EditorGadget(2,5,25,290,290)
If edGadID
Repeat
Event = WaitWindowEvent()
If Event=#PB_Event_Gadget
If EventGadgetID()=#_btnGad And EventType()=#PB_EventType_LeftClick
z.s=""
SendMessage_(edGadID,#EM_REPLACESEL,1,z)
EndIf
EndIf
Until Event = #PB_EventCloseWindow
EndIf
EndIf
EndIf
@}--`--,-- A rose by any other name ..
-
- User
- Posts: 15
- Joined: Sun Sep 12, 2004 6:41 am
-
- Enthusiast
- Posts: 499
- Joined: Wed Sep 17, 2003 9:17 pm
- Location: Southern California
- Contact:
Edited:
Yian, you should really read the MS documentation...
RichEdit Controls:
http://msdn.microsoft.com/library/en-us ... ntrols.asp
Edit Controls (This applies too):
http://msdn.microsoft.com/library/en-us ... ntrols.asp
Code: Select all
#_btnGad=1
#_btnGad2=2
winID=OpenWindow(0,0,0,300,300,#PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_SizeGadget|#PB_Window_TitleBar,"SOMETHING")
If winID
gadList=CreateGadgetList(WindowID(0))
If gadList
btnID=ButtonGadget(#_btnGad,10,1,50,20,"DELETE")
btnID2=ButtonGadget(#_btnGad2,80,1,100,20,"CHANGE COLOR")
edGadID=EditorGadget(3,5,25,290,290)
If edGadID
Repeat
Event = WaitWindowEvent()
If Event=#PB_Event_Gadget
If EventGadgetID()=#_btnGad And EventType()=#PB_EventType_LeftClick
z.s=""
SendMessage_(edGadID,#EM_REPLACESEL,1,z)
ElseIf EventGadgetID()=#_btnGad2 And EventType()=#PB_EventType_LeftClick
Format.CHARFORMAT
Format\cbSize=SizeOf(CHARFORMAT)
Format\dwMask=#CFM_COLOR
Format\crTextColor=RGB(Random(255),Random(255),Random(255))
SendMessage_(edGadID,#EM_SETCHARFORMAT,#SCF_SELECTION,Format)
EndIf
EndIf
Until Event = #PB_EventCloseWindow
EndIf
EndIf
EndIf
RichEdit Controls:
http://msdn.microsoft.com/library/en-us ... ntrols.asp
Edit Controls (This applies too):
http://msdn.microsoft.com/library/en-us ... ntrols.asp
Last edited by PolyVector on Fri Sep 17, 2004 2:23 am, edited 1 time in total.
@PolyVector ... Missing Event catch for #_btnGad2. Change Gadget# in line 17 from #_btnGad to #_btnGad2.
to
Code: Select all
ElseIf EventGadgetID()=#_btnGad And EventType()=#PB_EventType_LeftClick
Code: Select all
ElseIf EventGadgetID()=#_btnGad2 And EventType()=#PB_EventType_LeftClick
What goes around comes around.
PB 5.21 LTS (x86) - Windows 8.1
PB 5.21 LTS (x86) - Windows 8.1
-
- Enthusiast
- Posts: 499
- Joined: Wed Sep 17, 2003 9:17 pm
- Location: Southern California
- Contact:
-
- User
- Posts: 15
- Joined: Sun Sep 12, 2004 6:41 am
Thanks poly,I had looked through the MS pages but I ddin't find the color commands.Also,I had searched this forum and got some really complicated stuff and people saying you MUST use windows callback to do it.Thanks again! 
Hmm ok this is some stuffI don't get:

Hmm ok this is some stuffI don't get:
Is this how you assign types in PB?Format.CHARFORMAT
Format\cbSize=SizeOf(CHARFORMAT)
Format\dwMask=#CFM_COLOR
Format\crTextColor=RGB(Random(255),Random(255),Random(255))
-
- Enthusiast
- Posts: 499
- Joined: Wed Sep 17, 2003 9:17 pm
- Location: Southern California
- Contact:
This creates a variable called 'Format' of type CHARFORMAT
This sets the 'cbSize' element of Format the size(in bytes) of a CHARFORMAT structure... Windows needs this to prevent buffer overflows...
This assigns the 'crTextColor' element of Format to a random RGB value...
It's pretty simple stuff... The thread that I believe you are refering to was about the Edit class... You do need to use callbacks to modify that... We're talking about the RichEdit class here...
Code: Select all
Format.CHARFORMAT
Code: Select all
Format\cbSize=SizeOf(CHARFORMAT)
Code: Select all
Format\crTextColor=RGB(Random(255),Random(255),Random(255))
Heya Yian_The_Craft,
I'm not sure how far along you are so if I am telling you something you already know, please forgive.
(Also, have a windows bias in the following.)
You have a core PureBasic (what you see in the help).
You have an extended PureBasic, which adds functionality by exposing the operating system or user libraries.
Recognised windows functions have an underscore appended to the function name.
So:
In PB you can define structures and use them to build your own variable types.
You define a variable type using "dot" notation, eg myVar.l for long. Or myVar.myStructure for structures.
Elements or fields within the structured variable are accessed by using a backslash, eg, myVar\myField.
PB also has a number of windows structures it recognises.
CHARFORMAT is one such. The "external" or "OpSys" structures are assigned to a variable name in the same way as a normal PB structure, you just don't need to define them.
In the code you showed, "Format" is defined as variable type (structured as) CHARFORMAT.
Just to confuse, most code shown here mixes three things:
1: Core PB functionality.
2: Recognised windows calls and structures, etc, which are not PB per se but which can be used in PB.
3: And user libraries. This one threw me for ages, because there was nothing in the help nor the windows SDK help to cover these, and most code show forgets to advise there is a library dependency.
Anyhow, by now you're bored to tears, enlightened, or confused.
Edit: What PolyVector said (sneaking in a post whilst I was still typing) but in verbose mode.
I'm not sure how far along you are so if I am telling you something you already know, please forgive.

(Also, have a windows bias in the following.)
You have a core PureBasic (what you see in the help).
You have an extended PureBasic, which adds functionality by exposing the operating system or user libraries.
Recognised windows functions have an underscore appended to the function name.
So:
In PB you can define structures and use them to build your own variable types.
You define a variable type using "dot" notation, eg myVar.l for long. Or myVar.myStructure for structures.
Elements or fields within the structured variable are accessed by using a backslash, eg, myVar\myField.
PB also has a number of windows structures it recognises.
CHARFORMAT is one such. The "external" or "OpSys" structures are assigned to a variable name in the same way as a normal PB structure, you just don't need to define them.
In the code you showed, "Format" is defined as variable type (structured as) CHARFORMAT.
Just to confuse, most code shown here mixes three things:
1: Core PB functionality.
2: Recognised windows calls and structures, etc, which are not PB per se but which can be used in PB.
3: And user libraries. This one threw me for ages, because there was nothing in the help nor the windows SDK help to cover these, and most code show forgets to advise there is a library dependency.
Anyhow, by now you're bored to tears, enlightened, or confused.

Edit: What PolyVector said (sneaking in a post whilst I was still typing) but in verbose mode.

@}--`--,-- A rose by any other name ..
-
- User
- Posts: 15
- Joined: Sun Sep 12, 2004 6:41 am
OK I'm not new to programming,just PB.I am self-taught(since 99) so there are some holes in my knowledge.Types are something I have be learning recently and I haven't used it much.
Thanks to all!
But I have one question...we define the var Format as type CHARRANGE or whatever it was,but why didn't we have to specify that the type CHARRANGE includes cpMin for example?Or is that automatically recognised because it is a windows type? Thanks
Also...could you please post an example for how to use #EM_FINDTEXT ? I get confused with it because it requires some weird stuff...
Thanks to all!
But I have one question...we define the var Format as type CHARRANGE or whatever it was,but why didn't we have to specify that the type CHARRANGE includes cpMin for example?Or is that automatically recognised because it is a windows type? Thanks

Also...could you please post an example for how to use #EM_FINDTEXT ? I get confused with it because it requires some weird stuff...
