Display variable text in Dialog - and "read only"

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
rullbandspelare
Pro Scripter
Posts: 149
Joined: Tue Mar 23, 2004 9:11 pm

Display variable text in Dialog - and "read only"

Post by rullbandspelare » Sat Apr 21, 2007 10:15 am

Hi!
Is there a way to make a Dialog "Edit" field non editable or read only?

Dialog#1 have an "Edit" field which excepts input.
Dialog#2 have the same field but the "Edit" contents should be shown with the input entered in Dialog#1

I have all this working but I just dont want the user to be confused and trying to edit the field in Dialog#2

I have MS 7.4.

Thanks!
/tomas

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

Post by Marcus Tettmar » Sat Apr 21, 2007 11:28 am

Yes, but to do this you would need to 1) get the handle of the edit field, then 2) use the Win32 EnableWindow function. Here's an example:

Code: Select all

Dialog>Dialog1
   Caption=My Dialog
   Width=291
   Height=164
   Top=199
   Left=63
   Edit=msEdit1,72,32,121,msEdit1
   Edit=msEdit2,72,64,121,msEdit2
EndDialog>Dialog1

//initialisation
Show>Dialog1

//get handle of dialog
LibFunc>user32,FindWindowA,dlgHwnd,TForm,My Dialog

//get handle of msEdit2 edit - we use the edit text, so do this when
//you first show the dialog, before setting the value of the edit
LibFunc>User32,FindWindowExA,edthwnd,dlgHwnd,0,TEdit,msEdit2

//now we can do what we want to the dialog .. 

//disable the edit and open modal
CloseDialog>Dialog1
LibFunc>User32,EnableWindow,res,edthwnd,0
Show>Dialog1,r
The messy part is getting the handles of the objects. That's why a forthcoming version of Macro Scheduler will give you variables for the object handles as soon as the dialog is created. Then you can simply use EnableWindow and not have to do all the FindWindow stuff to locate the handles.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

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