I'm trying to get away from the windows API and use the PB graphics commands. I think I did everything correctly in the code below, but it doesn't work. Anyone have any ideas?
Code:
#compile exe #include "\pbwin80\winapi\win32api.inc" declare function testproc(byval long,byval long,byval long,byval long) as long function winmain(byval hinst&,byval hprev&,byval cmdline as asciiz ptr,byval cmdshow&) as long dim wmsg as tagmsg xsize&=getsystemmetrics(%sm_cxscreen) ysize&=getsystemmetrics(%sm_cyscreen) ysize&=ysize&*(.95) ''create class and register it with windows dim wclass as wndclass dim wclassname as asciiz*80 dim wcaption as asciiz*80 wclassname="TestProg" if isfalse(hprev&) then wclass.style=%cs_hredraw or %cs_vredraw wclass.lpfnwndproc=codeptr(testproc) wclass.cbclsextra=0 wclass.cbwndextra=0 wclass.hinstance=hinst& wclass.hicon=%null wclass.hcursor=loadcursor(%null,byval %idc_arrow) wclass.hbrbackground=getstockobject(%gray_brush) wclass.lpszmenuname=%null wclass.lpszclassname=varptr(wclassname) registerclass wclass end if wcaption="Test Window" style&=%ws_popup or %ws_visible or %ws_caption or %ws_sysmenu hwnd&=createwindow(wclassname,_ ''window class name wcaption,_ ''window caption style&,_ ''window style 0,_ ''initial x position 0,_ ''initial y position xsize&,_ ''initial x size ysize&,_ ''initial y size %null,_ ''parent window handle %null,_ ''window menu handle hinst&,_ ''program instance handle %null) ''creation parameters showwindow hwnd&,cmdshow& updatewindow hwnd& while istrue(getmessage(wmsg,byval %null,0,0)) translatemessage wmsg dispatchmessage wmsg wend function=wmsg.wparam end function function testproc(byval hwnd&,byval msg&,byval wparam&,byval lparam&) as long select case msg& case %wm_create dim wndrect as rect getclientrect hwnd&,wndrect xsize&=wndrect.nright-wndrect.nleft ysize&=wndrect.nbottom-wndrect.ntop control add graphic,hwnd&,1000,"",0,0,xsize&,ysize&,%ws_visible or %ws_child or %ss_notify graphic attach hwnd&,1000 gosub prtest updatewindow hwnd& case %wm_paint dim ps as paintstruct hdc&=beginpaint(hwnd&,ps) endpaint hwnd&,ps case %wm_syscommand if lowrd(wparam&)<>%sc_close then exit select destroywindow hwnd& function=1 exit function case %wm_destroy postquitmessage 0 function=0 exit function end select function=defwindowproc(hwnd&,msg&,wparam&,lparam&) exit function prtest: graphic clear %white graphic color %black,%white graphic get client to xsize&,ysize& xsize&=int(xsize&*(.9)) ysize&=int(ysize&*(.9)) xdiff#=round((xsize&/(highx&-lowx&)),4) ydiff#=round((ysize&/(highy&-lowy&)),4) if xdiff#<ydiff# then diffmult#=xdiff# else diffmult#=ydiff# if xsize&>ysize& then extra&=int(xsize&*(.002)) else extra&=int(ysize&*(.002)) end if d$="" graphic color %black,%white for z&=1 to 200 x1&=z& y1&=z&+z& x2&=z&+z& y2&=z& graphic line (x1&,y1&) - (x2&,y2&) next z& if xsize&>ysize& then extra&=int(xsize&*(.0075)) else extra&=int(ysize&*(.0075)) end if graphic color %black,%yellow for z&=1 to 30 x1&=z&*10 y1&=(z&*10)+10 graphic ellipse ((x1&-extra&),(y1&-extra&)) - ((x1&+extra&),(y1&+extra&)),%black,%yellow,fillstyle& 'arc hdc&,(x1&-extra&),(y1&-extra&),(x1&+extra&),(y1&+extra&),(x1&-extra&),(y1&-extra&),(x1&-extra&),(y1&-extra&) 'arc hdc&,(x1&-extra&),(y1&-extra&),(x1&+extra&),(y1&+extra&),(x1&+extra&),(y1&+extra&),(x1&+extra&),(y1&+extra&) next z& graphic color %black,%white graphic redraw return end function
Comment