Page 1 of 1

Streaming images into an editor gadget

Posted: Mon Mar 28, 2005 11:31 pm
by srod
Hi there,

I'm happy enough streaming text into an editor gadget, but need some way of doing the same with combinations of text, bitmaps and Windows metafiles.

Is there an easy way of doing this or am I into the world of OLE? If so, I'd probably prefer to find some other way as that scares the life out of me!

I've thought about using a web gadget, but it doesn't really serve my purposes in this instance.

Thanks in advance.

Posted: Tue Mar 29, 2005 11:12 am
by leo1991
Do you search somethin like this?

Code: Select all

;
; Image in an EditorGadget 
; 29.3.2005,12:11 by Leo1991
;

hwnd = OpenWindow(0,0,0,640,480,#PB_Window_ScreenCentered|#PB_Window_SystemMenu,"Hello World!")
CreateGadgetList(hwnd)
hedit = EditorGadget(0,10,10,620,460)
CreateGadgetList(hedit)
file.s = OpenFileRequester("Bild","","*.bmp|*.bmp",0)
himg.l = LoadImage(0,file)
ImageGadget(1,10,10,10,10,himg)

Repeat
    
Until WaitWindowEvent() = #PB_Event_CloseWindow

re:

Posted: Tue Mar 29, 2005 12:00 pm
by srod
Thanks Leo1991,

I'd already considered that approach, but that really leads to using a web gadget.

What I'm after is a way of streaming an rtf source (read from a database) which mixes formatted text with images in a similar way to visual basic's .rtf property.

E.g. I might load a string variable with:

Code: Select all

"{\rtf1\ansi\ansicpg1252\deff0\deflang2057{\fonttbl{\f0\fswiss\fcharset0 Arial;}}
{\*\generator Msftedit 5.41.15.1503;}\viewkind4\uc1\pard\f0\fs20 Hello {\pict\wmetafile8\picwgoal662\pichgoal17 
010009000003b900000006001c00000000000400000003010800050000000b0200000000050000
000c020d001901040000002e0118001c000000fb021000070000000000bc020000000001020222
53797374656d00001901000074691f7f00ea120004ee83398092ae020c020000040000002d0100
001c000000fb029cff0000000000009001000000000440001254696d6573204e657720526f6d61
6e0000000000000000000000000000000000040000002d01010004000000020101000500000009
02000000020d000000320a5a000000010004000000000019010d00203b2d00030000001e000800
0000fa0200000600000000000000040000002d01020007000000fc020100000000000000040000
002d0103000800000025030200020002000f01020008000000fa02000000000000000000000400
00002d01040007000000fc020000ffffff000000040000002d01050004000000f0010200040000
002701ffff040000002d010000030000000000
}\par
}"
which mixes text and a Windows metafile and then I would like to stream this into an editor gadget.

The problem is that I can stream the text easily enough, but the image data is lost. I know for certain now that I must dabble with OLE which is a little beyond my experience at the mo.

The application I am writing involves the user selecting a whole heap of text and images and constructing a single document which can then be loaded into Word for example. My only real options are to use either rich text format or HTML.
I just thought that rich text would be neater and easier for the user to manage. My experiments with HTML suggest that once a completed document is loaded into Word, all images are inserted as links rather than physical data. Now whilst this is not a major problem for the user to overcome, it's just a bit messy that's all.

I guess though I may end up using a web gadget for simplicity's sake.

Thanks again.

Posted: Wed Feb 08, 2006 8:43 am
by Dare2
Waking the sleeping dogs, here.

Did you ever manage to get this going (images in editorgadget) without the metafile approach?

I have tried (and failed) to embed images in the editorgadget. Several times, in fact. I even tried embedding an object and sticking an image over it. But the code to keep the image aligned, including scrolling off the visible area and being dragged around, defeated me.

So, hoping you cracked this and have some clues or hints you can share.

Posted: Wed Feb 08, 2006 8:07 pm
by srod
I used Anders 'advanced editor' library to stream images in the end. It works well. Haven't tested it with PB4 though.

Posted: Wed Feb 08, 2006 8:08 pm
by Shannara
hmm, German Shepard is awake ;)

How did you end up streaming text into the gadget with the colors and all?

Posted: Wed Feb 08, 2006 8:45 pm
by srod
Simply use SetGadgetText().

E.g.

Code: Select all

