CAcUiDialoge and resizing dousnot work like with CDialogEx

CAcUiDialoge and resizing dousnot work like with CDialogEx

majklha
Advocate Advocate
527 Views
6 Replies
Message 1 of 7

CAcUiDialoge and resizing dousnot work like with CDialogEx

majklha
Advocate
Advocate

I have a dialog, developed in Visual Studie Dialog Designer and on it a couple of MFC controls, eg. CButtons, CEdit, etc.

The dialog is resizable and controls was set as dynamic (Dynamic Layout - Moving Type / Sizing type). If I use CDialogEx, the controls move and resize according to dialog. But with CAcUiDialog it doesnot work. 

I need to use CAcUiDialog because of BeginEditorCommand and EndEditorCommand methods.

How to solve it? Thanks,

Michal

0 Likes
528 Views
6 Replies
Replies (6)
Message 2 of 7

daniel_cadext
Advisor
Advisor

you can’t set or append the style for CAcUiDialog as resizable? There’s methods CAdUiDialog::MoveControlX, MoveControlY

 

Also, you can roll your own BeginEditorCommand You can use this as inspiration

https://github.com/CEXT-Dan/PyRx/blob/910ef5046434ffc558145453768fea0e5a0df8a4/PyRxCore/PyEdUserInte...

 

the cool thing about CAcUiDialog is it save the position between sessions, with CDialogEx, you have to roll your own

Python for AutoCAD, Python wrappers for ARX https://github.com/CEXT-Dan/PyRx
0 Likes
Message 3 of 7

daniel_cadext
Advisor
Advisor

Just checking one of mine, it’s resizable

I used CMFCDynamicLayout to control my ok / cancel buttons

it's been a while since i've done MFC Though 

 

IMPLEMENT_DYNAMIC(XlsxSheetViewUI, CAcUiDialog)

...

BOOL XlsxSheetViewUI::OnInitDialog()
{
    auto flag = CAcUiDialog::OnInitDialog();
    CAcModuleResourceOverride resourceOverride;
    AdjustLayout();
    initCtrls();
    ResizeDynamicLayout();
    return flag;
}
...
void XlsxSheetViewUI::AdjustLayout()
{
    CMFCDynamicLayout* dynamicLayout = this->GetDynamicLayout();
    if (dynamicLayout == nullptr)
        return;
    auto moveSettings = CMFCDynamicLayout::MoveHorizontalAndVertical(100, 100);
    auto sizeSettings = CMFCDynamicLayout::SizeNone();

    dynamicLayout->AddItem(GetDlgItem(IDOK)->GetSafeHwnd(), moveSettings, sizeSettings);
    dynamicLayout->AddItem(GetDlgItem(IDCANCEL)->GetSafeHwnd(), moveSettings, sizeSettings);
}

 

resize.png

Python for AutoCAD, Python wrappers for ARX https://github.com/CEXT-Dan/PyRx
0 Likes
Message 4 of 7

majklha
Advocate
Advocate

Yes I understand. Thank you. But in this case I must add each control to my code. With CDialogEx it goes automatically. I am not lazy, I only have a lot of controls in the dialog.

 

0 Likes
Message 5 of 7

majklha
Advocate
Advocate

You sent me this link in previous post, where I asked for this user procedures BeginEditor, EndEditor. I used it, but the result was the same as with my own sollution. In 99% Autocads it works properly, but with Autocad 2025 on one computer it caused dead Autocad. I am not able to discover reason. And it is because I tried to solve it from other side....

But thanks, I try it again. Maybe I erased from your code something important 🙂

Saving the possitions is the easy think. 

0 Likes
Message 6 of 7

daniel_cadext
Advisor
Advisor

The benefit of CAcUiDialog is it saves the position and size in the users profile, and it has BeginEditorCommand

With CDialogEx, you have to roll your own.

 

Both CAcUiDialog and CDialogEx are resizable

 

With regards to BeginEditorCommand, there’s  a few versions floating around. Not sure if I mentioned this, but you can get inspiration by using ILSpy and digging into what the .NET wrappers use. The class is AcMgUserInteraction, theirs is slightly different than mine as they call AFX_MANAGE_STATE(AfxGetAppModuleState());

My routine is used on wxWindow handles

Python for AutoCAD, Python wrappers for ARX https://github.com/CEXT-Dan/PyRx
Message 7 of 7

daniel_cadext
Advisor
Advisor

Looking at AcMgUserInteraction,  AFX_MODULE_STATE is created in beginUserInteraction and reset in endUserInteraction.

I’ve updated my class as well, maybe that will fix your issue 

Python for AutoCAD, Python wrappers for ARX https://github.com/CEXT-Dan/PyRx