Background Color of Bookmarks Pane  SOLVED

PDF-XChange Editor SDK for Developers

Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Sean - Tracker, Paul - Tracker Supp, Chris - Tracker Supp, Tracker Supp-Stefan, Ivan - Tracker Software

Forum rules
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.

When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
Post Reply
RMan
User
Posts: 172
Joined: Tue Jul 02, 2013 10:06 pm

Background Color of Bookmarks Pane

Post by RMan » Mon Feb 13, 2017 9:43 pm

Is there any way through the SDK or the Resources.dat to control the background color of the Bookmarks pane separate from the main panes color? Since bookmarks can have a color property and you display that if you try to use a dark colored theme the black bookmarks are unreadable with a dark background.

As a feature request you might want to think about always keeping the bookmarks pane white because of this or having a white background behind the actual bookmarks text so the various colors always show up.

User avatar
Sasha - Tracker Dev Team
User
Posts: 4202
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Background Color of Bookmarks Pane

Post by Sasha - Tracker Dev Team » Tue Feb 14, 2017 10:10 am

Hello RMan,

Sadly, you cannot change the background of the Bookmarks View itself. What you can do is manually change the entire theme background or the color of the bookmarks so that they would match the background of the current theme.

Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

RMan
User
Posts: 172
Joined: Tue Jul 02, 2013 10:06 pm

Re: Background Color of Bookmarks Pane

Post by RMan » Tue Feb 14, 2017 12:49 pm

Thanks.

Can we please get this an extremely high priority to fix and release a patch. The old viewer worked the way I am suggesting in that the Bookmarks Pane was always white for this reason and without it the rest of the UI settings are honestly pretty much useless since bookmarks are one of the most used features by users for both editing and viewing.

User avatar
Sasha - Tracker Dev Team
User
Posts: 4202
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Background Color of Bookmarks Pane

Post by Sasha - Tracker Dev Team » Tue Feb 14, 2017 1:02 pm

Hello RMan,

Well from what I previously said - this is not a bug and this won't be fixed. I just suggested two possible ways how you can code this in your side.

Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

User avatar
Sasha - Tracker Dev Team
User
Posts: 4202
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Background Color of Bookmarks Pane  SOLVED

Post by Sasha - Tracker Dev Team » Fri Feb 17, 2017 4:09 pm

Hello RMan,

We've been experimenting and came up with this code:

Code: Select all

PDFXEdit.IUIX_Obj obj = doc.ActiveView.BookmarksView.Obj;

    Int64 st = (Int64)(PDFXEdit.UIX_ObjStyleFlags.UIX_ObjStyle_NoBackground | PDFXEdit.UIX_ObjStyleFlags.UIX_ObjStyle_NoBorder | PDFXEdit.UIX_ObjStyleFlags.UIX_ObjStyle_NoInnerShadow);
    obj.SetStyle(st, st);

    MyEventHandler eh = new MyEventHandler(obj);
    obj.Redraw();

/////

public partial class MyEventHandler :
    PDFXEdit.IUIX_ObjImpl,
    IDisposable
{
    public MyEventHandler(PDFXEdit.IUIX_Obj obj)
    {
        if (obj != null)
           obj.PushImpl(this);
    }
    ~MyEventHandler()
    {
        Dispose();
    }

    public void Dispose()
    {
        if (fDisposed_)
            return;
        fDisposed_ = true;
        if (Obj_ != null)
        {
            Obj_.PopImpl(this);
            System.Runtime.InteropServices.Marshal.ReleaseComObject(Obj_);
            Obj_ = null;
        }
    }

    private PDFXEdit.IUIX_Obj Obj_ = null;
    private bool fDisposed_ = false;

    // IUIX_ObjImpl
    public PDFXEdit.IUIX_Obj Obj
    {
        get { return this.Obj_; }
    }

    public void OnEvent(PDFXEdit.IUIX_Obj pSender, PDFXEdit.IUIX_Event pEvent)
    {
        pEvent.Handled = false;

        if (pEvent.Code == (int)PDFXEdit.UIX_EventCodes.e_First)
        {
            Obj_ = pSender;
        }
        else if (pEvent.Code == (int)PDFXEdit.UIX_EventCodes.e_Last)
        {
            Dispose();
        }
        else if (pEvent.Code == (int)PDFXEdit.UIX_EventCodes.e_Render)
        {
            PDFXEdit.IUIX_RenderContext pRC = (PDFXEdit.IUIX_RenderContext)System.Runtime.InteropServices.Marshal.GetObjectForIUnknown((IntPtr)pEvent.Param1);
            pRC.FillUpdateRegion((int)0xСССССС, false);
        }
    }

    public void OnPostEvent(PDFXEdit.IUIX_Obj pSender, PDFXEdit.IUIX_Event pEvent)
    {

    }

    public void OnPreEvent(PDFXEdit.IUIX_Obj pSender, PDFXEdit.IUIX_Event pEvent)
    {

    }
}
It's not very pretty but it does what you need.

Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