If OpenWindow(0, 100, 200, 400, 400, #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget, "")
CreateGadgetList(WindowID())
ADVEditor(1,0,40,WindowWidth(),WindowHeight()-80,3)

a$="{\rtf1\ansi\ansicpg1252\deff0\deflang2057{\fonttbl{\f0\fswiss\fcharset0 Arial;}}"
a$+"{\*\generator Msftedit 5.41.15.1503;}\viewkind4\uc1\pard\f0\fs20{\pict\wmetafile8\picwgoal691\pichgoal722 "
a$+"010009000003c90200000600fe00000000000400000003010800050000000b0200000000050000"
a$+"000c0233012601040000002e0118001c000000fb029cff00000000000090010000000004400012"
a$+"54696d6573204e657720526f6d616e0000000000000000000000000000000000040000002d0100"
a$+"000400000002010100050000000902000000020d000000320a5700fdff01000400fdfffdff2301"
a$+"2f0120712d00030000001e0007000000fc020000ffffff000000040000002d0101000400000006"
a$+"01010008000000fa02050000000000ffffff00040000002d010200fe00000024037d0090000200"
a$+"89000300810003007a000400740005006d000700660009005f000b0059000e00530011004d0014"
a$+"004700180041001b003c00200036002400310029002c002d00230038001f003d001b0043001800"
a$+"490014004f00110056000e005c000c0063000a006a00080071000600780005007f000400860003"
a$+"008e000300950003009d000400a4000500ac000600b3000800ba000a00c1000c00c8000e00ce00"
a$+"1100d5001400db001800e1001b00e7001f00ed002300f3002c00fd0031000201360007013c000b"
a$+"0141000f01470013014d00160153001a0159001d015f001f01660022016d002401730025017a00"
a$+"2601810027018900280190002801970028019e002701a5002601ac002501b3002401ba002201c0"
a$+"001f01c7001d01cd001a01d3001601d9001301de000f01e4000b01e9000701ee000201f300fd00"
a$+"fc00f3000101ed000401e7000801e1000c01db000f01d5001101ce001401c8001601c1001801ba"
a$+"001a01b3001b01ac001c01a4001c019d001c0195001c018e001c0186001b017f001a0178001801"
a$+"710016016a001401630011015c000f0156000c014f00080149000401430001013d00fc003800f3"
a$+"002d00ee002900e9002400e4002000de001b00d9001800d3001400cd001100c7000e00c0000b00"
a$+"ba000900b3000700ac000500a50004009e000300970003009000020008000000fa020000000000"
a$+"0000000000040000002d0103000400000006010100040000002d01010008000000fa0200000600"
a$+"000000000000040000002d01040007000000fc020100000000000000040000002d010500fe0000"
a$+"0025037d009000020089000300810003007a000400740005006d000700660009005f000b005900"
a$+"0e00530011004d0014004700180041001b003c00200036002400310029002c002d00230038001f"
a$+"003d001b0043001800490014004f00110056000e005c000c0063000a006a000800710006007800"
a$+"05007f000400860003008e000300950003009d000400a4000500ac000600b3000800ba000a00c1"
a$+"000c00c8000e00ce001100d5001400db001800e1001b00e7001f00ed002300f3002c00fd003100"
a$+"0201360007013c000b0141000f01470013014d00160153001a0159001d015f001f01660022016d"
a$+"002401730025017a002601810027018900280190002801970028019e002701a5002601ac002501"
a$+"b3002401ba002201c0001f01c7001d01cd001a01d3001601d9001301de000f01e4000b01e90007"
a$+"01ee000201f300fd00fc00f3000101ed000401e7000801e1000c01db000f01d5001101ce001401"
a$+"c8001601c1001801ba001a01b3001b01ac001c01a4001c019d001c0195001c018e001c0186001b"
a$+"017f001a0178001801710016016a001401630011015c000f0156000c014f000801490004014300"
a$+"01013d00fc003800f3002d00ee002900e9002400e4002000de001b00d9001800d3001400cd0011"
a$+"00c7000e00c0000b00ba000900b3000700ac000500a50004009e00030097000300900002000400"
a$+"00002d010300040000002d01010004000000f0010400040000002701ffff1c000000fb02100007"
a$+"0000000000bc02000000000102022253797374656d000000000000de60e777587aae0200f4b502"
a$+"7078ae025ae78339040000002d010400030000000000"
a$+"}Hi.\par}"
 
SetGadgetText(1,a$)

  Repeat
    EventID = WaitWindowEvent()

    If EventID = #PB_Event_CloseWindow  ; If the user has pressed on the close button
      Quit = 1
    EndIf

  Until Quit = 1
  
EndIf

End
Probably only works with PB 3.94.

Posted: Wed Feb 08, 2006 10:09 pm
by Shannara
Ah, ok i think. Nvm, I'll start a new topic.

Posted: Wed Feb 08, 2006 10:26 pm
by Dare2
okay, thanks srod! :)