How would I make an area grey out if a box is checked?

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
User avatar
Phil Pendlebury
Automation Wizard
Posts: 538
Joined: Tue Jan 16, 2007 9:00 am
Contact:

How would I make an area grey out if a box is checked?

Post by Phil Pendlebury » Tue Jan 16, 2007 9:50 pm

Hi all, I am new here so please be gentle. Here is my dialog:

Code: Select all

Dialog>Dialog1
   Caption=Export Settings
   Width=340
   Height=388
   Top=CENTER
   Left=CENTER
   Max=0
   Min=0
   Close=0
   Resize=0
   Edit=msEdit1,16,48,33,10
   Edit=msEdit2,16,104,145,yourfile
   CheckBox=msCheckBox1,Get track names from tracknames.txt,16,168,225,False
   Label=Number Of Tracks To Export (enter only numbers):,56,48,true
   RadioGroup=msRadioGroup1,Set Locators To,8,232,113,113,All Project%CRLF%Parts on Tracks%CRLF%Manually Set,0
   Label=Default File Name,168,104,true
   Button=QUIT,200,320,57,25,4
   Button=GO!,264,320,57,25,5
   Label=Multi Track Export by Phil Pendlebury,16,16,true
   Label=Ignore if you will get track names,168,136,true
   Label=Will be appended with _1 _2 etc.,168,120,true
   Label=from filename.txt text file,168,152,true
   Label=tracknames.txt must be in same folder as exe file,16,184,true
   Label=TRACK NAMING:,16,88,true
   Label=LOCATOR SELECTION:,16,216,true
EndDialog>Dialog1

Show>Dialog1

Label>ActionLoop
GetDialogAction>Dialog1,result
Let>audiotracks=%Dialog1.msEdit1%
Let>filename=%Dialog1.msEdit2%
Let>allorused=%Dialog1.msRadioGroup1%
Let>textfile=%Dialog1.msCheckBox1%
If>result=5,Begin
If>result=4,End
Goto>ActionLoop
As you can see, there is an input field:
Edit=msEdit2,16,104,145,yourfile

This becomes irrelevant if the box is checked:
CheckBox=msCheckBox1,Get track names from tracknames.txt,16,168,225,False

As you can see I have had to waste a lot of dialog space advising people to ignore the text entry if the box is checked.

So... What I really would love is a way to automatically make the Edit box text "GREY OUT" if the check box is checked.

Can anyone offer any help here to a total n00b?

Thanks in advance.

:)
Phil Pendlebury - Linktree

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Tue Jan 16, 2007 10:08 pm

Since there is no native setting to do this, this requires a little piece of Windows 32 API work. Try this:

Code: Select all

Dialog>Dialog1
   Caption=Export Settings
   Width=340
   Height=388
   Top=CENTER
   Left=CENTER
   Max=0
   Min=0
   Close=0
   Resize=0
   Edit=msEdit1,16,48,33,10
   Edit=msEdit2,16,104,145,yourfile
   CheckBox=msCheckBox1,Get track names from tracknames.txt,16,168,225,False
   Label=Number Of Tracks To Export (enter only numbers):,56,48,true
   RadioGroup=msRadioGroup1,Set Locators To,8,232,113,113,All Project%CRLF%Parts on Tracks%CRLF%Manually Set,0
   Label=Default File Name,168,104,true
   Button=QUIT,200,320,57,25,4
   Button=GO!,264,320,57,25,5
   Label=Multi Track Export by Phil Pendlebury,16,16,true
   Label=Ignore if you will get track names,168,136,true
   Label=Will be appended with _1 _2 etc.,168,120,true
   Label=from filename.txt text file,168,152,true
   Label=tracknames.txt must be in same folder as exe file,16,184,true
   Label=TRACK NAMING:,16,88,true
   Label=LOCATOR SELECTION:,16,216,true
EndDialog>Dialog1

Show>Dialog1

//Get Handle of filename Edit Box
LibFunc>User32,FindWindowA,dlgHwnd,TForm,Export Settings
LibFunc>User32,FindWindowExA,editHwnd,dlgHwnd,0,TEdit,yourfile

Label>ActionLoop
GetDialogAction>Dialog1,result

