1. Please some help Drag'n'Drop almost works but Error stops programme ?

Hello
Selgor here

The following is an error message when shortcut is dropped on window after dragging.

C:\EUPHORIA\include\Win32lib.ew:6303 in function addLVItem()
type_check failure, id is {21,3}
id = {21,3}
iIcon = 3
text = {
{112'p',111'o',119'w',101'e',114'r',100'd',101'e',115's',107'k',
46'.',114'r',116't',102'f'}
}
lParam = <no value>
iItem = <no value>
LV_ITEM = <no value>
i = <no value>
i = <no value>
... called from C:\Euphoria\quicklauncher\QuickLauncher.exw:179 in procedure additems()
FileName = {67'C',58':',92'\',68'D',111'o',99'c',117'u',109'm',101'e',
110'n',116't',115's',32' ',97'a',110'n',100'd',32' ',83'S',101'e',116't',
116't',105'i',110'n',103'g',115's',92'\',65'A',100'd',109'm',105'i',110'n',
105'i',115's',116't',114'r',97'a',116't',111'o',114'r',92'\',68'D',101'e',
115's',107'k',116't',111'o',112'p',92'\',112'p',111'o',119'w',101'e',114'r'100'd',101'e',1
15's',107'k',46'.',114'r',116't',102'f'}
ico = 3
at = <no value>
size = 2
key = 4
Name = {112'p',111'o',119'w',101'e',114'r',100'd',101'e',115's',107'k',
46'.',114'r',116't',102'f'}
Ext = {114'r',116't',102'f'}
seq = {
{112'p',111'o',119'w',101'e',114'r',100'd',101'e',115's',107'k',
46'.',114'r',116't',102'f'},
{114'r',116't',102'f'}
}
filename = <no value>

And it goes further on ............

The window appears with tabs
I can drag a shortcut to the window
But when shortcut is dropped ......... the error appears.

The systray icon is visible in the tray.

And when the programme is re-run after crash the icon of shortcut is visible
but will not execute programme of shortcut on mouse click

Yet right clicking iconj allows context menu to delete icon

It seems to want to work but doesn't????

I'm wondering if anyone can spot the programming error in the code

The following is the code for the progr5amme

I have shown the place where the error occurs with tyhe following

------------------------*------------------------
-------------------------*-----------------------

It's a fair way down.

I'm using winXP, Euphoria 3.1 , ans a previous win32LIB that works for all my other programmes

The programme :-

 
 
include Win32lib.ew 
include CreateLink.ew 
include hotkey.e 
include systray.ew 
include reg.ew 
include database.e 
include inputbox.ew 
include startpath.e 
include file.e 
include win32ini.ew 
without warning 
 
-------------------------------------------------------------------------------- 
--------------- custom your own parameters here--------------------------------- 
integer Width ,Height 
sequence Font, HotKeys 
Width =400   Height= 200---Window's default width and height 
Font  = {"Times New Roman",10,Normal} 
HotKeys={{8,81}, ---Win + Q  --Alt=1,Ctrl=2,Shift=4,Win=8 
         {0,192},       ---192 is the key upper to the Tab 
         {0,106}}       ---106 is the multiply key in number pad 
--------------- file names------------------------------------------------ 
sequence AppDirectroy AppDirectroy =startup_dir() 
constant datafile=AppDirectroy&"userdata.edb" 
constant runfile=AppDirectroy&"QuickLauncher.exw" 
constant systrtayicon=AppDirectroy&"systray.ico" 
constant defaulticon=AppDirectroy&"default.ico" 
constant appsetting=AppDirectroy&"config.ini" 
constant helpfile=AppDirectroy&"readme.txt" 
-------------------------------------------------------------------------------- 
sequence data 
if compare(dir(appsetting),-1)=0 then 
    WritePrivateProfileString("WindowSize","Width",sprint(Width),appsetting) 
    WritePrivateProfileString("WindowSize","Height",sprint(Height),appsetting) 
    WritePrivateProfileString("HotKeys","hotkey",sprint(HotKeys),appsetting) 
