Page 1 of 1

Posted: Thu Jul 04, 2002 10:29 pm
by BackupUser
Restored from previous forum. Originally posted by WolfgangS.

HI!

1. Problem ...
Normaly i use this NewPanel() procedure to open a new panel with a RichEditGadget in it.
The problem is, when i use the RichEditOptions(#RichEdit,$373777) command, i just can use NewPanel() one time. The second time and all times later the OpenRichEdit command gives me a 0 back.
But when i use the NewPanel() procedure WITHOUT the RichEditOptions(#RichEdit,$373777) command, all works fine.

Why ?!??!





2. Problem
I want to get a horizontal and vertical scrollbar (hide if not necessary). Why don't works this ?:
#ES_AUTOHSCROLL|#WS_VISIBLE|#ES_AUTOVSCROLL



Best regards ...
WolfgangS



Win2k PB3.2







#RichEdit=#ES_AUTOHSCROLL|#WS_VISIBLE|#ES_SAVESEL|#ES_AUTOVSCROLL


Structure PanelComplex
Number.l ; Nummerierung des PanelComplexes
PathAndName.s ; Pfad+Name
Frame3dGadgetID.l ; ID des Frame3dGadget
RichEditGadgetID.l ; ID des RichEditGadget
Saved.l ; Ob schon gespeichert wurde
EndStructure



Procedure UpdatePanels()
UseWindow(#MotherWindowID)
SelectElement(Panel(), GetGadgetState(#PanelGadgetID)); !!!!!!!!!!!!! Aktiviert das aktuelle Element - Bezug auf Panel
If GetGadgetState(#PanelGadgetID)=0
ActivateGadget(#WebGadgetID)
Else
UseRichEdit(Panel()\RichEditGadgetID)
ActivateRichEdit(Panel()\RichEditGadgetID) ; !!!!!!!!!!!!! Aktiviert das dazugehörige RichEditGadget
EndIf
EndProcedure


Procedure NewPanel() ; öffnet neues Panel
UseWindow(#MotherWindowID)
LastElement(Panel()) : AddElement(Panel()) : AmountPanel+1
Panel()\Number=AmountPanel ; Nummerierung des PanelComplexes
Panel()\PathAndName=#String_Untitled ; Pfad+Name
Panel()\Frame3dGadgetID=#Frame3dID+AmountPanel ; ID des Frame3dGadget
Panel()\RichEditGadgetID=#RichID+AmountPanel ; ID des RichEditGadget
Panel()\Saved=#TRUE ; Ob schon gespeichert wurde #TRUE = weil leer
AddGadgetItem(#PanelGadgetID, -1, #String_Untitled)
Frame3DGadget(Panel()\Frame3dGadgetID,0,0,WindowWidth()-#RightBorder_3d,WindowHeight()-#LowerBorder_3d,"Frame3dGadgetID="+Str(Panel()\Frame3dGadgetID)+" Liste:"+Str(ListIndex(Panel())),2)
SetGadgetState(#PanelGadgetID, CountGadgetItems(#PanelGadgetID)-1) ; aktiviert das aktuelle (letzte) Panel
If OpenRichEdit(GadgetID(Panel()\Frame3dGadgetID),Panel()\RichEditGadgetID,0,0,WindowWidth()-#RightBorder_Rich,WindowHeight()-#LowerBorder_Rich, Str(Panel()\RichEditGadgetID))=0
MessageRequester("Error","Open new Richgadget",0)
End
EndIf
ActivateRichEdit(Panel()\RichEditGadgetID)
UseRichEdit(Panel()\RichEditGadgetID)
RichEditBackgroundColor($373777)
RichEditTextColor($eeee00)
RichEditOptions(#RichEdit,$373777)
UpdatePanels()
EndProcedure

Posted: Fri Jul 05, 2002 12:21 am
by BackupUser
Restored from previous forum. Originally posted by El_Choni.

Hi,

It's strange that you managed to make it work just by commenting RichEditOptions(), because it shouldn't. The main problem in your code is that you're passing OpenRichEdit() a wrong first parameter. You should get the handle to the Frame3DGadget first:

Code: Select all

Frame3DhWnd = Frame3DGadget(Panel()\Frame3dGadgetID,0,0,WindowWidth()-#RightBorder_3d,WindowHeight()-#LowerBorder_3d,"Frame3dGadgetID="+Str(Panel()\Frame3dGadgetID)+"Liste:"+Str(ListIndex(Panel())),2)
And pass it as the first parameter of OpenRichEdit(Frame3DhWnd, ...)

You should also use the #WS_CHILD flag:

Code: Select all

#RichEdit=#ES_AUTOHSCROLL|#WS_VISIBLE|#ES_SAVESEL|#ES_AUTOVSCROLL|#WS_CHILD
Also, I suggest you to increment AmountPanel by two, instead of one, because even if RichEdit internal index is not supposed to conflict with PB gadges ones, this index is used by Windows when it creates PB gadgets and RichEdit controls, and should be unique.

I'm looking closely at your code to find out if I can improve setting options easily. Anyway: tested your code with these changes and it worked fine. Tell me if you find any more trouble.

Thanks for using the lib. Bye,

El_Choni

Edited by - El_Choni on 05 July 2002 01:34:57

Posted: Fri Jul 05, 2002 3:14 am
by BackupUser
Restored from previous forum. Originally posted by El_Choni.

Hi again,

Ok, I've updated the library. Download version 1.6 when it's available (usually less than 24 hours). In any case, you should change #RichEdit to:

Code: Select all

#WS_CHILD|#WS_VISIBLE|#ES_NOHIDESEL|#WS_CLIPSIBLINGS|#WS_HSCROLL|#ES_SAVESEL|#ES_MULTILINE|#WS_VSCROLL|#ES_AUTOVSCROLL
I guess you want it multilined, don't you?

RichEditOptions() now change only the options of the controls created *after* it's called, so you would put it just before the OpenRichEdit() call (there's another function to change options on the fly now: ChangeRichEditOptions(), which apply only to the current control). RichEditBackground() is now used to change the current control's background color.

Your procedure would look like this when you install version 1.6:

Code: Select all

Procedure NewPanel() ; öffnet neues Panel
  UseWindow(#MotherWindowID)
  LastElement(Panel()) : AddElement(Panel()) : AmountPanel+2 ; (changed)
  Panel()\Number=AmountPanel ; Nummerierung des PanelComplexes
  Panel()\PathAndName=#String_Untitled ; Pfad+Name
  Panel()\Frame3dGadgetID=#Frame3dID+AmountPanel ; ID des Frame3dGadget
  Panel()\RichEditGadgetID=#RichID+AmountPanel+2 ; ID des RichEditGadget (changed by me)
  Panel()\Saved=#TRUE ; Ob schon gespeichert wurde #TRUE = weil leer
  AddGadgetItem(#PanelGadgetID, -1, #String_Untitled)
  Frame3DID=Frame3DGadget(Panel()\Frame3dGadgetID,0,0,WindowWidth()-#RightBorder_3d,WindowHeight()-#LowerBorder_3d,"Frame3dGadgetID="+Str(Panel()\Frame3dGadgetID)+" Liste:"+Str(ListIndex(Panel())),2)
  SetGadgetState(#PanelGadgetID, CountGadgetItems(#PanelGadgetID)-1) ; aktiviert das aktuelle (letzte) Panel
  RichEditOptions(#RichEdit)
  If OpenRichEdit(Frame3DID,Panel()\RichEditGadgetID,0,0,WindowWidth()-#RightBorder_3d,WindowHeight()-#LowerBorder_3d, Str(Panel()\RichEditGadgetID))=0
    MessageRequester("Error","Open new Richgadget",0)
    End
  EndIf
  ActivateRichEdit(Panel()\RichEditGadgetID) ; better put this after colour settings

  UseRichEdit(Panel()\RichEditGadgetID) ; this is not needed; the RichEdit index used is the last opened (or used).

  RichEditBackground($373777)
  RichEditBackgroundColor($373777)
  RichEditTextColor($eeee00)
  UpdatePanels()
EndProcedure
I hope this helps you. Don't forget to download the new lib:

http://www.reelmediaproductions.com/pb

Bye,

El_Choni

Edited by - El_Choni on 08 July 2002 19:05:22

Posted: Fri Jul 05, 2002 6:09 am
by BackupUser
Restored from previous forum. Originally posted by WolfgangS.

Ola El_Choni

thank you very much for your help, i really appreciate this !

My way to open a RichEditGadget is ok, 'cause i use the GadgetID() command to get the Handle (not the ID) of the Frame3dGadget.

Unfortunetely Fred and a lot of other People (?) mixed up a bit "handle" and "ID".
My opinion is:
A handle is a close to the WindowOS parameter, also usable for API.
An ID is only a PB internal parameter, to distinguish gadgets'n'stuff.
The Help says ...
*************************************************
Syntax

GadgetID = GadgetID(#Gadget)
Description

Returns the unique GadgetID of the #Gadget.
Supported OS

Windows, AmigaOS, Linux
*************************************************

but is should be:
*************************************************
Syntax

handle = GetHandle(#GadgetID)
Description

Returns the unique handle of the #GadgetID.
Supported OS

Windows, AmigaOS, Linux
*************************************************
But please don't hurt me if i'm wrong. Otherwise it does not matter how we call it.




Thank you for the flags suggestion. Unfortunately (again :wink: ?) i need it NOT multilined. When i reach the max width of the RichEditGadget it should appear the horizontal scrollbar.
After a few hours of try out, i really "throw the Towel" and ask you for some mercy help.


Adiós
WolfgangS

Posted: Fri Jul 05, 2002 11:49 am
by BackupUser
Restored from previous forum. Originally posted by El_Choni.

Ok, then just delete #WS_MULTILINE, #ES_AUTOVSCROLL and #WS_VSCROLL (you won't be needing vertical scroll if you use a single line, I guess). And don't forget to add #WS_CHILD, #WS_HSCROLL and #ES_AUTOHSCROLL. Notice that horizontal scroll won't appear if you only write spaces.

And sorry about the ID thing, you're right. In the library docs I decided to use ID for handles and index for the internal index, but it gets confusing anyway.

Hope you get it working now. Bye,

El_Choni

Posted: Mon Jul 08, 2002 4:50 pm
by BackupUser
Restored from previous forum. Originally posted by Franco.
The Help says ...
*************************************************
Syntax

GadgetID = GadgetID(#Gadget)
Description

Returns the unique GadgetID of the #Gadget.
Supported OS

Windows, AmigaOS, Linux
*************************************************

but is should be:
*************************************************
Syntax

handle = GetHandle(#GadgetID)
Description

Returns the unique handle of the #GadgetID.
Supported OS

Windows, AmigaOS, Linux
*************************************************
But please don't hurt me if i'm wrong. Otherwise it does not matter how we call it.
AFAIK 'ID' is always used (in the help file) as IDentifier what means the OS Handle.
That's why there is a '#' when a PureBasic Gadget Number is meant (like #Gadget).
Conclusion:
ID = Handle
# = PureBasic Number


Have a nice day...
Franco

Sometimes you have to go a lonely way to accomplish genius things.