if>Dialog1.msCheckBox1=True
  //Disable Edit Box
  LibFunc>User32,EnableWindow,rEW,editHwnd,0
else
  //Enable Edit Box
  LibFunc>User32,EnableWindow,rEW,editHwnd,1
endif

Let>audiotracks=%Dialog1.msEdit1%
Let>filename=%Dialog1.msEdit2%
Let>allorused=%Dialog1.msRadioGroup1%
Let>textfile=%Dialog1.msCheckBox1%
If>result=5,Begin
If>result=4,End
Goto>ActionLoop
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
Phil Pendlebury
Automation Wizard
Posts: 538
Joined: Tue Jan 16, 2007 9:00 am
Contact:

Post by Phil Pendlebury » Tue Jan 16, 2007 11:00 pm

Marcus I don't know how you did that but I will figure it out and meantime... THANK YOU... Fantastic!

:-)
Phil Pendlebury - Linktree

User avatar
Phil Pendlebury
Automation Wizard
Posts: 538
Joined: Tue Jan 16, 2007 9:00 am
Contact:

Post by Phil Pendlebury » Sat Feb 17, 2007 1:01 pm

Hi again.

I now need to do this to another two edit boxes.

the code you gave me before:

Code: Select all


//Get Handle of filename Edit Box
LibFunc>User32,FindWindowA,dlgHwnd,TForm,Export Settings
LibFunc>User32,FindWindowExA,editHwnd,dlgHwnd,0,TEdit,yourfile

Label>ActionLoop
GetDialogAction>Dialog1,result

if>Dialog1.msComboBox1<Default>User32,EnableWindow,rEW,editHwnd,0
else
  //Enable Edit Box
  LibFunc>User32,EnableWindow,rEW,editHwnd,1
endif
I cant figure out what to add / change in order to get it to grey it another edit box. Or maybe it is not possible to do more than one?

The two edit box properties:

Edit=msEdit3,16,104,121,STOP
Edit=msEdit1,16,80,25,10


msEdit3 should be greyed out by default

And if this is checked

CheckBox=msCheckBox2,Use Stop Track,16,128,97,False

msEdit3 is open for input and ,msEdit1 becomes greyed out.

This is along with the other one you already helped me with.

I understand you probably don't want to just create the code for me but could you give me some pointers as to what value does what in the edHwnd commands etc. ?

I have tried experimenting but to no avail I'm afraid.

Thanks.
Phil Pendlebury - Linktree

User avatar
pgriffin
Automation Wizard
Posts: 460
Joined: Wed Apr 06, 2005 5:56 pm
Location: US and Europe

Post by pgriffin » Sun Feb 18, 2007 9:53 pm

Phil,

here is an example of multiple edits being "greyed out".

Note that 'SomeText' has to appear in the dialog "Export Settings" as the right-most variable for and Edit.

Edit=msEdit2,12,12,32,12,SomeText

LibFunc>User32,FindWindowA,dlgHwnd,TForm,Export Settings
LibFunc>User32,FindWindowExA,edit1Hwnd,dlgHwnd,0,TEdit,yourfile
LibFunc>User32,FindWindowExA,edit2Hwnd,dlgHwnd,0,TEdit,SomeText

Label>ActionLoop
GetDialogAction>Dialog1,result

if>"some condition" is met
LibFunc>User32,EnableWindow,rEW,edit2Hwnd,0
else
LibFunc>User32,EnableWindow,rEW,edit2Hwnd,1
endif

if>Dialog1.msCheckBox1=True
//Disable Edit Box
LibFunc>User32,EnableWindow,rEW,edit1Hwnd,0
else
//Enable Edit Box
LibFunc>User32,EnableWindow,rEW,edit1Hwnd,1
endif

.....

You can disable/enable as many fields as you like with this method.

got it? if not, just ask. Notice that I have numbered the editHwnd variables....

User avatar
Phil Pendlebury
Automation Wizard
Posts: 538
Joined: Tue Jan 16, 2007 9:00 am
Contact:

Post by Phil Pendlebury » Mon Feb 19, 2007 9:21 am

That's great thank you. :-)

On a similar subject I have been having real trouble with default values for Drop Down lists but I will post this separately.

Thanks again, I'm sure others will also find this useful.
Phil Pendlebury - Linktree