RMan
User
Posts: 172
Joined: Tue Jul 02, 2013 10:06 pm

Re: Background Color of Bookmarks Pane

Post by RMan » Fri Feb 17, 2017 5:53 pm

Thanks!!! I will check it out this weekend.

User avatar
Sasha - Tracker Dev Team
User
Posts: 4202
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Background Color of Bookmarks Pane

Post by Sasha - Tracker Dev Team » Fri Feb 17, 2017 8:29 pm

:)
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

RMan
User
Posts: 172
Joined: Tue Jul 02, 2013 10:06 pm

Re: Background Color of Bookmarks Pane

Post by RMan » Mon Jul 10, 2017 1:26 pm

Unfortunately I was never able to get this to work in VB6 and I'm hoping you can really press the developers to fix this and either keep the bookmarks pane white or check the contrast value between black text and the background color and if it's too low then force it to white. I'm guessing 90% of the bookmarks in PDF are black anyways so any dark theme the bookmarks pane in the standard editor is unusable.

It's especially evident for users using the Windows High Contrast Themes for visual disability problems. Here's a sample of how the bookmarks and interface look in that case.

Image

User avatar
Sasha - Tracker Dev Team
User
Posts: 4202
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Background Color of Bookmarks Pane

Post by Sasha - Tracker Dev Team » Tue Jul 11, 2017 9:46 am

Hello RMan,

Fixed this, and the fix will be available from the next major build (323).
Capture10.PNG
Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

RMan
User
Posts: 172
Joined: Tue Jul 02, 2013 10:06 pm

Re: Background Color of Bookmarks Pane

Post by RMan » Wed Sep 20, 2017 12:16 am

Unfortunately it doesn't look like it works in the August build. You can still barely read the bookmarks. I still don't understand why the Bookmarks pane just isn't set to a white background so the bookmarks colors always display in the color that their properties are set for.
bookmarks.jpg
bookmarks.jpg (41.18 KiB) Viewed 1800 times

User avatar
Sasha - Tracker Dev Team
User
Posts: 4202
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Background Color of Bookmarks Pane

Post by Sasha - Tracker Dev Team » Wed Sep 20, 2017 7:58 am

Hello RMan,

Please read carefully:
Fixed this, and the fix will be available from the next major build (323).
Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

RMan
User
Posts: 172
Joined: Tue Jul 02, 2013 10:06 pm

Re: Background Color of Bookmarks Pane

Post by RMan » Wed Sep 20, 2017 11:57 am

Sorry about that. Didn't think to check the version number. Thanks again.

User avatar
Sasha - Tracker Dev Team
User
Posts: 4202
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Background Color of Bookmarks Pane

Post by Sasha - Tracker Dev Team » Wed Sep 20, 2017 11:57 am

:)
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

RMan
User
Posts: 172
Joined: Tue Jul 02, 2013 10:06 pm

Re: Background Color of Bookmarks Pane

Post by RMan » Wed Nov 14, 2018 5:03 pm

By chance has a theme setting or programatic setting been added yet for this? Hooking in doesn't work in the language we are using and in the latest version the bookmarks are still unreadable for dark window colors.

1.) If the window background color is pure black then it will swap the black bookmark text color to white but many other colors would still be hard to read.
2.) Also with pure black the highlighted bookmark text color is not changed so it's hard to read.
3.) If it's a dark gray or other dark color background than any dark color text bookmark is hard to read and even pure black text is not swapped to white in that case.

Since bookmarks can have color and since most PDF viewers have a white or light colored background for the Bookmarks Pane the vast majority of bookmarks if they are going to have color set to them are likely to be a dark color which doesn't work with a dark theme in the Editor.

Here's how I see it with various colors.
pdf-xchange-bookmarks.JPG

User avatar
Sasha - Tracker Dev Team
User
Posts: 4202
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Background Color of Bookmarks Pane

Post by Sasha - Tracker Dev Team » Thu Nov 15, 2018 8:12 am

Hello RMan,

Just had a chat with one of our lead devs - he said that we will try to address this in the upcoming build.

Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