else 
    data=value(getString("WindowSize","Width",appsetting)) 
    if data[1]=GET_SUCCESS then Width=data[2] end if 
    data=value(getString("WindowSize","Height",appsetting)) 
    if data[1]=GET_SUCCESS then Height=data[2] end if 
    data=value(getString("HotKeys","hotkey",appsetting)) 
    if data[1]=GET_SUCCESS then HotKeys=data[2] end if 
end if 
-------------------------------------------------------------------------------- 
integer Left,Top,X,Y,moveWindow moveWindow=0 
sequence ScreenSize, rect 
ScreenSize = getRect(Screen) 
Left=(ScreenSize[3]-Width)/2 
Top=(ScreenSize[4]-Height)/2 
constant QuickLauncher_Parent=create( Window,"QuickLauncher",0,0,0,50,50,WS_POPUP) 
constant QuickLauncher = createEx( Window, "QuickLauncher", QuickLauncher_Parent,Left, Top, Width, Height ,{WS_POPUP, WS_THICKFRAME},WS_EX_TOPMOST) 
--setIcon( QuickLauncher,"thounder.ico") 
constant SysTray = systray_Create(QuickLauncher) 
systray_SetIcon(SysTray,systrtayicon) 
systray_SetTip(SysTray,"QuickLauncher") 
constant tabControl = createEx( TabControl, "TabControl", QuickLauncher, 0, 28, 460, 280, 0, 0 ) 
constant menu      =  create(Popup,"",QuickLauncher,0,0,0,0,0), 
         menu1     =  create(MenuItem,"New Page",menu,0,0,0,0,0), 
         menu2     =  create(MenuItem,"Delete Page",menu,0,0,0,0,0), 
         menu3     =  create(MenuItem,"Rename Page",menu,0,0,0,0,0), 
         sep1      =  create(MenuItem,"-", menu, 0, 0, 0, 0, 0), 
         menu4     =  create(MenuItem,"New Item",menu,0,0,0,0,0), 
         menu5     =  create(MenuItem,"Delete Item",menu,0,0,0,0,0), 
         menu6     =  create(MenuItem,"Rename Item",menu,0,0,0,0,0), 
         menu7     =  create(MenuItem,"Relink Item",menu,0,0,0,0,0), 
         sep2      =  create(MenuItem,"-", menu, 0, 0, 0, 0, 0), 
         menu8     =  create(MenuItem,"Help",menu,0,0,0,0,0), 
         menu9     =  create(MenuItem,"Hide",menu,0,0,0,0,0), 
         menu10    =  create(MenuItem,"Exit",menu,0,0,0,0,0) 
-------------------------------------------------------------------------------- 
constant Shell32 = open_dll("Shell32.dll") 
constant SHGetFileInfo = define_c_proc(Shell32,"SHGetFileInfo",{C_POINTER,C_UINT,C_POINTER,C_UINT, C_INT}) 
constant 
        SHGFI_ICON =             #000000100,     -- get icon 
        SHGFI_DISPLAYNAME =      #000000200,     -- get display name 
        SHGFI_TYPENAME =         #000000400,     -- get type name 
        SHGFI_ATTRIBUTES =       #000000800,     -- get attributes 
        SHGFI_ICONLOCATION =     #000001000,     -- get icon location 
        SHGFI_EXETYPE =          #000002000,     -- return exe type 
        SHGFI_SYSICONINDEX =     #000004000,     -- get system icon index 
        SHGFI_LINKOVERLAY =      #000008000,     -- put a link overlay on icon 
        SHGFI_SELECTED =         #000010000,     -- show icon in selected state 
        SHGFI_ATTR_SPECIFIED =   #000020000,     -- get only specified attributes 
        SHGFI_LARGEICON =        #000000000,     -- get large icon 
        SHGFI_SMALLICON =        #000000001,     -- get small icon 
        SHGFI_OPENICON =         #000000002,     -- get open icon 
        SHGFI_SHELLICONSIZE =    #000000004,     -- get shell size icon 
        SHGFI_PIDL =             #000000008,     -- pszPath is a pidl 
        SHGFI_USEFILEATTRIBUTES = #000000010     -- use passed dwFileAttribute 
 
