On Sun, Nov 18, 2012 at 10:03 AM, Mark Miesfeld <miesf...@gmail.com> wrote:
> On Sat, Nov 17, 2012 at 3:56 PM, <amphitr...@ok.de> wrote:
>
>>
> With self~moveTo(x, y); self~ensureVisible() in method initDialog
>> it flickers because the dialog is shown first in the middle of the
>> display, for almost no time but long enough to make it observably
>> flicker once.
>>
>
> You're on the right track here, you just need to take care of a few
> details.
>
Actually, I needed to code an example to remember the correct details.
The main thing is to make the sub-dialog not visible in ResEdit. Then you
basically do not need to do anything except position the dialog in
initDialog()
dlg~execute("SHOWTOP", IDI_DLG_OODIALOG)
When execute runs, it first invokes initDialog(), then it invokes show().
If you have the sub-dialog invisible, then it will not display on the
screen. When ooDialog invokes show() with SHOWTOP, this will show the
invisible dialog. This eliminates the flicker you see.
In addition, if you have set your system to move the pointer to the default
button, this will work correctly - you won't see the pointer left in the
old position. The operating system "does the right thing" in this case.
Here is a complete working example, maiDlg.rex, along with the .h and .rc
files to go with it. If you copy and paste, then you will need to fix the
lines that wrap.
The system menu has 3 items added under the Extra Dialogs menu. One item
positions a sub-dialog at the pointer position, one positions a sub-dialog
below the main dialog, and one positions a sub-dialog to the left of the
main dialog.
I didn't put comments in the program. So, after you take a look at it, if
you have questions on anything, then just ask.
Also, the program works well, if the user does not move the main dialog.
But, try moving the main dialog to the bottom of the screen and then
select the: Show sub-dialog low menu item. The sub-dialog will be off the
screen. This is where ensureVisible() comes in handy.
You can fix this by changing the
dlg~execute("SHOWTOP", IDI_DLG_OOREXX)
line to this:
dlg~executeAsync("SHOWTOP", IDI_DLG_OODIALOG)
dlg~ensureVisible
dlg~endAsyncExecution
Here is the example program and .rc / .h files:
/* mainDlg.rex Simple RcDialog with a modal sub-dialgo */
.application~useGlobalConstDir('O', 'mainDlg.h')
dlg = .SimpleRcDlg~new("mainDlg.rc", IDD_MAIN )
dlg~execute("SHOWTOP", IDI_DLG_OOREXX)
return 0
-- End of entry point.
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -*\
Directives, Classes, or Routines.
\* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -*/
::requires "ooDialog.cls"
::class 'SimpleRcDlg' subclass RcDialog
::method initDialog
self~configMenu
::method showLo unguarded
use arg id, x, y
r = self~windowRect
p = .Point~new(r~right, r~bottom)
if .OS~isAtLeastVista then do
adjustForGlassX = 2 *.SM~cxFixedFrame
adjustForGlassY = 2 *.SM~cyFixedFrame
end
else do
adjustForGlassX = 0
adjustForGlassY = 0
end
p~x += adjustForGlassX
p~y += adjustForGlassY
dlg = .SubDlg~new("mainDlg.rc", IDD_SUBDLG)
dlg~initialPos = p
dlg~toLeft = .false
reply .true
dlg~execute("SHOWTOP", IDI_DLG_OODIALOG)
::method showHere unguarded
use arg id, x, y
pos = .Point~new(x, y)
dlg = .SubDlg~new("mainDlg.rc", IDD_SUBDLG)
dlg~initialPos = pos
dlg~toLeft = .false
reply .true
dlg~execute("SHOWTOP", IDI_DLG_OOREXX)
::method showLeft unguarded
use arg id, x, y
r = self~windowRect
p = .Point~new(r~left, r~top)
dlg = .SubDlg~new("mainDlg.rc", IDD_SUBDLG)
dlg~initialPos = p
dlg~toLeft = .true
reply .true
dlg~execute("SHOWTOP", IDI_DLG_OODIALOG)
::method configMenu private
sysMenu = .SystemMenu~new(self)
popup = .PopupMenu~new(IDM_MENU_EXTRA)
popup~insertItem(IDM_SHOW_HI, IDM_SHOW_HI, 'Show sub-dialog here')
popup~insertItem(IDM_SHOW_HI, IDM_SHOW_LO, "Show sub-dialog low")
popup~insertItem(IDM_SHOW_HI, IDM_SHOW_LEFT, "Show sub-dialog to left")
sysMenu~insertPopup(SC_MOVE, IDM_MENU_EXTRA, popup, "Extra Dialogs")
sysMenu~insertSeparator(SC_MOVE, IDM_SEPARATOR)
sysMenu~connectCommandEvent(IDM_SHOW_LO, 'showLo')
sysMenu~connectCommandEvent(IDM_SHOW_HI, 'showHere')
sysMenu~connectCommandEvent(IDM_SHOW_LEFT, 'showLeft')
::class 'SubDlg' subclass RcDialog
::attribute initialPos
::attribute toLeft
::method initDialog
if \ self~toLeft then do
self~moveTo(self~initialPos)
end
else do
s = self~getRealSize
pos = self~initialPos
if .OS~isAtLeastVista then adjustForGlass = 3 *.SM~cxFixedFrame
else adjustForGlass = 0
pos~x -= s~width + adjustForGlass
self~moveTo(pos)
end
// mainDlg.h
#ifndef IDC_STATIC
#define IDC_STATIC (-1)
#endif
#define IDD_MAIN 101
#define IDD_SUBDLG 103
#define IDM_SHOW_HI 1001
#define IDM_SHOW_LO 1002
#define IDM_SHOW_LEFT 1003
#define IDM_MENU_EXTRA 1004
#define IDM_SEPARATOR 1005
// mainDlg.rc
#include <windows.h>
#include <winuser.h>
#include <commctrl.h>
#include "mainDlg.h"
LANGUAGE 0, SUBLANG_NEUTRAL
IDD_SUBDLG DIALOGEX 0, 0, 186, 95
STYLE DS_3DLOOK | DS_CENTER | DS_MODALFRAME | DS_SHELLFONT | WS_CAPTION |
WS_POPUP | WS_SYSMENU
CAPTION "Sub-Dialog"
FONT 8, "Ms Shell Dlg", 400, 0, 1
{
DEFPUSHBUTTON "OK", IDOK, 71, 71, 50, 14
PUSHBUTTON "Cancel", IDCANCEL, 126, 71, 50, 14
}
LANGUAGE 0, SUBLANG_NEUTRAL
IDD_MAIN DIALOGEX 0, 0, 256, 134
STYLE DS_3DLOOK | DS_CENTER | DS_MODALFRAME | DS_SHELLFONT | WS_CAPTION |
WS_VISIBLE | WS_POPUP | WS_SYSMENU
CAPTION "Main Dialog"
FONT 8, "Ms Shell Dlg", 400, 0, 1
{
DEFPUSHBUTTON "OK", IDOK, 141, 110, 50, 14
PUSHBUTTON "Cancel", IDCANCEL, 196, 110, 50, 14
}
--
Mark Miesfeld
------------------------------------------------------------------------------
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
_______________________________________________
Oorexx-users mailing list
Oorexx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/oorexx-users