How does one get a window to be repainted properly?
This dialog is the top one where the action takes place:
Style& = %WS_POPUP Or _
%WS_BORDER Or _
%DS_NOFAILCREATE Or _
%WS_VSCROLL 'Or _ %WS_CLIPCHILDREN
Dialog New hDlg&, "", 7, 45, 407, 240, Style& To sDlg&
In the sub-class procedure for all textboxes on this dialog, I
am attempting to cause the ENTER key to move down all controls
below this point, and then insert a new textbox directly below
the one with the focus. It works very well, only some of the
moved-down labels/textboxes get slightly mangled in the process.
Dragging the thumb of the scrollbar right up and or down to move
them out of sight and back again does the trick - the bad areas
are now properly repainted. WNDW is the name of a global RECT.
(All of this is in a DLL, not an EXE)
Can someone help, please?
Case %WM_KEYDOWN
CtlID&=GetDlgCtrlID(hWnd&)
nsc&=1
Select Case wParam&
Case %VK_RETURN
If CtlID&<Descr& Then Exit Select
Array Scan Mva&(1) For mvc&, =CtlID&, To n& 'Mva&() hold the ID's of ALL
Control Get Size sDlg&, Mva&(n&) To x1&, mvi& 'controls on the dialog
Control Get Loc sDlg&, Mva&(n&) To x0&, y0& 'Get its coordinates, then
For i&=mvc& To n&+1 Step -1 'move down all controls below
Control Get Loc sDlg&, Mva&(i&) To x&, y&
Control Set Loc sDlg&, Mva&(i&), x&, y&+mvi&
Next
m&=NextNo 'Get (next) ID for new textbox
Control Add TextBox, sDlg&, m&, "Jack-in-the=box", x0&, y0&+mvi&, x1&, mvi&, TbxStyle&
If mva&(n&)<DptBgn&-1001 Then Control Send sDlg&, m&, %WM_SETFONT, mnFont&, 1
Incr mvc&
Array Insert mva&(n&+1), m& 'Insert new item ID in list
ti&=ti&+mvi&
iVscrollMax = ti&/15 'Update scrollrange
Call SetScrollRange (sDlg&, %SB_VERT, 0, iVscrollMax, %TRUE)
Dialog Get Loc sDlg& To xL&, yT&
Dialog Get Size sDlg& To xW&, yD& 'Here starts the various efforts
w&=CreateRectRgn (xL&, yT&, xL&+xW&-1, yT&+yD&-1) 'to force repainting
Cx&=GetDlgItem (sDlg&, w&)
wndw.nleft=xL&
wndw.ntop=yT&
wndw.nright=xL&+xW&-1
wndw.nbottom=yT&+yD&
Call InvalidateRect(sDlg&, wndw, %True)
' Call RedrawWindow(sDlg&, wndw, Cx&, %RDW_ERASE Or %RDW_INVALIDATE Or RDW_ALLCHILDREN)
Call UpdateWindow (sDlg&)
------------------
This dialog is the top one where the action takes place:
Style& = %WS_POPUP Or _
%WS_BORDER Or _
%DS_NOFAILCREATE Or _
%WS_VSCROLL 'Or _ %WS_CLIPCHILDREN
Dialog New hDlg&, "", 7, 45, 407, 240, Style& To sDlg&
In the sub-class procedure for all textboxes on this dialog, I
am attempting to cause the ENTER key to move down all controls
below this point, and then insert a new textbox directly below
the one with the focus. It works very well, only some of the
moved-down labels/textboxes get slightly mangled in the process.
Dragging the thumb of the scrollbar right up and or down to move
them out of sight and back again does the trick - the bad areas
are now properly repainted. WNDW is the name of a global RECT.
(All of this is in a DLL, not an EXE)
Can someone help, please?
Case %WM_KEYDOWN
CtlID&=GetDlgCtrlID(hWnd&)
nsc&=1
Select Case wParam&
Case %VK_RETURN
If CtlID&<Descr& Then Exit Select
Array Scan Mva&(1) For mvc&, =CtlID&, To n& 'Mva&() hold the ID's of ALL
Control Get Size sDlg&, Mva&(n&) To x1&, mvi& 'controls on the dialog
Control Get Loc sDlg&, Mva&(n&) To x0&, y0& 'Get its coordinates, then
For i&=mvc& To n&+1 Step -1 'move down all controls below
Control Get Loc sDlg&, Mva&(i&) To x&, y&
Control Set Loc sDlg&, Mva&(i&), x&, y&+mvi&
Next
m&=NextNo 'Get (next) ID for new textbox
Control Add TextBox, sDlg&, m&, "Jack-in-the=box", x0&, y0&+mvi&, x1&, mvi&, TbxStyle&
If mva&(n&)<DptBgn&-1001 Then Control Send sDlg&, m&, %WM_SETFONT, mnFont&, 1
Incr mvc&
Array Insert mva&(n&+1), m& 'Insert new item ID in list
ti&=ti&+mvi&
iVscrollMax = ti&/15 'Update scrollrange
Call SetScrollRange (sDlg&, %SB_VERT, 0, iVscrollMax, %TRUE)
Dialog Get Loc sDlg& To xL&, yT&
Dialog Get Size sDlg& To xW&, yD& 'Here starts the various efforts
w&=CreateRectRgn (xL&, yT&, xL&+xW&-1, yT&+yD&-1) 'to force repainting
Cx&=GetDlgItem (sDlg&, w&)
wndw.nleft=xL&
wndw.ntop=yT&
wndw.nright=xL&+xW&-1
wndw.nbottom=yT&+yD&
Call InvalidateRect(sDlg&, wndw, %True)
' Call RedrawWindow(sDlg&, wndw, Cx&, %RDW_ERASE Or %RDW_INVALIDATE Or RDW_ALLCHILDREN)
Call UpdateWindow (sDlg&)
------------------
Comment