Disabling edit areas in Tab Books

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:

Disabling edit areas in Tab Books

Post by Phil Pendlebury » Mon Jan 28, 2008 2:22 am

Hi there,

I am using the following type of code to grey out areas of my main dialog depending on certain criteria.

Code: Select all

//Get Handles
LibFunc>User32,FindWindowA,dlgHwnd,TForm,MEAP Export Settings
LibFunc>User32,FindWindowExA,edit1Hwnd,dlgHwnd,0,TEdit,%deffilename%
LibFunc>User32,FindWindowExA,edit2Hwnd,dlgHwnd,0,TEdit,str:%deftracks%

IF>MEAPDialog.msComboBox1<>Default File Name
  //Disable Edit Box
  LibFunc>User32,EnableWindow,rEW,edit1Hwnd,0
else
  //Enable Edit Box
  LibFunc>User32,EnableWindow,rEW,edit1Hwnd,1
endif

IF>MEAPDialog.msCheckBox4=True
  //Disable Edit Box
  LibFunc>User32,EnableWindow,rEW,edit4Hwnd,1
else
  //Enable Edit Box
  LibFunc>User32,EnableWindow,rEW,edit4Hwnd,0
endif
The problem is that my dialog is getting very large now so I want to start using tab books.

My questions:

Will the grey out technique work ACROSS tabs or does the front tab have to be in focus from the start in order for it to work?

If it will work so please share some code tips :-)

At the moment while using two tab books, none of my grey areas work, even the ones on the main tab.

If you need to see some more code I will post more.

Thank you.
Phil Pendlebury - Linktree

User avatar
JRL
Automation Wizard
Posts: 3504
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Mon Jan 28, 2008 6:38 am

I haven't tested this but I wonder if the problem is in getting the handle. If it is and you have version 9.1 or greater you're in luck since you no longer need to get the handles for objects in your dialogs. The handles are available to be used anytime after the dialog block has been executed. They are in the form DialogName.ObjectName.Handle. (I'm guessing that your dialog block name is dialog1 and your edit objects are msedit1 and msedit4.)

Code: Select all

//Get Handles no longer needed
//LibFunc>User32,FindWindowA,dlgHwnd,TForm,MEAP Export Settings
//LibFunc>User32,FindWindowExA,edit1Hwnd,dlgHwnd,0,TEdit,%deffilename%
//LibFunc>User32,FindWindowExA,edit2Hwnd,dlgHwnd,0,TEdit,str:%deftracks%

IF>MEAPDialog.msComboBox1<Default>User32,EnableWindow,rEW,dialog1.msedit1.handle,0
else
//Enable Edit Box
LibFunc>User32,EnableWindow,rEW,dialog1.msedit1.handle,1
endif

IF>MEAPDialog.msCheckBox4=True
//Disable Edit Box
LibFunc>User32,EnableWindow,rEW,dialog1.msedit4.handle,1
else
//Enable Edit Box
LibFunc>User32,EnableWindow,rEW,dialog1.msedit4.handle,0
endif

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

Post by Phil Pendlebury » Mon Jan 28, 2008 12:44 pm

Thanks JRL but I can't see that working. The syntax doesn't make sense when compared to mine (which was originally provided by Marcus for v 9).

My dialog is called: MEAPDialog, So in your examples you have mentioned 2 different dialogs.

I will give it a try though of course and am very grateful for your assistance.

Even if Marcus is too busy to provide a detailed answer - It would be good to know IF there is a way to get this method working with tabbed dialog boxes.

Thanks again,

Phil.
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 Jan 28, 2008 1:16 pm

Yes, you can definitely disable edits on tabs. Doesn't matter where they are, especially since v9 you have direct access to any object's handle. This works fine for me:

Code: Select all

Dialog>Dialog1
   Caption=Dialog1
   Width=445
   Height=250
   Top=489
   Left=455
   TabBook=msTabBook1,24,8,289,193,0
      TabPage=Page1
         Edit=msEdit1,32,16,121,msEdit1
   EndTabBook
EndDialog>Dialog1

LibFunc>User32,EnableWindow,rEW,Dialog1.msEdit1.Handle,0

Show>Dialog1,r
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 Jan 28, 2008 1:27 pm

Thanks guys, I'll get back to you if any problems arise. Looks straight forward though. Thank you again.
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 Jan 28, 2008 1:34 pm

Works perfectly thank you :-)

Much easier than before as well with no worrying about string or numerical type etc.
Phil Pendlebury - Linktree

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