RMan
User
Posts: 172
Joined: Tue Jul 02, 2013 10:06 pm

Re: Background Color of Bookmarks Pane

Post by RMan » Fri Nov 16, 2018 3:00 am

Thanks. I honestly feel stupid for not thinking of this before but I found away around the programming call that was not supported in VB6 for this. So I finally have it working based on the sample code you had posted before!!!

The declaration for SetStyle has unsupported types defined for the parameters.
Sub SetStyle(nStyle As <Unsupported variant type>, [nStyleMask As <Unsupported variant type>])

This is what we need to do but doesn't work because of declarations
Call obj.SetStyle(st, st)

So instead I finally thought to try and declare it as a generic object and pass it late bound for it to compile and work
Dim oObject As Object
Set oObject = obj
Call oObject.SetStyle(st, st)

And it finally works.

The other main key was moving the PushImpl out of the callback routine and into the main form routine.
Call obj.PushImpl(eh)

RMan
User
Posts: 172
Joined: Tue Jul 02, 2013 10:06 pm

Re: Background Color of Bookmarks Pane

Post by RMan » Fri Nov 16, 2018 3:05 am

Here's the VB6 Code I finally got to work.

In a class module I called it BPaneCallback.bas

Code: Select all

Option Explicit


Implements PDFXEditCtl.IUIX_ObjImpl

Private Obj_ As PDFXEditCtl.IUIX_Obj

Private Const p_lColor = 16777215 '&HFFFFFF rgb(255,255,255) or vbWhite'

Private Declare Sub CopyMemoryBPPane Lib "Kernel32" Alias "RtlMoveMemory" (dest As Any, Source As Any, ByVal bytes As Long)

Property Get IUIX_ObjImpl_Obj() As IUIX_Obj
    On Error Resume Next
    Set IUIX_ObjImpl_Obj = Obj_
End Property


Public Sub IUIX_ObjImpl_OnPreEvent(ByVal pSender As PDFXEditCtl.IUIX_Obj, ByVal pEvent As PDFXEditCtl.IUIX_Event)
    'Nothing to do'
End Sub


Public Sub IUIX_ObjImpl_OnPostEvent(ByVal pSender As PDFXEditCtl.IUIX_Obj, ByVal pEvent As PDFXEditCtl.IUIX_Event)
    'Nothing to do'
End Sub


Public Sub IUIX_ObjImpl_OnEvent(ByVal pSender As PDFXEditCtl.IUIX_Obj, ByVal pEvent As PDFXEditCtl.IUIX_Event)
    On Error Resume Next
    pEvent.Handled = False
    If (pEvent.Code = PDFXEditCtl.UIX_EventCodes.e_First) Then
        Set Obj_ = pSender
    ElseIf (pEvent.Code = PDFXEditCtl.UIX_EventCodes.e_Last) Then
        Set Obj_ = Nothing
    ElseIf (pEvent.Code = PDFXEditCtl.UIX_EventCodes.e_Render) Then
        Dim pRC As PDFXEditCtl.IUIX_RenderContext
        Dim lParam As Long
        lParam = pEvent.Param1
        Set pRC = ObjFromPtr(lParam)
        If Not pRC Is Nothing Then
            Call pRC.FillUpdateRegion(ByVal p_lColor, False)
        End If
    End If
End Sub


Private Function ObjFromPtr(ByVal pObj As Long) As Object
On Error Resume Next
    Dim obj As Object
    ' force the value of the pointer into the temporary object variable'
    CopyMemoryBPPane obj, pObj, 4
    ' assign to the result (this increments the ref counter)'
    Set ObjFromPtr = obj
    ' manually destroy the temporary object variable'
    ' (if you omit this step you will get a GPF!)'
    CopyMemoryBPPane obj, 0&, 4
End Function

Public Function Init(ByRef oObj As PDFXEditCtl.IUIX_Obj)
    On Error Resume Next
    Set Obj_ = oObj
    'Call Obj.PushImpl(this) Crahses - Had to move to main form after Init call'
End Function

Private Sub Class_Initialize()
    On Error Resume Next
End Sub

Private Sub Class_Terminate()
    On Error Resume Next
    If Not Obj_ Is Nothing Then
        Set Obj_ = Nothing
    End If
End Sub
Then in the main form you probably want to add this into the OnEvents since I think there might be a bookmarks pane for each document.

Code: Select all

