MleText window does not show text

new topic     » topic index » view thread      » older message » newer message

This program selects and displays sequences if containing a typed text.

For example: When I type the letter "S" should show all rows that have that character in anywhere.
If I type another letter, this letter joins with the first and the program is looking for new selection lines containing the two letters together.
Please, use "e" as the second letter. The MleText window is hidden if the two letters make a sequel nonexistent.

I use a window MleText, for displaying the selected sequences.
And hide this window when not in use.

But a problem is happening, the result is only shown after entering the second letter onwards.

The problem becomes more evident if uncomment the line with the instruction "sleep ()"
The code follows below,
Any response is welcome

Thanks in advance

-- 11/11/12 sintaxColor.exw 
-- separa e coloriza trecho digitado em lista de opções 
include WIN32lib.ew 
constant version="1.1" 
--        ,FONTWH={12,12} 
        ,WIN1  =create(Window,"Pedido - "&version,0,00,00,900,720,0)    -- col,lin 
        ,NOMBOX=create(MleText ,"",WIN1,240,03,420,30,                  -- cx entrada nome cliente 
                     { WS_CLIPPINGCHILD, WS_VISIBLE,WS_TABSTOP,	ES_SAVESEL ,WS_BORDER } ) 
        ,FINDNOM=create(MleText ,"",WIN1,220,55,626,240, -- *8 Para font default  
                     { WS_CLIPPINGCHILD, WS_VISIBLE,WS_TABSTOP,	ES_SAVESEL ,WS_BORDER } ) 
        ,FONE  =create(MleText ,"",WIN1,680,03,160,30,                  -- cx entrada nome cliente 
                     { WS_CLIPPINGCHILD, WS_VISIBLE,WS_TABSTOP,	ES_SAVESEL ,WS_BORDER } ) 
----------------------------------------------------------------------------------- 
setWindowBackColor( WIN1,{200,255,230}) 
setFont({FINDNOM,FONE,NOMBOX},"Courier New", 12, Bold ) -- 
setVisible(FINDNOM,0) 
setFocus(NOMBOX) 
----------------------------------------------------------------------------------- 
atom Li1,Choice 
Li1=1 
Choice=2 
sequence LisCli,Linhas,PARMS 
LisCli={"0001|sem cadastro                           |11 97222-6461" 
       ,"0002|Dudu e Isa                             |11 91234-1234" 
       ,"0003|Jerry                                  |12 91234-1234" 
       ,"0004|Alcindo e Silvana                      |12 91234-1234" 
       ,"0005|Sergio Gelli                           |11 97222-6461" 
       ,"0006|Jose Inacio                            |11 91234-1234"} 
--	------------------------------------------teste linha formatada 
------------------------     cor text, cor fundo, zero inutil, mas nao da erro 
--	block={ { { "aaaaaaa" }, {BrightWhite},{Blue},{0} }     -- linha 1 c/1 palavra    
--       , { { "aaaaaaa" }, {Blue},{BrightWhite} }         -- linha 1 c/1 palavra    
-----------------------                    text1    text2         fund 1    fund2 
--       , { { "AAAAAAA","bbBB" },        {Blue,BrightWhite},{BrightWhite   ,Red } }  -- linha 2 c/2 palavras  
-----------------------                    text1    text2  text3  fund 1 fund2 fund3 
--       , { { "AAAAAAA","bbBB","ccCC" }, {Blue,BrightWhite,0},{BrightWhite,0,Red } }  -- linha 2 c/3 palavras 
--	      } 
--	------------------------------------------fim teste 
---------------------------------------------------------------------------------------------------------- 
procedure printText(integer id,sequence block,integer colunaX, integer linhaY ) 
	integer colTempX, fontwidth, fontheight 
	atom hdc, result, pstr 
	sequence BBox, comboline, textline, text, colourline, backcolour, data  
	-- early out? 
	if length( block ) = 0 then   -- block=bloco usando o texto formatado c/TextToAnalysedLine(junk) 
		return 
	end if      
--	data = getFontSize(id)        --  
--	if length(data)=0 then data={10,10} end if 
 data={10,18}  
	fontwidth = data[1] 
	fontheight = data[2] 
	hdc = getDC( id )	                  -- ORIGINAL  get the device context 
--	hdc = getDC( WIN2 )	                  -- ORIGINAL  get the device context 
 result=	assignFont( {id,hdc})       -- Gets the device context for id with the current font installed.    