global function GetIcon(sequence strPath, atom bSmall) 
    sequence info 
    atom path,infoptr,hicon, cbFileInfo,flags 
    path=allocate_string(strPath) 
    cbFileInfo= 32  
    infoptr=allocate(256) 
    if bSmall then 
        flags =or_bits(SHGFI_ICON,SHGFI_SMALLICON) 
    else 
        flags =or_bits(SHGFI_ICON,SHGFI_LARGEICON) 
    end if 
    c_proc(SHGetFileInfo,{path, 256,infoptr,cbFileInfo,flags}) 
    hicon=peek4s(infoptr) 
    free(path) 
    free(infoptr) 
    return addIcon(hicon) 
end function 
function getico(sequence FileName) 
    integer ico 
    if compare(dir(FileName),-1)=0 then  
           ico=GetIcon(defaulticon,0) 
    else ico=GetIcon(FileName,0) end if 
    return ico 
end function 
------------------------------------------------------------------------------- 
global procedure setLVItemSelected( integer LV, integer pRow, integer pColumn, atom selected) 
atom LV_ITEM 
object VOID     
    LV_ITEM = struct_LVITEM(LVIF_STATE, pRow, pColumn, selected, 1, 0, 0, 0)     
    VOID = sendMessage( LV, LVM_SETITEMSTATE, pRow-1, LV_ITEM )     
    release_mem(LV_ITEM)     
end procedure 
-------------------------------------------------------------------------------- 
sequence tabitems,names,listviews 
atom ok, err 
ok=DB_OK 
integer currentview 
currentview=1 
tabitems={} listviews={} 
-------------------------------------------------------------------------------- 
function getfilenameandextension(sequence filename) 
    sequence s,f,e 
    integer i,j 
    s=reverse(filename) 
    i=find('\\',s) 
    if i!=1 then 
       f=reverse(s[1..i-1]) 
    else 
       f=filename 
    end if 
    j=find('.',s) 
    if j=0 then j=1 end if 
    e=reverse(s[1..j-1]) 
    return {f,e} 
end function 
procedure showitems(integer index) 
    integer ico,at 
    sequence seq 
    if db_select_table(getHint(tabitems[index])) = DB_OK then 
        for i=db_table_size() to 1 by -1 do 
          seq=db_record_data(i) 
          ico=getico(seq[2]) 
          at=addLVItem(listviews[index],ico,{seq[1]}) 
        end for 
    end if 
end procedure 
procedure additems(sequence FileName) 
      integer ico,at,size,key 
      sequence Name,Ext,seq,filename 
      seq=getfilenameandextension(FileName) 
      Name=seq[1] 
      Ext =seq[2] 
      if compare(lower(Ext),"lnk")=0 then 
          filename=resolve_link(FileName) 
          seq=getfilenameandextension(filename) 
          at=deleteFile(FileName) 
          Name=seq[1] 
          FileName=filename 
      end if 
      ico=getico(FileName) 
      if db_select_table(getHint(tabitems[currentview])) = DB_OK then 
          size=db_table_size() 
          if size=0 then key=1 else 
          key=db_record_key(size)+1 end if 
          ok=db_insert(key, {Name, FileName}) 
          at=addLVItem({listviews[currentview],size+1},ico,{Name}) 
      end if 
end procedure 
procedure deleteitems() 
      integer re 
      sequence pos 
      object ctrl 
      ctrl=listviews[currentview] 
          pos=getIndex(ctrl) 
          if length(pos) and db_select_table(getHint(tabitems[currentview])) = DB_OK then 
              --for i=1 to length(pos) do 
                 db_delete_record(pos[1]) 
                 re=deleteItem(ctrl,pos[1]) 
                 --refreshWindow(ctrl) 
              --end for 
          end if 
