Re: How to solve LOGIC ERROR: Held resource owner
- Posted by sergelli Oct 11, 2011
- 37419 views
DerekParnell said...
If you've got a minimal sample program that demonstrates the problem I'd appreciate testing it here.
Sorry, this is the smallest "code" I could do.
He is configured to do the error mentioned
Attention to the lines enveloped between the lines equal to this
------------*******************************************------------ code lines ------------*******************************************------------
is where the problem can be solved or created
include Win32lib.ew global integer fontSize,hasOptionsChanged hasOptionsChanged=-1 -------------------------------------------------------------------------------------------------- fontSize=12 constant fontsizelist ={20,8,9,10,11,12,13,14,15,16,17,18,19,20} ,fontname="Courier New" -- tem que usar esta fonte ------------------------------------------------------------------------------- global constant MAIN = create( Window, "MAIN Window ", 0, 120, 70, 900, 600, 0) ,MLE = create( LText, "", MAIN, 222, 111, 510, 220, 0 ) -- MLE = janela de edicao ,OPTIONSWINDOW = create( Window, "Options", MAIN, 20, 370, 600, 400,{ WS_DLGFRAME, WS_SYSMENU}) ,FONTSIZELIST =create( List, "Font Sizes", OPTIONSWINDOW, 280, 20, 45, 75, 0 ) ------------------------------------------------------------------------------------ procedure writeAnyThing(atom id, atom sz, sequence text) setPenColor( id, 4 ) setFocus(id) setVisible(id,1) setFont(id, fontname, sz, Normal) ------------*******************************************------------ -- This below line, solve the problem , but I need the "Courier New" -- if id=MLE then setFont(id, "Arial", sz, Normal) end if ------------*******************************************------------ wPuts(id,text) end procedure ------------------------------------------------------------------------------------ procedure paint_preview() -- entirely re-create preview panel using current values sequence data integer fontwidth, fontheight data = getFontSize(OPTIONSWINDOW) data = getFontSize(MLE) fontwidth = data[1] fontheight = data[2] setPosition(MLE ,0,0) setIndex(MLE,1) setWindowBackColor(MLE, BrightWhite) writeAnyThing(MLE,fontSize," Ia Ia Ia Ia Ia Ia Ia Ia ") setWindowBackColor( OPTIONSWINDOW, BrightWhite) setPosition(OPTIONSWINDOW ,10,100) writeAnyThing(OPTIONSWINDOW,fontSize,"ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ") end procedure ---------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------- function get_fontsize() integer junk junk = getIndex(FONTSIZELIST) if not junk then return fontSize else return fontsizelist[junk] end if end function ------------------------------------------------------------------------------- global procedure showsResultAfterSelectingFont(integer x, integer y, sequence z) fontSize = get_fontsize() -- get fontSize selected paint_preview() end procedure --------------- setHandler(FONTSIZELIST, w32HChange,routine_id("showsResultAfterSelectingFont")) ------------------------------------------------------------------------------- global procedure on_open_OPTIONS(integer x, integer y, sequence z) eraseItems ( FONTSIZELIST ) for i = 1 to length(fontsizelist) do addItem( FONTSIZELIST, sprintf("%d", fontsizelist[i]) ) end for showsResultAfterSelectingFont(0,0,"") end procedure -------------------------------------------------------------------------------- setHandler(OPTIONSWINDOW, w32HOpen,routine_id("on_open_OPTIONS")) ------------*******************************************------------ -- here (below) happens the error setHandler(OPTIONSWINDOW, w32HPaint,routine_id("showsResultAfterSelectingFont")) -- You can comment the line above, but the window "MLE" do not -- will show words when open in the first time ------------*******************************************------------ -------------------------------------------------------------------------------- procedure closeOPTIONSWINDOW(integer x, integer y, sequence z) hasOptionsChanged=0 setFocus(MLE) setVisible(MLE,0) setPosition(MLE,10,10) setIndex(MLE,30) writeAnyThing(MLE,30,"final do programa ") end procedure --------------------------------------------------------------------------------- setHandler(OPTIONSWINDOW, w32HClose,routine_id("closeOPTIONSWINDOW")) --------------------------------------------------------------------------------- function OptionsHaveChanged() integer temp openWindow(OPTIONSWINDOW, Normal) while 1 do doEvents(0) -- allows other events SetHandler to work if hasOptionsChanged != -1 then -- otherwise will be in eternal loop closeWindow(OPTIONSWINDOW) temp = hasOptionsChanged hasOptionsChanged = -1 return temp end if end while end function --------------------------------------------------------------------------------- procedure onClickMain(integer x, integer y, sequence z) x=OptionsHaveChanged() -- stands still here, even the program to return this function end procedure --------------------------------------------------------------------------------- setHandler(MAIN, w32HClick,routine_id("onClickMain")) --------------------------------------------------------------------------------- procedure onOpenMain(integer x, integer y, sequence z) setWindowBackColor( MLE, BrightWhite) setFont( MAIN, "Courier New", 20, Bold ) setFont( MLE, "Arial", 20, Bold ) setPosition(MAIN,10,10) writeAnyThing( MAIN, 20, "Click on anywhere gray color of the window" ) end procedure ------------------------------------------------------------------------------------- setHandler(MAIN, w32HPaint,routine_id("onOpenMain")) WinMain( MAIN,Normal )