-- result=	assignFont( {WIN2,hdc})       -- Gets the device context for id with the current font installed.    
	------------------- 
	------------------- 
	-- display the text 
	------------------- 
	------------------- 
	for i = 1 to length(block) do	 
		comboline = block[i]	          -- extract data for the current line 
		textline = comboline[1]	       -- extract text for the current line 
		colourline = comboline[2]      -- extract color text for the current line 
		backcolour = comboline[3]      -- extract backGround for the current line 
		colTempX = colunaX 
		for j = 1 to length(textline) do 
			text = textline[j] 
			-- set the Pen Position 
			BBox = convPctToPixel(id, colTempX,linhaY, 0, 0) 
			result = w32Func( xSetTextColor, {hdc, colourline[j] } ) 
			result = w32Func( xSetBkColor, {hdc, backcolour[j] } ) 
			result = w32Func( xSetBkMode, {hdc, OPAQUE } ) 
			-- copy string to memory 
			pstr = w32acquire_mem(0,text ) 
			-- write out string to window/device 
			w32Proc( xTextOut, { hdc, 
               BBox[1], BBox[2],  
	         	    pstr, 
      	      	 length( text ) } ) 
			-- advance column pointer to next start pos 
			colTempX += length(text) * fontwidth  
 		-- Free the string 
	 	w32release_mem(pstr) 
		end for 
		-- advance row to next position 
		linhaY += fontheight 
	end for 
	-- replace the font with the default again 
 replaceObject( id, kFontObject, hdc,-1,ForProgram)   -- -1 = DefaultFontID  
	-- release the device context 
--	copyBlt(id, 250, 250, id) 
	releaseDC( id ) 
end procedure 
------------------------------------------------------------------------------------------------------- 
procedure fazLinha(sequence preDigi,sequence digi2,sequence posDigi,sequence data4) 
 sequence spc 
 spc={} 
 while length(spc&preDigi&digi2&posDigi&data4)<60 do 
 	spc&=" "                                            -- p/completar nome c/espaços 
	end while 
 --Linhas={ { { "aaaaaaa" }, {12345679},{987654321} }     -- linha 1 c/1 palavra    
 --    --       --       --       --     --    cores texto       cores fundo 
 --	    , { { "AAAAAAA","bbBB","ccCC" }, {   65200,12582911,0},{0,65200,12582911   } }  -- linha 2 c/3 palavras 
 if Li1=Choice then 
 	Linhas=append (Linhas,{ {preDigi,digi2,posDigi,spc&data4},{Yellow,Red,Yellow,Yellow},{Red,Yellow,Red,Red} } ) 
 else 
 	Linhas=append (Linhas,{ {preDigi,digi2,posDigi,spc&data4},{65200,Blue,65200,65200},{Blue,65200,Blue,Blue} } ) 
 end if 
 Li1+=1 
end procedure 	 
-- setVisible(FINDNOM,1)               -- abre janela FINDNOM 
-------------------------------------------------------------------------------------------------------------- 
procedure afterKeyUp(integer id, integer event, sequence parms) 
 atom zzz 
 sequence text1 
 zzz=0 
 if id!=NOMBOX  then return end if 
 if not match(sprintf("%s",{parms[1]}),"1234567890_- +/\\&@#%*()ABCDEFGHIJKLMNOPQRSTUVXYZ_abcdefghijklmnopqrstuvxyz") then 
  if parms[1]=8 then 
   -- do nothing 
  else 
   return      -- printable key em NOMBOX 
	 end if 
	end if 
 text1=getText(NOMBOX) 
 if length(text1)=0 then return end if 
 Linhas={} 
	Li1=1   
 for i=1 to length(LisCli) do 
	 event=match(upper(text1),upper(LisCli[i]))                -- event>0 = encontrou nome com texto digitado 
	 if event>0 then                                          -- encontrou texto digitado 
	  zzz=1	 
	  parms=w32trim( LisCli[i])                                -- linha que contém o texto 
   fazLinha(parms[1..event-1]	                             -- antes do digitado 
            ,text1                                         -- texto  digitado 
            ,parms[event+length(text1)..length(parms)]     -- depois do digitado 
            ,"" )     -- telefone 
	 end if 
	end for  
	if zzz=0 then 
  setVisible(FINDNOM,0) 
 else 
 	printText(FINDNOM,Linhas,03, 03) -- procedure em resources.ew 
 	copyBlt(FINDNOM, 1,1, FINDNOM) 
  if getIndex(NOMBOX)=2 then 
  end if 
 end if 
end procedure 
----------------------------------------------------------------------------------------------------------- 
procedure Nom()    -- test 
 setVisible(FINDNOM,1)               -- abre janela FINDNOM 
end procedure 
----------------------------------------------------------------------------------------------------------- 
procedure afterKEY(integer id, integer event, sequence parms) 
 afterKeyUp( id,  event,PARMS) 
-- sleep(1)         -- to see the first time, first key 
end procedure 
----------------------------------------------------------------------------------------------------------- 
procedure printableKeyNOM(integer id, integer event, sequence parms) 
-- setVisible(FINDNOM,1)               -- abre janela FINDNOM 
-- Nom()   -- test 
 setVisible(FINDNOM,1)               -- abre janela FINDNOM 
 PARMS=parms 
end procedure 
----------------------------------------------------------------------------------------------------------- 
setHandler({NOMBOX},w32HKeyPress  ,routine_id("printableKeyNOM"))  -- teclado numérico e Enter 
setHandler({NOMBOX},w32HChange  ,routine_id("afterKEY"))            -- teclado numérico e Enter 
WinMain(WIN1,Normal) 
new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu