The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 LabTalk Forum
 Simulating automatic column width feature
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

AKazak

Russia
1228 Posts

Posted - 05/04/2020 :  2:39:50 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
OriginPro 2019b (64-bit) 9.6.5.169
Windows 7 Pro x64 SP1

Greetings!

I like using a smart automatic column width feature activated by double mouse click by the right border of the selected column(s).


https://my.originlab.com/forum/topic.asp?TOPIC_ID=4690 provides a workaround using OC:
col.SetWidth(-1);
(https://www.originlab.com/doc/OriginC/ref/Column-SetWidth)
However the discussion concluded that col.SetWidth is not the same as double-click command.

https://my.originlab.com/forum/topic.asp?TOPIC_ID=2213 provides another workaround but based on Column Label Rows.

Is there a way to simulate double-click command properly?

Edited by - AKazak on 05/04/2020 2:43:38 PM

cpyang

USA
1406 Posts

Posted - 05/04/2020 :  3:39:30 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
OriginC allows detailed controls on how you resize the columns, but there was no LabTalk to simulate that automatic width in 2019b. This was added in 2020b as all the Mini Toolbar buttons are executing some labtalk commands, and there is such button introduced in Origin2020b.



If needed, I can provide some Origin C sample code so you can do this in 2019b.

CP
Go to Top of Page

AKazak

Russia
1228 Posts

Posted - 05/04/2020 :  4:10:56 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:
Originally posted by cpyang

OriginC allows detailed controls on how you resize the columns, but there was no LabTalk to simulate that automatic width in 2019b. This was added in 2020b as all the Mini Toolbar buttons are executing some labtalk commands, and there is such button introduced in Origin2020b.



If needed, I can provide some Origin C sample code so you can do this in 2019b.

CP




OK, I see.
Please provide the OC snippet.

Thank you.
Go to Top of Page

cpyang

USA
1406 Posts

Posted - 05/04/2020 :  4:42:51 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
The following the the simplest code, and there can be so many different things you can do with it.

void autos()
{
	DWORD dwCntrl = AS_INVALIDATE;//|AS_NOHEIGHT
	Worksheet wks = Project.ActiveLayer();
	OGRIDLIMITS limits;
	init_autosize_limits(&limits, -1, -1, -1, -1);
	wks.AutoSize(dwCntrl, 0, &limits);
}


The prototype for init function is

init_autosize_limits(OGRIDLIMITS *pLimits, double dminCol = 1.5, double dmaxCol = 25, double dminRow = -1, double dmaxRow = -1);


so using -1 is to indicate not having any limits.

CP
Go to Top of Page

AKazak

Russia
1228 Posts

Posted - 05/05/2020 :  04:52:22 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:
Originally posted by cpyang

The following the the simplest code, and there can be so many different things you can do with it.

void autos()
{
	DWORD dwCntrl = AS_INVALIDATE;//|AS_NOHEIGHT
	Worksheet wks = Project.ActiveLayer();
	OGRIDLIMITS limits;
	init_autosize_limits(&limits, -1, -1, -1, -1);
	wks.AutoSize(dwCntrl, 0, &limits);
}


The prototype for init function is

init_autosize_limits(OGRIDLIMITS *pLimits, double dminCol = 1.5, double dmaxCol = 25, double dminRow = -1, double dmaxRow = -1);


so using -1 is to indicate not having any limits.

CP




Great!
Please clarify the meaning of AUTOSIZE setting.
https://www.originlab.com/doc/OriginC/ref/AUTOSIZE doesn't say too much.
What is the difference between AS_INVALIDATE and AS_NOHEIGHT?
Go to Top of Page

Chris D

428 Posts

Posted - 05/05/2020 :  08:10:22 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

The AS_NOHEIGHT flag tells Origin to not autosize the height of cells/rows. The AS_INVALIDATE flag tells Origin that it needs to redraw the columns at their new width. The | operator combines two or more flags.

So if you specified AS_NOHEIGHT | AS_INVALIDATE, you are telling Origin to both ignore resizing height and to force redraw.

I hope this helps.

Thanks,
Chris Drozdowski
Originlab Technical Support
Go to Top of Page

AKazak

Russia
1228 Posts

Posted - 05/05/2020 :  08:56:13 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:
Originally posted by Chris D

Hi,

The AS_NOHEIGHT flag tells Origin to not autosize the height of cells/rows. The AS_INVALIDATE flag tells Origin that it needs to redraw the columns at their new width. The | operator combines two or more flags.

So if you specified AS_NOHEIGHT | AS_INVALIDATE, you are telling Origin to both ignore resizing height and to force redraw.

I hope this helps.

Thanks,
Chris Drozdowski
Originlab Technical Support




OK.
Does AS_NOWIDTH flag tell Origin to not autosize the width of cells/rows?
What is the meaning of AS_SELECTION?
Go to Top of Page

AKazak

Russia
1228 Posts

Posted - 05/07/2020 :  12:00:23 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:
Originally posted by AKazak
OK.
Does AS_NOWIDTH flag tell Origin to not autosize the width of cells/rows?
What is the meaning of AS_SELECTION?



Any ideas?
Go to Top of Page

cpyang

USA
1406 Posts

Posted - 05/07/2020 :  12:29:03 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Yes, AS_NOWIDTH is to skip column width resizing.

AS_SELECTION should be to resize selected columns I supposed, I have not tried, must be -1 for column begin end to be effective.

CP
Go to Top of Page

AKazak

Russia
1228 Posts

Posted - 05/08/2020 :  02:33:11 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:
Originally posted by cpyang

Yes, AS_NOWIDTH is to skip column width resizing.

AS_SELECTION should be to resize selected columns I supposed, I have not tried, must be -1 for column begin end to be effective.

CP




OK.
Please add this to the documentation.

Thank you.
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000