Dim obj As PDFXEditCtl.IUIX_Obj
    Dim doc As IPXV_Document
    Set doc = AxPXV_Control1.doc
    If Not doc Is Nothing Then
        Set obj = doc.ActiveView.BookmarksView.obj

        Dim st As Long
        Dim lRet As Long

        st = PDFXEditCtl.UIX_ObjStyleFlags.UIX_ObjStyle_NoBackground Or PDFXEditCtl.UIX_ObjStyleFlags.UIX_ObjStyle_NoBorder Or PDFXEditCtl.UIX_ObjStyleFlags.UIX_ObjStyle_NoInnerShadow
        'This is what we need to do but does not work because of declarations Call obj.SetStyle(st, st)'
        'Sub SetStyle(nStyle As <Unsupported variant type>, [nStyleMask As <Unsupported variant type>])'
        'So instead we wil define a generic object and pass it late bound for it to compile and work'
        Dim oObject As Object
        Set oObject = obj
        Call oObject.SetStyle(st, st)
        Dim eh As BPaneCallback
        Set eh = New BPaneCallback
        eh.Init obj
        'Moved this call from the class to here'
        Call obj.PushImpl(eh)
        obj.Redraw
    End If
    

RMan
User
Posts: 172
Joined: Tue Jul 02, 2013 10:06 pm

Re: Background Color of Bookmarks Pane

Post by RMan » Fri Nov 16, 2018 4:33 am

So the final piece is how do we best use the events the get the doc object for a file no matter if it's opened, drag and dropped, imported, etc?

Best thing I could figure out was to cache a value when the e_document_initialized and then when the e_document_activated is fired hook the callback for the bookmarks pane and set my boolean value to false so it doesn't fire it again when switching between documents. But I'm not sure if there could be a case where the pdf is opened but not made active where it wouldn't catch it. It seams like there should be an e_document_opened event that returns the doc object as one of the parameters or something but I wasn't seeing it.

Code: Select all

Case e_document_initialized
        p_bDocumentInitialized = True
Case e_document_activated
        If p_bDocumentInitialized = True Then
               PDFEditor_BookmarkPaneSetBackground PDFEditor.doc
        End If
        p_bDocumentInitialized = False

User avatar
Sasha - Tracker Dev Team
User
Posts: 4202
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Background Color of Bookmarks Pane

Post by Sasha - Tracker Dev Team » Mon Nov 19, 2018 1:51 pm

Hello RMan,

Alternatively you can listen to the e.operExecuted event and see whether it a https://sdkhelp.tracker-software.com/vi ... op_openDoc operation. Note, that if the Bookmarks View has not been activated before, it can be null. If it is null, then you will also have to make a custom command handler as listener for the cmd.view.bookmarks command and after it was executed check the Bookmarks View again. https://gist.github.com/Polaringu/16bb2 ... 7cbe36f4e6

Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

RMan
User
Posts: 172
Joined: Tue Jul 02, 2013 10:06 pm

Re: Background Color of Bookmarks Pane

Post by RMan » Tue Nov 20, 2018 12:09 am

Thanks but I'm not sure if that is going to catch all of the cases. Is there a case where a file might be read in by memory or by another plug in that might not fire one of the ToDoc or DocOpen operations?

At the very least I see these operations at the very least that all fire instead of the op.openDoc it looks like when files are opened/created from various ways.
op.newBlankDoc
op.combineDocs
op.textToDoc
op.rtfToDoc
op.imagesToDoc

For those of you following this you need to check the pFrom value in your OnEvent. Something like this in VB.

Private Sub AxPXV_Control1_OnEvent(ByVal nEventID As Long, ByVal pEvent As PDFXEditCtl.IEvent, ByVal pFrom As 0)
Select Case nEventID
Case pdfMainCtl.Inst.Str2ID("e.operExecuted")
Dim oOperExecuted As PDFXEditCtl.IOperation
Set oOperExecuted = pFrom
Dim lOperExecutedID As Long
lOperExecutedID = oOperExecuted.id
If lOperExecutedID = pdfMainCtl.Inst.Str2ID("op.openDoc") then
'Do your bookmarks routine here
End if
End Select
End Sub

User avatar
Sasha - Tracker Dev Team
User
Posts: 4202
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Background Color of Bookmarks Pane

Post by Sasha - Tracker Dev Team » Tue Nov 20, 2018 7:49 am

Hello RMan,

Just checked with that dev - if you try to access the BookmarksView it won't be null - it will be created if not before. So basically, you will have to listen to all of those events that you mentioned and do your stuff with the Bookmarks View.

Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

Post Reply