Guidance
指路人
g.yi.org
Guidance Forums / Reginald Rexx / Using values from guigetctlplacement

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
Message1. Using values from guigetctlplacement
#12391
Posted by: Doug Arndt 2008-09-30 00:28:00 Last edited by: Jeff Glatt 2009-03-04 14:10:34 (Total edited 1 time)
When I extract the location of a radio button, using guigetctlplacement, then delete the radio button and then use those values to recreate the radio button, the control isn't in the same place.  

Click the "Test Placement" button to demonstrate
/*
GUIBEGIN
WINDOW , 0, 0, 400, 200, POPUP|CAPTION|SYSMENU|MINBOX|MAXBOX|THICK, , My Window
	FONT 8, 400, MS Shell Dlg
	TEXT 6, 137, 389, 55, GROUP, , ConBox, , Console box
	PUSH 324, 94, 40, 14, TABSTOP, , ExitButton, , Exit
	RADIO 147, 50, 39, 10, AUTO|GROUP, , RadioButton, , Radio
	PUSH 50, 102, 66, 14, TABSTOP, , TestPlacement, , Test Placement
DEND
GUIEND
*/

LIBRARY rexxgui, rxconsole

guierr = "SYNTAX"
guiheading = 1
guicreatewindow('NORMAL')

guigetctlplacement('RadioButton','CCX' ,'CCY' , 'CCWidth', 'CCHeight')
consay(con1,"RadioButton location: " ccx ccy ccwidth ccheight)

DO FOREVER
   guigetmsg()
   CATCH SYNTAX
      CONDITION()
   CATCH HALT
   FINALLY
      guidestroywindow()
END
RETURN

/* Create console by converting 'ConBox' */
wm_initdialog:
   guigetctlplacement('ConBox','ConX' ,'ConY' , 'ConWidth', 'ConHeight')
   guiremovectl('ConBox')
   concreate('Con1', guiwindow, "CHILD | NODEFAULT",conx, cony, conwidth, conheight)
   RETURN ""

wm_click_exitbutton:
   guiwake('CLOSE')
   RETURN

wm_click_testplacement:
   guiremovectl('RadioButton')  
   consay(con1,"New button created at:" ccx ccy ccwidth ccheight)
   guiaddctl("RADIO" ccx"," ccy"," ccwidth"," ccheight", AUTO|GROUP, , RadioButton, , New Radio", , 1)
   RETURN
Doug
Message2.
#12396
Posted by: Jeff Glatt 2008-09-30 11:17:16 Last edited by: Jeff Glatt 2008-09-30 11:20:09 (Total edited 1 time)
Sizes/Positions are calculated in two ways on Windows. One way is in raw pixel values. So a width of 100 does in fact mean 100 pixels. But there is also "dialog units", which is what is used in GuiAddCtl, and also the GUI BLOCK. Dialog pixels are scaled according to the font assigned to the window. So if you have 100 dialog units, that may show perhaps about 10 text chars at Courier 8. If you change to Courier 12, now the font is bigger, so in order to show the same number of chars, the control needs to be made bigger. So each dialog unit becomes a larger value. Windows does this so that, if an enduser changes the font on his system, controls will automatically resize to not clip text.

To get dialog units, pass an eighth arg of "SCALE" to GuiGetCtlPlacement:
guigetctlplacement("MyCtl", x, y, width, height, , , "Scale")
Message3.
#12398
Posted by: Doug Arndt 2008-09-30 23:05:30
Isn't working for me, 
   RADIO 147, 50, 39, 10, AUTO|GROUP, , RadioButton, , Radio
without the "scale" i get 221 81 59 16
       with "scale"       221 81 39 10
looks like only the size of the box is affected, not the location. 

Still, isn't this more complicated than it should be ?
Do I, as a REXX programmer, really want to deal with "raw pixel", "dialog units" etc ?   Shouldn't there be a consistancy between all functions so I don't have to care ?  And then the "Options" are useful if I want to go into that mess ?
Doug
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Fri 2024-3-29  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0