end procedure 
-------------------------------------------------------------------------------- 
procedure TabItem_onClick (integer self, integer event, sequence params)--params is () 
    setFocus(self) 
    currentview=find(self,tabitems) 
end procedure 
procedure ListView_onClick (integer self, integer event, sequence params)--params is () 
      sequence item,seq 
      atom al 
      item = getIndex(self) 
      if length(item) and db_select_table(getHint(tabitems[currentview])) = DB_OK then 
          seq=db_record_data(item[1]) 
          setVisible(QuickLauncher,False) 
          al=chdir(file_dir(seq[2])) 
          shellExecute("open",seq[2],SW_SHOWNORMAL) 
      end if 
end procedure 
procedure QuickLauncher_onKeyDown (integer self, integer event, sequence params)--params is ( atom scanCode, atom shift ) 
      atom scanCode,shift 
      scanCode=params[1] 
      if scanCode=VK_DELETE then 
          deleteitems() 
      elsif scanCode=VK_RETURN then 
          ListView_onClick(listviews[currentview],4,{}) 
      end if 
end procedure 
setHandler( {QuickLauncher,tabControl}, w32HKeyDown, routine_id("QuickLauncher_onKeyDown")) 
 
 
--------------------------------------******************************************************-------------------------------------------- 
-------------------------------------******************************************************--------------------------------------------- 
------------------          where error message is incurred   
 
 
 
procedure QuickLauncher_onMouse (integer self, integer event, sequence params)--params is ( int event, int x, int y, int shift ) 
    int x, y 
    sequence it 
    it={}--hitTestLV(self) 
    x=params[2] 
    y=params[3] 
    if params[1] = RightDown then 
        popup( menu, x, y ) 
    elsif params[1] = LeftDown and self=tabControl then 
        X=x 
        Y=y 
        moveWindow=1 
    elsif params[1] = MouseMove then 
          if moveWindow=1 then 
              Left+=x-X 
              Top+=y-Y 
              setRect(QuickLauncher,Left, Top,Width, Height,True) 
          else 
 
-----------------------------------------------------**********************************************---------------------------------------------- 
------------- if I leave the following line in ......... then NOTHING happens ------------------------- 
           
         --it=hitTestLV(self)   
 
------------------------------  so ???          
              
 
            if length(it)=2 then 
              setFocus(self) 
              setLVItemSelected(self,it[1],it[2],1) 
              end if 
          end if 
    elsif params[1] = LeftUp then 
        moveWindow=0 
    end if 
end procedure 
setHandler( tabControl, w32HMouse, routine_id("QuickLauncher_onMouse")) 
 
 
--------------------------------------*****************************************------------------------------------------ 
--------------------------------------*****************************************------------------------------------------ 
 
 
procedure QuickLauncher_onOpen (integer self, integer event, sequence params)--params is () 
    if compare(dir(datafile),-1)=0 then 
            ok=db_create(datafile,DB_LOCK_NO) 
            ok=db_create_table("System") 
            ok=db_create_table("Text") 
            ok=db_create_table("Media") 
            ok=db_create_table("Web") 
    end if 
    ok=db_open(datafile, DB_LOCK_NO) 
    if ok=DB_OK then 
        rect = getClientRect( QuickLauncher ) 
        setRect(tabControl,rect[1], rect[2], rect[3], rect[4],True) 
        rect = getClientRect( tabControl ) 
        names = db_table_list() 
        for i = 1 to length(names) do 
            tabitems &= createEx( TabItem, names[i], tabControl, 0, 0, 0, 0, 0, 0 ) 
            setHint(tabitems[i],names[i]) 
            listviews &= createEx( ListView, {"ListView",""}, tabitems[i], rect[1], 20, rect[3], rect[4],or_all({LVS_ICON,LVS_SHOWSELALWAYS}),0) 
            showitems(i) 
            setHandler( tabitems[i], w32HClick, routine_id("TabItem_onClick")) 
            setHandler( listviews[i], w32HClick, routine_id("ListView_onClick")) 
            setHandler( listviews[i], w32HKeyDown, routine_id("QuickLauncher_onKeyDown")) 
            setHandler( listviews[i], w32HMouse, routine_id("QuickLauncher_onMouse")) 
        end for 
        setFocus(tabitems[1]) 
    end if 
    for i=1 to length(HotKeys) do 
         setHotKey(QuickLauncher, i, HotKeys[i][1],HotKeys[i][2] ) 
    end for 
    systray_Show(SysTray) 
    setFont(QuickLauncher,Font[1],Font[2],Font[3]) 
    err = regSetValue( 
                "HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\Run", -- key 
                "QuickLauncher",                                     -- name 
                 runfile)                                         -- value 
