ObjectARX
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Palette change its size on startup

5 REPLIES 5
Reply
Message 1 of 6
danipon71
621 Views, 5 Replies

Palette change its size on startup

I've made a custom palette in AutoCAD 2017.

 

After service pack 1.1 of AutoCAD 2017 the width of the docked palette increases on every startup.

 

Thanks in advance

 

 

 

 

 

5 REPLIES 5
Message 2 of 6

Having tested your problem description, I was not able to recreate the issue. 

Can you please share reproducible code with a detailed description of the problem for further testing?

Message 3 of 6

 

Hi,

after doing some tests it seems the issue occurs only with windows' "text, apps, and other items size" set to 125% (or more).

I'm working with CAdUiPaletteSet and i use CAdUiPaletteSet::Save and CAdUiPaletteSet::Load to manage its size.

I've tried the same xml with and without service pack 1.1 (with all hotfix) and the problem seems to be in the Load method since the values in the xml file are fine but with AutoCAD(up-to-date) the palette is larger.

At the beginning I thought the problem was generated by the Save method because the values tend to grow on every startup, but if I switch back to 100% the values saved are correct.

Sorry if my explanation is a bit "messy".

 

Thank for the support.

 

Some Code: (if necessary, i can clean and attach the project)

 

class CPaletteSet : public CAdUiPaletteSet
{
     ...
}

void CPaletteSet::LoadPaletteSet()
{
    MSXML::IXMLDOMDocumentPtr pDoc = NULL;
    HRESULT hr;
    hr = pDoc.CreateInstance(MSXML::CLSID_DOMDocument);

    // Get the file where the palette set's properties are saved
    const TCHAR *pRoam;
    TCHAR paletteBuffer[MAX_PATH];
    BOOL bResult;
    bResult = acdbHostApplicationServices()->getRoamableRootFolder(pRoam);
    _tcscpy(paletteBuffer, pRoam);
    _tcscat(paletteBuffer, PALETTESET_FILENAME);
    CComVariant var(paletteBuffer);

    VARIANT_BOOL bReturn = pDoc->load(var);
    if (bReturn == VARIANT_TRUE) // success!
    {
        MSXML::IXMLDOMNodePtr pNode;
        GetChildNode(pDoc->documentElement, _T("PS"), &pNode);

        // Call the base class version of Load.
        // This would re-establish the properties of
        // the palette set
        Load(pNode);
    }
}

BOOL GetChildNode(MSXML::IXMLDOMNode* pNode,
    LPCTSTR pszNodeName,
    MSXML::IXMLDOMNode** ppChild)
{
    ASSERT(ppChild != NULL);
    if (ppChild == NULL)
        return FALSE;

    *ppChild = NULL;

    ASSERT(pNode != NULL && pszNodeName != NULL);
    if (pNode == NULL || pszNodeName == NULL)
        return FALSE;

    USES_CONVERSION;

    CComBSTR bstrName;
    pNode->get_nodeName(&bstrName);

    CString sName = OLE2A(bstrName);
    if (sName.CompareNoCase(pszNodeName) == 0) {
        *ppChild = pNode;
        // AddRef before returning
        if (*ppChild != NULL)
            (*ppChild)->AddRef();
        return TRUE;
    }
    // Get the named child element from the list of children
    MSXML::IXMLDOMNodeListPtr pChildren;
    pNode->get_childNodes(&pChildren);
    ASSERT(pChildren != NULL);
    if (pChildren == NULL) {
        ASSERT(FALSE);
        return FALSE;
    }

    int nCount = pChildren->Getlength();
    if (nCount < 1) {
        // No children
        return FALSE;
    }

    for (long i = 0; i<nCount; i++) {
        MSXML::IXMLDOMNodePtr pNode;
        pChildren->get_item(i, &pNode);
        ASSERT(pNode != NULL);

        CComBSTR bstrName;
        pNode->get_nodeName(&bstrName);

        CString sName = OLE2A(bstrName);
        if (sName.CompareNoCase(pszNodeName) == 0) {
            *ppChild = pNode.GetInterfacePtr();
            // AddRef before returning
            if (*ppChild != NULL)
                (*ppChild)->AddRef();
            return TRUE;
        }
    }

    // Named child not found
    return FALSE;
}

void CreatePalette()
{
    CString szTitle = _T("Title");
    // Create palette set
    pPaletteSet = new CPaletteSet;
    CRect rect(0, 0, 250, 500);

    pPaletteSet->Create(szTitle,
        WS_OVERLAPPED | WS_DLGFRAME, 
        rect, 
        acedGetAcadFrame(), 
        PSS_SNAP |
        PSS_PROPERTIES_MENU | 
        PSS_AUTO_ROLLUP |
        PSS_CLOSE_BUTTON
        );

    pPaletteSet->AppendPalette(_T("Palette"));


    // Show the palette set
    pPaletteSet->EnableDocking(CBRS_ALIGN_LEFT | RS_ALIGN_RIGHT);
    pPaletteSet->RestoreControlBar();

    // Load PaletteSet pesistent data
    pPaletteSet->LoadPaletteSet();

    CMDIFrameWnd* pAcadFrame = acedGetAcadFrame();
    pAcadFrame->ShowControlBar(pPaletteSet, TRUE, FALSE);

    if (pPaletteSet->GetOpacity() !=100)
        pPaletteSet->SetOpacity(100);

}

 

Message 4 of 6

Attached is an old project migrated and compatible with AutoCAD 2017. On running the 'PALETTESHOW' command on every startup no changes to custom palette were seen. 

Please let me know if I have missed something to recreate the issue.

Code snippets will not help us investigate. Can you please share screencast showing the behaviour and sample project to reproduce the behaviour at our end?

 

 

 

Message 5 of 6

Thanks for the reply and sorry for the delay.

 

I’ve modified the attached project to resemble ours.

I start with the paletteset docked and I use RestoreControlBar and SavePaletteSet/LoadPaletteSet to manage location and size.

On startup I don’t make it float by default

I’ve put 2 versions of SavePaletteSet, one will not restore the palette(the standard one) and the other will make it larger on every start up.

My mistake was not realinzing that the second one was already a workaround done for AutoCAD 2013 (to localize it use : "WORKAROUND").

 

Image 1 : before closing AutoCAD

Image 2 : no workaround (using SavePaletteSet/LoadPaletteSet from the sample project), the paletteset is there but it's collapsed

Image 3 : with workaround, it's a little bit larger

 

The workaround stopped working on windows 7 and 10 with AutoCAD 2017 1.1. (font, icon, ecc... 125% or more)

At the moment i skip the SavePaletteSet/LoadPaletteSet Event (like the sample prj) with dpi > 96.

(It solves the issue of the paletteset growing bigger than the screen but then it shows with deafult size everytime)

 

The code is clearly outdated so probably there is a better way to load the user's settings.

 

Thanks again for the support and sorry if my statements were misleading.

(if needed i'll do the screencast but i simply close AutoCAD with the paletteset docked, restart it and then reopen the paletteset using the command 'PALETTESHOW')

 

test.jpg

Message 6 of 6

Thanks for your patience.


At the moment i skip the SavePaletteSet/LoadPaletteSet Event (like the sample prj) with dpi > 96.

The code is clearly outdated so probably there is a better way to load the user's settings. 

Sorry, having researched I couldn't figure a way in your code to retain the size of the palette if DPI settings is a cause for the change in size.
However, there is a way to handle the DPI scaling in .NET application forms, please can you check the following link :
http://through-the-interface.typepad.com/through_the_interface/2011/03/handling-dpi-scaling-in-your-...

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost