Borderless dialogs and dialog objects

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

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

Borderless dialogs and dialog objects

Post by JRL » Fri Jan 11, 2008 4:36 pm

Hi,
I've been working on a script and thought it might be nice to use a dialog with no border. What I discovered was that using the libfunc> technique described in Scripts and Tips for making a dialog borderless, also makes dialog objects unuseable. I have modified the example slightly by adding an edit box and a button. When the following script is run, clicking the button will not cause any effect and the edit box will not accept any data. The script will time out after about 10 seconds.

This is not a big deal but I'm wondering why this occurs and if there is a way to make the dialog borderless and still have a button to press?

Thanks for listening,
Dick

Code: Select all

Dialog>Dialog1
   Caption=MyDialog
   Width=226
   Height=140
   Top=267
   Left=458
   Label=Hello World,80,16,true
   Edit=msEdit1,48,32,121,
   Button=Ok,72,64,75,25,2
   Default=Ok
EndDialog>Dialog1

Let>WS_CAPTION=12582912
Let>WS_MINIMIZEBOX=131072
Let>WS_MAXIMIZEBOX=65536
Let>WS_SYSMENU=524288
Let>WS_THICKFRAME=262144
Let>WS_POPUP=2147483648
Let>WS_CHILD=1073741824

//change the style of MyDialog to non-sizeable with a system menu,
//but no max or min boxes
Show>Dialog1
LibFunc>user32,FindWindowA,dhwnd,TForm,MyDialog
Let>style=WS_CHILD
LibFunc>user32,SetWindowLongA,sres,dhwnd,-16,style
CloseDialog>Dialog1
Show>Dialog1

Let>kk=0
Label>Loop
Add>kk,1
GetDialogAction>dialog1,res1
If>res1=2,EOF
If>kk>1000,EOF
Wait>0.01
Goto>Loop

label>EOF
CloseDialog>Dialog1

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

Post by Marcus Tettmar » Fri Jan 11, 2008 5:09 pm

Not sure if WS_CHILD is the correct flag to use. Try this:

Code: Select all

Dialog>Dialog1
   Caption=MyDialog
   Width=226
   Height=140
   Top=267
   Left=458
   Max=0
   Min=0
   Close=0
   Resize=0
   Label=Hello World,80,16,true
   Edit=msEdit1,48,32,121,
   Button=Ok,72,64,75,25,2
   Default=Ok
EndDialog>Dialog1

Let>WS_CAPTION=12582912
Let>WS_MINIMIZEBOX=131072
Let>WS_MAXIMIZEBOX=65536
Let>WS_SYSMENU=524288
Let>WS_THICKFRAME=262144
Let>WS_POPUP=2147483648
Let>WS_CHILD=1073741824
Let>WS_VISIBLE=268435456
Let>WS_BORDER=8388608

//get current style
LibFunc>user32,GetWindowLongA,style,Dialog1.Handle,-16

//modify style to remove borders and size frame
Let>style={(%style% And Not %WS_CAPTION%)}
Let>style={(%style% And Not %WS_THICKFRAME%)}
LibFunc>user32,SetWindowLongA,sres,Dialog1.Handle,-16,style

//refresh - we have to tell it the frame changed
Let>SWP_FRAMECHANGED=32
Let>SWP_NOMOVE=2
Let>SWP_NOZORDER=4
Let>SWP_NOSIZE=1
Let>flags={(%SWP_FRAMECHANGED% OR %SWP_NOMOVE% OR %SWP_NOZORDER% OR %SWP_NOSIZE%)}
LibFunc>user32,SetWindowPosA,r,Dialog1.Handle,0,0,0,0,0,flags

//show it
Show>Dialog1

Let>kk=0
Label>Loop
Add>kk,1
GetDialogAction>dialog1,res1
If>res1=2,EOF
If>kk>1000,EOF
Wait>0.01
Goto>Loop

label>EOF
CloseDialog>Dialog1
Note - since v9 no need to use FindWindow - just use Dialog.Handle - also means we don't have to show it first.
Last edited by Marcus Tettmar on Fri Jan 11, 2008 6:18 pm, edited 1 time in total.
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
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Fri Jan 11, 2008 5:24 pm

Thank you Marcus. I'll give it a try.

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