I have a preview for xprint/graphc.
I added a scrollbar (vertical) when i 'zoom' in.
The 'zoomed' page show (in larger font) the top or bottom half of the page.
I was using (and is still included) a button to 'page down/up'.
The scrollbar works fine but i only want it to show up in the zoom mode.
Now, if i just zoom and dont do a page down (or click on the scrollbar) then
go back to full page display the scrollbar disappears as it should. But once
i do a page/down or click the scrollbar then if i go back to full page view the
scrollbar remains and i cant get rid of it. Here is the callback routine
701 is the value of the scrollbar
UPDATED CODE below -- the scrollbar now disappears thanks to the help of Fred Harris.
Scrollbar now positions correctly.
Removed the si.n whatever = 0 and
setscrollinfo in the place where the scrollbar is eliminated and replaced with
control kill.
I added a scrollbar (vertical) when i 'zoom' in.
The 'zoomed' page show (in larger font) the top or bottom half of the page.
I was using (and is still included) a button to 'page down/up'.
The scrollbar works fine but i only want it to show up in the zoom mode.
Now, if i just zoom and dont do a page down (or click on the scrollbar) then
go back to full page display the scrollbar disappears as it should. But once
i do a page/down or click the scrollbar then if i go back to full page view the
scrollbar remains and i cant get rid of it. Here is the callback routine
701 is the value of the scrollbar
UPDATED CODE below -- the scrollbar now disappears thanks to the help of Fred Harris.
Scrollbar now positions correctly.
Removed the si.n whatever = 0 and
setscrollinfo in the place where the scrollbar is eliminated and replaced with
control kill.
Code:
CALLBACK FUNCTION DlgProc1 LOCAL lResult&,x1!,x2!,y1!,y2!,fil$ LOCAL msg$ LOCAL si AS SCROLLINFO,oldpos AS LONG STATIC hCurZoom AS DWORD STATIC hCurZoomO AS DWORD STATIC hCursor1 AS DWORD STATIC hPreview AS DWORD STATIC GraphicHandle AS LONG STATIC cursorname AS ASCIIZ * 255 STATIC cursorname2 AS ASCIIZ * 255 STATIC modulename AS ASCIIZ * 255 LOCAL nScreenWidth AS LONG,x&,xx& LOCAL nScreenHeight AS LONG,y&,yy& STATIC count& STATIC hCtrl& 'cursorname="ZOOM" cursorname="ZOOMIN" cursorname2="ZOOMOUT" modulename="WUXPRNT.DLL" DIM rc AS RECT, i AS LONG, j AS LONG, Delta(1) AS LONG, ij AS INTEGER SELECT CASE CBMSG CASE %WM_INITDIALOG 'hCurZoom = LoadCursor(GetModuleHandle(""), "ZOOM") hCurZoom = LoadCursor(GetModuleHandle(modulename), Cursorname) '"ZOOM") hCurZoomO = LoadCursor(GetModuleHandle(modulename), Cursorname2) '"ZOOM") hPreview = GetDlgItem(hDlgPreview, %IDC_Graphic1) 'PREVIEW) hCursor1 = GetClassLong(hPreview, %GCL_HCURSOR) SetClassLong hPreview, %GCL_HCURSOR, hCurZoom 'Cursor2 PageBeingViewed&=1 PagesPreviewed&=1 lResult&=previewit(coid$,pagesPreviewed&) CONTROL DISABLE hDlgPreview,%IDC_GRAPHIC1 CASE %WM_MOUSEMOVE ' Ensure zoom cursor is used IF GetCursor <> hCurZoom THEN IF zoom&=0 THEN SetCursor hCurZoom ELSE SetCursor hCurZoomO END IF END IF CASE %WM_DESTROY DestroyCursor hCursor1 DestroyCursor hCurZoom DestroyCursor hCurZoomO CASE %WM_LBUTTONDOWN 'UP 'DOWN SendMessage hDlgPreview,%WM_COMMAND,304&,0 CASE %WM_RBUTTONDOWN 'UP 'DOWN IF zoom&=1 THEN SendMessage hDlgPreview,%WM_COMMAND,304&,0 END IF CASE %WM_VSCROLL count&=count&+1 IF count&=2 THEN count&=0 SendMessage hDlgPreview,%WM_COMMAND,305&,0 'access up/down EXIT FUNCTION ELSE EXIT FUNCTION END IF CASE %WM_COMMAND SELECT CASE CBCTL CASE %IDC_GRAPHIC1 'the graphic area (report) IF CBCTLMSG=%STN_CLICKED THEN SendMessage hDlgPreview,%WM_COMMAND,304&,0 END IF IF CBCTLMSG=%STN_DBLCLK THEN IF zoom&=1 THEN SendMessage hDlgPreview,%WM_COMMAND,304&,0 END IF CASE 301 'ok button end dialog and start print GRAPHIC WINDOW END '??? DIALOG END hDlgPreview,0 CASE 302 'next page GRAPHIC SET POS (0,0) GRAPHIC CLEAR GRAPHIC REDRAW pagespreviewed&=pagespreviewed&+1 'PageBeingViewed&=PageBeingViewed&+1 IF pagespreviewed&>pagestoprint& THEN pagespreviewed&=pagestoprint& IF pagespreviewed&=pagestoprint& THEN CONTROL KILL hDlgPreview,302 'CONTROL DISABLE hDlgPreview,302 CONTROL ADD BUTTON,hDlgPreview,302,"Next", 052,02,45,16 CONTROL DISABLE hDlgPreview,302 END IF IF pagespreviewed&>1 THEN CONTROL KILL hDlgPreview,303 CONTROL ADD IMGBUTTONX, hDlgPreview,303,"PRV", 099,02,45,16 '097,2,45,16 SLEEP 0 END IF 'IF PageBeingViewed&>pagestoprint& THEN PageBeingViewed&=pagestoprint& lResult&=previewit(coid$,pagespreviewed&) CONTROL DISABLE hDlgPreview,%IDC_GRAPHIC1 CASE 303 'previous page PagesPreviewed&=PagesPreviewed&-1 '2 pageBeingViewed&=PageBeingViewed&-1 IF PageBeingViewed&<1 THEN PageBeingViewed&=1 IF PagesPreviewed&<=1 THEN PagesPreviewed&=1 CONTROL KILL hDlgPreview,303 CONTROL ADD BUTTON, hDlgPreview,303,"Previous", 099,02,45,16 '097,2,45,16 CONTROL DISABLE hDlgPreview,303 EXIT IF:EXIT FUNCTION END IF IF PagesPreviewed&<PagestoPrint& THEN 'CONTROL ENABLE hDlgPreview,302 CONTROL KILL hDlgPreview,302 CONTROL ADD IMGBUTTONX,hDlgPreview,302,"NXT", 052,02,45,16 '047,2,45,16 END IF GRAPHIC SET POS (0,0) GRAPHIC CLEAR GRAPHIC REDRAW lResult&=previewit(coid$,pagespreviewed&) CONTROL DISABLE hDlgPreview,%IDC_GRAPHIC1 CASE 304 'zoom in/out CONTROL KILL hDlgPreview,%IDC_GRAPHIC1 IF zoom&=0 THEN zoom&=1 nScreenWidth= GetSystemMetrics(%SM_CXSCREEN ) nScreenHeight= GetSystemMetrics(%SM_CYSCREEN) DIALOG PIXELS hDlgPreview,nScreenWidth,nScreenHeight TO UNITS x&,y& IF PageW!=0 THEN PageW!=8.5 IF PageH!=0 THEN PageH!=11 CONTROL KILL hDlgPreview,401 CONTROL KILL hDlgPreview,402 CONTROL KILL hDlgPreview,304 'zoom graphw&=566/8.5*PageW! IF GraphH&=0 THEN GraphH&=300/(PageH!/2)*PageH!/2 IF pageH!=14 THEN graphh&=300*14/11 'DIALOG SET SIZE hDlgPreview, Graphw&+40,Graphh&+25 '600,325 DIALOG SET SIZE hDlgPreview, Graphw&+40,Graphh&+25 '600,325 DIALOG SET LOC hDlgPreview, 0,0 'CONTROL ADD SCROLLBAR, hDlgPreview,%idc_scrollbar1,"",Graphw&+25,20,30,Graphh&-20,%WS_VSCROLL or %SBS_VERT 'or %WS_TABSTOP 'ctlstyle& = %WS_CHILD OR %WS_VISIBLE OR %WS_BORDER OR %SS_CENTER OR %WS_HSCROLL OR %WS_VSCROLL OR %SS_NOTIFY ' SS_NOTIFY required to respond to mouse clicks ! ctlstyle& = %WS_VISIBLE OR %WS_BORDER OR %SS_CENTER OR %WS_VSCROLL OR %SS_NOTIFY ' SS_NOTIFY required to respond to mouse clicks ! 'control add label,hDlgPreview,%IDC_SCROLLBAR1,"",Graphw&+25,20,1,graphh&-20,ctlstyle& '30,Graphh&-20,ctlstyle& CONTROL ADD SCROLLBAR,hDlgPreview,%IDC_SCROLLBAR1,"",Graphw&+25,20,40,Graphh&-20,ctlstyle& 'CONTROL HANDLE hForm1&, %FORM1_LABEL1 TO hCtrl& CONTROL HANDLE hDlgPreview, %IDC_SCROLLBAR1 TO hCtrl& 'OriginalProc=SetWindowLong(hCtrl&, %GWL_WNDPROC, CODEPTR(MySubClassProc)) 'SetScrollRange hwnd, %SB_VERT, 0, UBOUND(sysmetrics), %FALSE si.cbSize = LEN(si) ' get place holders for the si parameters si.fMask = %SIF_ALL ' setting the topological space for the scroll bars si.nMin = 0 ' min scroll pos si.nMax = 270 '1 'Graphh&-30 '1 'gphh&-30 'h ' max scroll pos si.nPage = 135 '2 'Graphh&-20 '1 'gphh&-20 'vt ' lenght of the vertical scroll bar's thumb si.npos = 0 si.ntrackpos = 0 'SetScrollRange hCrtl&,%SB_CTL,135,270,%FALSE 'hdlgPreview,%idc_scrollbar1 , 0, 270, %FALSE 'SetScrollInfo CBHNDL, %SB_VERT, si, 1 ' initial setup of the vertical scrollbar, "1" represents ' "TRUE" and causes redraw of the scroll bar 'SetScrollInfo hDlgPreview, %idc_scrollbar1, si, 1 ' initial setup of the vertical scrollbar, "1" represents true 'SetScrollInfo hCtrl&, %SB_VERT, si, 1 ' initial setup of the vertical scrollbar, "1" represents true SetScrollInfo hCtrl&, %SB_CTL, si, 1 ' initial setup of the vertical scrollbar, "1" represents true 'SetScrollInfo %IDC_SCROLLBAR1,%SB_CTL,si,1 'hCtrl&, %SB_CTL, si, 1 'CONTROL REDRAW hDlgPreview,%IDC_SCROLLBAR1 LOCAL xloc&,yloc& IF graphw&+40<x& THEN xloc&=(x&-(graphw&+40))/2 END IF IF graphh&+25<y& THEN yloc&=(y&-(graphh&+25))/2-16 END IF IF xloc&<>0 AND yloc&<>0 THEN DIALOG SET LOC hDlgPreview, xloc&,yloc& END IF DIALOG GET SIZE hDlgPreview TO xsize&,ysize& CONTROL ADD IMGBUTTONX, hDlgPreview,304,"ZMO", 146,02,45,16 '147,2,45,16 IF xsize&>=566 THEN CONTROL ADD GRAPHIC, hDlgPreview, %IDC_GRAPHIC1, "", (xsize&-Graphw&)/2-4,20,Graphw&,Graphh&,%SS_NOTIFY OR %WS_HSCROLL ELSE CONTROL ADD GRAPHIC, hDlgPreview, %IDC_GRAPHIC1, "", 0, 20, Graphw&,Graphh&,%SS_NOTIFY OR %WS_HSCROLL'OR %WS_VSCROLL END IF CONTROL KILL hDlgPreview,305 CONTROL ADD IMGBUTTONX, hDlgPreview,305,"PD1", 193,02,45,16 SetCursor hCurZoomO ELSE zoom&=0 nScreenWidth= GetSystemMetrics(%SM_CXSCREEN ) 'LOCAL nScreenHeight AS LONG,y&,yy& nScreenHeight= GetSystemMetrics(%SM_CYSCREEN) IF PageW!=0 THEN PageW!=8.5 IF PageH!=0 THEN PageH!=11 graphw&=293/8.5*PageW! GraphH&=PageH!/11*300 '/11*PageH! IF PageH!=14 THEN GraphH&=14/11*300 CONTROL KILL hDlgPreview,304 CONTROL KILL hDlgPreview,305 'control kill hDlgPreview,%idc_scrollbar1 '701 CONTROL ADD IMGBUTTONX, hDlgPreview,304,"ZMI", 146,02,45,16 '147,2,45,16 CONTROL ADD BUTTON, hDlgPreview,305,"Page Down", 193,02,45,16 CONTROL DISABLE hDlgPreview,305 DIALOG SET SIZE hDlgPreview, graphw&+50,Graphh&+40'graphw&+10,Graphh&+40 '293,340 DIALOG PIXELS hDlgPreview,nScreenWidth,nScreenHeight TO UNITS x&,y& xx&=(x&-graphw&-50)/2 '-7)/2 '290)/2 yy&=(y&-graphh&-40)/2 '-45)/2 '345)/2 IF xx&>0 AND yy&>0 THEN DIALOG SET LOC hDlgPreview,xx&,yy&-8 '10 ' xx&,yy& END IF CONTROL ADD GRAPHIC, hDlgPreview, %IDC_GRAPHIC1, "", 23, 20, 293,GraphH&,%SS_NOTIFY CONTROL ADD IMAGEX,hDlgPreview,401,"BL1",15,20,08,Graphh& '300',%SS_BLACKFRAME CONTROL ADD IMAGEX,hDlgPreview,402,"BL1",316,20,08,graphh& '300',%SS_BLACKFRAME 'control kill hDlgPreview,%idc_scrollbar1 '701 zoom&=0:downit&=0 SetCursor hCurZoom 'si.nMin = 0 ' min scroll pos 'si.nMax = 0 'gphh&-30 'h ' max scroll pos 'si.nPage = 0 'gphh&-20 'vt ' lenght of the vertical scroll bar's thumb 'si.fMask = 0 '%SIF_ALL'SIF_ALL 'si.nPos = 0 'si.cbsize = 0 'si.ntrackpos = 0 ''SetScrollInfo CBHNDL, %SB_VERT, si, 1 ' initial setup of the vertical scrollbar, "1" represents ''setscrollinfo hDlgPreview,%idc_scrollbar1,si,1 ''SetScrollInfo hCtrl&, %SB_VERT, si, 1 'SetScrollInfo hCtrl&, %SB_CTL, si, 1 CONTROL KILLl hDlgPreview,%idc_scrollbar1 END IF IF pagespreviewed&<pagestoprint& THEN CONTROL KILL hDlgPreview,302 CONTROL ADD IMGBUTTONX,hDlgPreview,302,"NXT", 052,02,45,16 '047,2,45,16 END IF IF pagespreviewed&>1 THEN CONTROL KILL hDlgPreview,303 CONTROL ADD IMGBUTTONX, hDlgPreview,303,"PRV", 099,02,45,16 '097,2,45,16 END IF lResult&=previewit(coid$,pagespreviewed&) 'fil$) CONTROL DISABLE hDlgPreview,%IDC_GRAPHIC1 EXIT FUNCTION CASE 305 'down/up x2!=8.5*720 y2!=11*720 IF pageH!=14 THEN y2!=14*720 x1!=0:y1!=0 GetScrollInfo hCtlr&, %SB_CTL, si 'oldPos = si.nPos IF downit&=0 THEN GRAPHIC SCALE (x1!,y1!)-(x2!,y2!/2) Downit&=1 CONTROL KILL hDlgPreview,305 CONTROL ADD IMGBUTTONX,hDlgPreview,305,"PU1",193,02,45,16 IF PageIsaBMP& THEN 'GRAPHIC STRETCH hBMP,0,(0,(bmpHeight&-1)/4)-(bmpWidth&-1,bmpHeight&-1) TO (x1!+180,y1!+300)-(x2!-360,y2!-600)'(0,0)-(529,359) 'GRAPHIC REDRAW END IF si.cbSize = LEN(si) ' get place holders for the si parameters si.fMask = %SIF_ALL ' setting the topological space for the scroll bars si.nMin = 0 ' min scroll pos si.nMax = 270 '1 'graphh&-30 'phh&-30 'h ' max scroll pos si.nPage = 135 '2 'graphh&-20 'gphh&-20 'vt ' lenght of the vertical scroll bar's thumb si.npos = 270 '1 'Graphh&-30 '1 'si.nmax 'gphh&-30 'si.nmax si.ntrackpos = 0 xx&=si.npos 'SetScrollInfo hDlgPreview, %IDC_Scrollbar1, si, 1 '0 'SetScrollInfo hCtrl&, %SB_VERT, si, 1 SetScrollInfo hCtrl&, %SB_CTL, si, 1 'SetScrollInfo %IDC_Scrollbar1, %SB_VERT,si, 1 '0 'control redraw didnt help 'CONTROL REDRAW hDlgPreview,%IDC_SCROLLBAR1 'dialog redraw hdlgPreview 'SetScrollPos hDlgPreview,%IDC_Scrollbar1,si.npos,1 '%SB_VERT, si, 1 ELSE downit&=0 'GRAPHIC SCALE (x1!,y1!)-(x2!-72,y2!-120) GRAPHIC SCALE (x1!,y1!)-(x2!,y2!) CONTROL KILL hDlgPreview,305 'SET TEXT hDlgPreview,305,"Page Down" CONTROL ADD IMGBUTTONX,hDlgPreview,305,"PD1",193,02,45,16 IF PageIsaBMP& THEN 'GRAPHIC STRETCH hBMP,0,(0,0)-(bmpWidth&-1,(bmpHeight&-1)/4*3) TO (x1!+180,y1!+300)-(x2!-360,y2!-600)'(0,0)-(529,359) 'GRAPHIC REDRAW END IF IF zoom&=0 THEN si.cbSize = 0 'LEN(si) ' get place holders for the si parameters si.fMask = 0 '%SIF_ALL ' setting the topological space for the scroll bars si.nMin = 0 ' min scroll pos si.nMax = 0 'Graphh&-30 '1 'gphh&-30 'h ' max scroll pos si.nPage = 0 'Graphh&-20 '1 'gphh&-20 'vt ' lenght of the vertical scroll bar's thumb si.npos = 0 'Graphh&-30 '0 'si.nmax si.ntrackpos = 0 '1 'SetScrollInfo hDlgPreview, %idc_scrollbar1,si,1 'SetScrollInfo hCtrl&, %SB_VERT, si, 1 SetScrollInfo hCtrl&, %SB_CTL, si, 1 'SetScrollPos hDlgPreview,%IDC_Scrollbar1,si.npos,1 CONTROL KILL hDlgPreview,%IDC_SCROLLBAR1 SLEEP 10 ELSE si.cbSize = LEN(si) ' get place holders for the si parameters si.fMask = %SIF_ALL ' setting the topological space for the scroll bars si.nMin = 0 ' min scroll pos si.nMax = 270 '1 'Graphh&-30 '1 'gphh&-30 'h ' max scroll pos si.nPage = 135 '2 'Graphh&-20 '1 'gphh&-20 'vt ' lenght of the vertical scroll bar's thumb si.npos = 0 'si.nmax si.ntrackpos = 0 'SetScrollInfo hDlgPreview, %idc_scrollbar1,si,1 'SetScrollInfo hCtrl&, %SB_VERT, si, 1 SetScrollInfo hCtrl&, %SB_CTL, si, 1 'CONTROL REDRAW hDlgPreview,%IDC_SCROLLBAR1 'dialog redraw hDlgPreview END IF END IF CONTROL KILL hDlgPreview,302 CONTROL ADD IMGBUTTONX,hDlgPreview,302,"NXT", 052,02,45,16 '047,2,45,16 lResult&=previewit(coid$,pagespreviewed&) 'fil$) CONTROL DISABLE hDlgPreview,%IDC_GRAPHIC1 CASE 306 'cancel abort&=1 CONTROL KILL hDlgPreview,%IDC_GRAPHIC1 GRAPHIC WINDOW END DIALOG END hDlgPreview CASE 307 'help -- only shows when zoom in because of no room in smaller dialog msg$= "Zoom in, Zoom out, Page Down."' , Page Up Always revert to" msg$=msg$+$CRLF+"Page Down or scroll bar can used to view the lower" '1 for the preview. This is to insure that the scale" msg$=msg$+$CRLF+"portion of the page after zooming in."'and any other necessary information is correctly displayed." msg$=msg$+$CRLF+"Next Page and Previous Page are self explanatory." msg$=msg$+$CRLF+"Cancel returns to the menu,Print sends report to the printer." msg$=msg$+$CRLF+" " msg$=msg$+$CRLF+"Next is disabled if total pages=1 or viewing last page." msg$=msg$+$CRLF+"Previous is disabled if total pages=1 or viewing page 1." msg$=msg$+$CRLF+"Page Down/Page Up is disabled unless in zoom mode." msg$=msg$+$CRLF+" " msg$=msg$+$CRLF+"Click Zoom In (or just click mouse with Zoom+ showing to zoom" msg$=msg$+$CRLF+"in to the top half of the page. Click mouse again or click" msg$=msg$+$CRLF+"the Zoom Out button to return to full page preview." MSGBOX msg$,,"Preview Help" CASE ELSE END SELECT END SELECT END FUNCTION
Comment