end procedure 
setHandler( QuickLauncher, w32HOpen, routine_id("QuickLauncher_onOpen")) 
-------------------------------------------------------------------------------- 
procedure PopupItem_onClick (integer self, integer event, sequence params)--params is () 
    sequence name,filename,pos,seq,new_name 
    object control 
    integer n,m 
        setEnable(listviews[currentview],False) 
        setEnable(listviews[currentview],True) 
    if  self = menu1 then 
         name = input_box("Enter a name for your new page",QuickLauncher) 
         if compare(name,"")!=0 then 
         ok=db_create_table(name) 
         tabitems &= createEx( TabItem, name, tabControl, 0, 0, 0, 0, 0, 0 ) 
         n=length(tabitems) 
         setHint(tabitems[n],name) 
         listviews &= createEx( ListView, {"ListView",""}, tabitems[n], rect[1], 20, rect[3], rect[4],or_all({LVS_ICON,LVS_SHOWSELALWAYS}),0) 
         setHandler( tabitems[n], w32HClick, routine_id("TabItem_onClick")) 
         setHandler( listviews[n], w32HClick, routine_id("ListView_onClick")) 
         setHandler( listviews[n], w32HKeyDown, routine_id("QuickLauncher_onKeyDown")) 
         setHandler( listviews[n], w32HMouse, routine_id("QuickLauncher_onMouse")) 
         currentview=n 
         end if 
    elsif self = menu2 then 
          name=getHint(tabitems[currentview]) 
          m=getLVCount(listviews[currentview]) 
          if m=0 or (m>0 and 
             message_box("All the items in page "&name&" will be deleted, are you sure?","Message",{MB_YESNO, MB_ICONQUESTION})=IDYES) then 
               db_delete_table(name) 
               destroy(tabitems[currentview]) 
               tabitems=tabitems[1..currentview-1]&tabitems[currentview+1..length(tabitems)] 
               listviews=listviews[1..currentview-1]&listviews[currentview+1..length(listviews)] 
               n=length(tabitems) 
               if currentview>n then currentview=n end if 
          end if 
    elsif  self = menu3 then 
         control=tabitems[currentview] 
         name=getHint(control) 
         new_name = input_box("Enter new name for page "&name,QuickLauncher) 
         if compare(new_name,"")!=0 then 
         db_rename_table(name,new_name) 
         db_close() 
         --setTabItemText(tabControl,currentview,new_name) 
         shellExecute("open",runfile,SW_SHOWNORMAL) 
         closeWindow(QuickLauncher) 
         --setText(tabitems[currentview],new_name) 
         --setHint(control,new_name) 
         end if 
    elsif self = menu4 then  
          filename = getOpenFileName(QuickLauncher,"",{"All Files", "*.*" } ) 
          if compare(filename,"")!=0 then 
              additems(filename) 
          end if 
    elsif self = menu5 then 
          deleteitems() 
    elsif self = menu6 then 
         control=listviews[currentview] 
         pos=getIndex(control) 
         if length(pos) and db_select_table(getHint(tabitems[currentview])) = DB_OK then 
              name=getLVItemText(control,pos[1],1) 
              name = input_box("Enter new name for item "&name,QuickLauncher) 
              if compare(name,"")!=0 then 
                  seq=db_record_data(pos[1]) 
                  setLVItemText(control,pos[1],1,name) 
                  db_replace_data(pos[1],{name,seq[2]}) 
              end if 
         end if 
    elsif self = menu7 then 
         control=listviews[currentview] 
         pos=getIndex(control) 
         if length(pos) and db_select_table(getHint(tabitems[currentview])) = DB_OK then 
              name=getLVItemText(control,pos[1],1) 
              name = input_box("Enter new link for item "&name,QuickLauncher) 
              if compare(name,"")!=0 then 
                  seq=db_record_data(pos[1]) 
                  db_replace_data(pos[1],{seq[1],name}) 
                  --setIcon(pos[1],GetIcon(name,0)) 
              end if 
         end if 
    elsif self = menu8 then 
        shellExecute("open",helpfile,SW_SHOWNORMAL) 
        setVisible(QuickLauncher,False) 
    elsif self = menu9 then 
        setVisible(QuickLauncher,False) 
    elsif self = menu10 then 
        closeWindow(QuickLauncher) 
    end if 