User avatar
Phil Pendlebury
Automation Wizard
Posts: 538
Joined: Tue Jan 16, 2007 9:00 am
Contact:

Post by Phil Pendlebury » Mon Feb 19, 2007 11:36 am

OK this works great except I have found a problem or even a "bug" if you like.

Code: Select all

//Get Handle of filename Edit Box
LibFunc>User32,FindWindowA,dlgHwnd,TForm,Export Settings
LibFunc>User32,FindWindowExA,edit1Hwnd,dlgHwnd,0,TEdit,%deffilename%
LibFunc>User32,FindWindowExA,edit2Hwnd,dlgHwnd,0,TEdit,%deftracks%
LibFunc>User32,FindWindowExA,edit3Hwnd,dlgHwnd,0,TEdit,%defstop%
In my script %deftracks% is a number

When running the dialog I am greeted with an error
Access violation are address 76B1AE31 in module USER32.dll. read the address 000000A.
I then have to manually quit the script. If I then run again I get:
Error trying to create dialog
The only way to run anything after this is to quite MS and restart it.

I tried changing the %deftracks% to a simple word "hello" and it worked perfectly. I then changed it to a number "10" and got the error again.

Windows Vista btw.
Phil Pendlebury - Linktree

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Mon Feb 19, 2007 11:42 am

Did you read the LibFunc documentation and try this:

LibFunc>User32,FindWindowExA,edit2Hwnd,dlgHwnd,0,TEdit,str:deftracks

DLLs are not forgiving and certainly nowhere near as forgiving as Macro Scheduler. So if a DLL requires a string but is given a number it will do nasty things to you! So the above lets us tell it it must pass the value as a string.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
Phil Pendlebury
Automation Wizard
Posts: 538
Joined: Tue Jan 16, 2007 9:00 am
Contact:

Post by Phil Pendlebury » Mon Feb 19, 2007 11:50 am

Ok I have got around this by entering a word as the value of that edit box and then doing this before the dialog action loop begins:

Code: Select all

LibFunc>User32,FindWindowExA,edit2Hwnd,dlgHwnd,0,TEdit,number

Code: Select all

Let>Dialog1.msEdit1=%deftracks%
rda>Dialog1
Hope this makes sense. It does seem though, that using an actual number causes the error. May be worth looking into?

Cheers,
Phil Pendlebury - Linktree

User avatar
Phil Pendlebury
Automation Wizard
Posts: 538
Joined: Tue Jan 16, 2007 9:00 am
Contact:

Post by Phil Pendlebury » Mon Feb 19, 2007 11:52 am

Sorry, no I didn't see the LibFunc documentation I don't know where that would be? EDIT: OK found it and added an extra red face... and I also posted back before you posted.

Apologies.

:oops: :oops: :oops: :oops:
Last edited by Phil Pendlebury on Mon Feb 19, 2007 11:56 am, edited 1 time in total.
Phil Pendlebury - Linktree

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Mon Feb 19, 2007 11:52 am

You don't know where the LibFunc documentation is!?

Try any of these:

1. Anywhere in Macro Scheduler hit F1 then search for LibFunc
2. Start/Programs/Macro Scheduler/Macro Scheduler Help
3. With the LibFunc code builder dialog open hit F1 or click Help
4. Place the cursor on LibFunc in the editor and hit F1
5. Select Help/Contents and search for LibFunc
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Mon Feb 19, 2007 12:00 pm

Note that 'SomeText' has to appear in the dialog "Export Settings" as the right-most variable for and Edit.

Edit=msEdit2,12,12,32,12,SomeText
But of course you only need get the handles once, so SomeText can be an initial value which can be removed/replaced/set to nothing once you have the handles. So the user doesn't need to see it.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
Phil Pendlebury
Automation Wizard
Posts: 538
Joined: Tue Jan 16, 2007 9:00 am
Contact:

Post by Phil Pendlebury » Mon Feb 19, 2007 12:45 pm

I did edit my post above once again before I saw your new post. My apologies. It is tricky stuff though for a n00b like me.

After reading the help I would still never have been able to do what you did for me although maybe I would have realised that the dll error was because I had something incorrect.

Once again, I am sure this will help others too so I hope you don't consider it wasted time.

Thanks and all the best,
Phil Pendlebury - Linktree

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts