Pretty printing library

agraham

Expert
Licensed User
Never one to shirk a challenge I buckled down to it and got a threading workaround sorted. Version 1.4 attached has a new CopyImageToClipboard function!

I presume it paste's the bitmap where the current cursor is on the page?
Yes. If the source image was originally a jpg you may have to fiddle its' dpi setting or resize it to get the result you want. See post #11 onwards in this thread http://www.basic4ppc.com/forum/showthread.php?t=1349
 

Attachments

Last edited:

markbarrett_1

Member
Licensed User
Hi,

Just implemented Landscape, LeftMargin, RightMargin, TopMargin and BottomMargin properties and they work perfectly...

Many thanks.

Cheers.

M
 

markbarrett_1

Member
Licensed User
bitmaps and cursor

Hi,

Now printing images out of the database :sign0060: Very simple and gives great results ;)

What would be very nice is if you can move the cursor to some arbitary location on the printed page, do your paste of the bitmap and then set the cursor to the top of the page where normal text handling can happen with normal print report logic.

Thanks.

Cheers.

M
 

agraham

Expert
Licensed User
What would be very nice is if you can move the cursor to some arbitary location on the printed page, do your paste of the bitmap and then set the cursor to the top of the page where normal text handling can happen with normal print report logic.
Sorry, that's not possible. The page layout is done at print time according to the margins and page size specified. Until then the contents of the RichTextBoxDesktop are just a linear stream of text and formatting commands so there is no way to predict where information will be printed on the page and hence no way to position the cursor at an arbitrary page location.
 

BjornF

Active Member
Licensed User
Right clicking the text box

Dear Andrew,

When I right-click in a normal textbox (in a Basic4ppc - program) I get the context specific menu (Cut, copy, paste etc). But that does not happen when I am using a rich text box (or have I missed something?). Is this something which could be implemented?

all the best / Björn
 

agraham

Expert
Licensed User
Your are not missing anything. You can add one using the Formlib library
B4X:
Sub App_Start
  rtb.New1("Form1",10,10,210,150)
  form1.Show
  flib1.New1("Form1",B4PObject(1))
  cm1.New1
  cm1.AddItem("Yes")
  cm1.AddItem("No")
  cm1.AddItem("-") 'Adds a separator
  cm1.AddItem("Maybe")
  flib1.AddContextMenu(rtb.ControlRef,cm1.Value)
End Sub

Sub cm1_Click
  Select cm1.SelectedText
    Case "Yes"
      Msgbox(cm1.SelectedText)
    Case "No"
      Msgbox(cm1.SelectedText)
    Case "Maybe"
      Msgbox(cm1.SelectedText)
  End Select
End Sub
However if you wanted Cut, Copy Paste this can't be done at moment as the required properties are not implemented. I'll look at it. The keyboard shortcuts Ctl-C, Ctl-V Ctl-X do work if you haven't tried them.

EDIT :- Note that Paste is already available as a method.
 
Last edited:

BjornF

Active Member
Licensed User
Thank you the explanation Andrew.

That means that it should be relatively simple to program it using the hardware.dll :)

all the best / Björn
 

agraham

Expert
Licensed User
That means that it should be relatively simple to program it using the hardware.dll :)
If you mean HardwareDesktop, as RichTextDesktop is desktop only, and you are expecting to use GetClipboard data then I am afraid you are going to be disappointed as it doesn't work! This is probably because of a threading issue in earlier versions of B4ppc that made it unable to access some COM controls - and the Clipboard in .NET is accessed via a COM control. I used a workaround in RichTextDesktop to access the Clipboard but that may no longer be necessary as Erel changed the threading model which was what let me implement a WebBrowser for the desktop as WebBrowser is also a COM control.

I'm looking at putting Cut and Copy methods in RichTextDesktop and may also provide access to the Clipboard once I've thought some more about it (and tried it out) or I might make the Clipboard a tiny stand-alone library that can be merged with the exe.

Maybe you mean to simulate key presses with the hardware dll but I am afraid that doesn't work on the desktop either :(
 
Last edited:

klaus

Expert
Licensed User
Hi Erel and Andrew,
Is it possible with the RichTextBox library to have one code for both, desktop and device ?

In a program I added the printer functions, it works fine thanks to Andrew's example. But when I compile for the device I get an error that it is missing a reference. If I add the RichTextBox library to the device I get another error in the line with rtb.New1.

I read that Woinowski had added the destop code with Tools/Components.
http://www.basic4ppc.com/forum/bug-reports/1586-when-compiling-device-desktop-code-used.html#post8649
There were also a problem in compilng which was soved in version 6.05.

A dummy library for the device would be handy, or am I missing something.

Thank you in advance and Best Regards.
 

agraham

Expert
Licensed User
A dummy library for the device would be handy, or am I missing something.
You are probably missing the fact that the device does not implement a RichTextBox control and also does not have any awareness of printing built in to the OS. Therefore there cannot be a RichTextBoxDevice library as the fundamentals to support it are missing :(

For "decorative" text puposes you could use my WebBrowser library and write HTML to its DocumentText property. I have been looking at other solutions for "RichText" on a device but have found no easy solution so far.

Although I can't see a need for it (unlike desktop dummies) I could easily provide a dummy non-functional library for the device if this would help in some way.
 

klaus

Expert
Licensed User
Hi Andrew,

I knew that the device doesn't support the RichTextBox Control. The printing functions are only for the desktop version.

For me, a non-functional library for the device would be interesting in that that there is only one source code file for both device and desktop, with no error during compilation.

Thank you for you help.
 
Top