Page 1 of 1

Inserting a Value into IDE

Posted: Wed Jan 02, 2008 11:45 pm
by Rook Zimbabwe
OKso I am almost finished with the ColorPicker and thanks to everyone that has helped me...

The one thing I cannot seem to do is to get my program to insert the values into the IDE like the colorpicker tool does...

I thought that the IDE colorpicked might be running as some sort fo DLL and so I included DLL routines in my program...

I use the following but there is no output:

Code: Select all

ProcedureDLL.s OutRGB(red$,grn$,blu$)
groplng$ = "RGB("+red$+","+grn$+","+blu$+")"
Debug "OUT: "+groplng$
ProcedureReturn groplng$

EndProcedure
All variables are global.

What am I not doing right? :cry:

Posted: Thu Jan 03, 2008 12:25 am
by citystate
can DLLs return a string?
have you tried returning the pointer to the string?

Posted: Thu Jan 03, 2008 12:27 am
by netmaestro
The way to accomplish this is to compile your program to an .exe and install it into the IDE using "Tools->Configure Tools". All you have to fill in for fields is the first one, "Commandline:" where you will put the path to your exe, "Name" which will be whatever you like, and "Event" which you should choose "Menu or Shortcut". Here's a sample code that works here, you will want to replace ColorRequester() with your custom color picker:

Code: Select all

result = ColorRequester()
insert$ = "RGB("+Str(Red(result))+","+Str(Green(result))+","+Str(Blue(result))+")"
scintilla = Val(GetEnvironmentVariable("PB_Tool_Scintilla"))
SendMessage_(scintilla, #EM_REPLACESEL, 0, @insert$)
Once you've done this you can click your tool from the tools menu and it will let you select a color, then place "RGB(0,0,0)" into your IDE at the cursor position. (assuming you chose black)

Posted: Thu Jan 03, 2008 12:28 am
by eddy
I have the same problem... :?

We have all to do it :
- scintilla gadget's handle : PB_TOOL_Scintilla
- sendmessage_() with this command #SCI_INSERTTEXT

But an external tool can't send string buffer easily to an other app. :(

Posted: Thu Jan 03, 2008 12:32 am
by eddy
netmaestro wrote:The way to accomplish this is to compile your program to an .exe and install it into the IDE using "Tools->Configure Tools". All you have to fill in for fields is the first one, "Commandline:" where you will put the path to your exe, "Name" which will be whatever you like, and "Event" which you should choose "Menu or Shortcut". Here's a sample code that works here, you will want to replace ColorRequester() with your custom color picker:

Code: Select all

result = ColorRequester()
insert$ = "RGB("+Str(Red(result))+","+Str(Green(result))+","+Str(Blue(result))+")"
scintilla = Val(GetEnvironmentVariable("PB_Tool_Scintilla"))
SendMessage_(scintilla, #EM_REPLACESEL, 0, @insert$)
why can't we use scintilla commands SCI_* ?

Posted: Thu Jan 03, 2008 12:35 am
by netmaestro
why can't we use scintilla commands SCI_* ?
Eddy, I don't know! I tried, and got the same problem as you did, so I switched to a Windows message. Seems like it should work though.

Posted: Thu Jan 03, 2008 8:29 pm
by Rook Zimbabwe
Well it inserts a color... It inserts WHITE (RGB(255,255,255) and will NOT let me choose any other color...

In fact... no matter what I pick the insert button is white and the rgb code is 255, 155, 255....

Off the IDE this works fine.

Will try as standalone... Standalone... Hmmm... If I create EXE in the same directory... it does what is is supposed to do in returning the color to the insert button.

But no output.

As I add it to my tools... output only white???

nope... works from IDE when run but NOT from IDE when called as a TOOL... that is when it returns WHITE

{{UPDATE}}
When I run this tool on its OWN sourcecode it works...

When I run it on ANYTHING ELSE... White is the order of the day...

Is my computer predudiced???

{{UPDATE AGAIN}}

It was a simple PEBKC Error - Reinforced by ID10t Variables!!! I did not Set the working directory in the tools section... I thought the images would be loaded into the program itself when compiled. Have to rethink.

Posted: Thu Jan 03, 2008 9:26 pm
by Rook Zimbabwe
Not so simple.

It has to do with how you load the images into the Image Gadget and tell the mouse what to draw.

to start with:

Code: Select all

Global Image1, Image2, Image3


Image1= CatchImage(#Image_1, ?Image1)
Image2= CatchImage(#Image_2, ?Image2)
Image3= CatchImage(#Image_3, ?Image3)

DataSection
Image1:
  IncludeBinary "colormap1.jpg"
Image2:
  IncludeBinary "greyscale.jpg"
Image3:
  IncludeBinary "plopscale.jpg"
EndDataSection
Does load the images into the program for use... Yay!!!

I modified the BOLD portion so as NOT to confuse the Image Gadget
Image1= CatchImage(#Image_1, ?Image1) where it had been #PB_Any which was misleading the program and is what my image never showed up or returned only WHITE

then I modified the Image Gadget a bit:

Code: Select all

ImageGadget(#Image_1, 6, 12, 597, 523, ImageID(#Image_1), #PB_Image_Border | #PB_EventType_LeftClick)
      RegisterGadgetEvent(#Image_1, @Image_1_Event()) 
theline:
ImageGadget(#Image_1, 6, 12, 597, 523, ImageID(#Image_1),
Had:
Image1 in that spot. So it was agreement that was thunking this apart... Though I do not see whay that wuld not have worked since they referenced the same thing???

I did not need the LoadImage() commands since the program already had them in memory because of Catchimage()

Oh well on to the finish! 8)

Thank everyone for helping me. I know I am slow.