end procedure 
setHandler({menu1,menu2,menu3,menu4,menu5,menu6,menu7,menu8,menu9,menu10}, w32HClick, routine_id("PopupItem_onClick")) 
-------------------------------------------------------------------------------- 
procedure QuickLauncher_onDragAndDrop (integer self, integer event, sequence params)--params is ( int id, sequence FileName ) 
     additems(params[2]) 
end procedure 
setHandler( QuickLauncher, w32HDragAndDrop, routine_id("QuickLauncher_onDragAndDrop")) 
-------------------------------------------------------------------------------- 
procedure QuickLauncher_onHotKey(atom id) 
    setVisible(QuickLauncher,not isVisible(QuickLauncher)) 
end procedure 
onHotKey = routine_id("QuickLauncher_onHotKey") 
-------------------------------------------------------------------------------- 
procedure onsystray(integer id, atom message) 
    sequence mpos 
    if message= WM_LBUTTONDOWN then 
        setVisible(QuickLauncher,not isVisible(QuickLauncher))  
    elsif message= WM_RBUTTONDOWN then 
        mpos=getMousePos () 
        popup( menu, mpos[1],mpos[2] ) 
    end if 
end procedure 
systray_SetEvent(SysTray,routine_id("onsystray")) 
--------------------------------------------------------------------------------- 
procedure QuickLauncher_onGotFocus (integer self, integer event, sequence params)--params is () 
refreshWindow(QuickLauncher) 
end procedure 
setHandler( QuickLauncher, w32HGotFocus, routine_id("QuickLauncher_onGotFocus")) 
-------------------------------------------------------------------------------- 
procedure QuickLauncher_onClose (integer self, integer event, sequence params)--params is () 
    db_close() 
    for i=1 to length(HotKeys) do 
         killHotKey(QuickLauncher,i) 
    end for 
    systray_Hide(SysTray) 
end procedure 
setHandler( QuickLauncher, w32HClose, routine_id("QuickLauncher_onClose")) 
-------------------------------------------------------------------------------- 
WinMain( QuickLauncher,Normal ) 
 


Please, any help appreciated

Cheers

Selgor

new topic     » topic index » view message » categorize

2. Re: Please some help Drag'n'Drop almost works but Error stops programme ?

Just a suggestion, may not be a good or sufficient one, but in your procedure "procedure additems", which apparently calls the erroring function in Win32Lib, just before you call the add LVitem, print out your variable "at", to see what it looks like when a working item is dragged, as opposed to when a NON-working item item is dragged. I say this because clearly the addLVitem function in Win32Lib doesn't like what you're passing it when you drag a shortcut.

Dan

new topic     » goto parent     » topic index » view message » categorize

3. Re: Please some help Drag'n'Drop almost works but Error stops programme ?

Hello DanM.

Selgor here

You are correct in your analysis.
The window comes up
But, as soon as the mouse pointer hits the window ERROR

So, it is the "new" win32LIB not working with the proggie

Thanks Dan.

Cheers

Selgor.

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu