1. Win32lib will not let run Another great Learning Programme ... WHY??
- Posted by Selgor Jun 02, 2010
- 1192 views
Hello,
Selgor here.
I seem to be finding many programmes that do not work with winlib32.
I thought that one added to a collection to keep all working. Not "change" and so the old no longer work.
But, it would seem that "changes" have made some of the OLD code obsolete.
The following is a work and a half. Great.
But, even with all the additions of the include files in the necessary and relevant parts it does not.
Namespace a problem
Line 239 is "undeclared".
Why ?
Can anyone help?
There is just so much learning in this code.
BUT, it will not work in new winlib ????
I am .... Just trying to learn ??
Thanks, Selgor.
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")) procedure QuickLauncher_onMouse (integer self, integer event, sequence params)--params is ( int event, int x, int y, int shift ) int x, y sequence it 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 -- it=hitTestLV(self) -- if length(it)=2 then -- setFocus(self) -- setLVItemSelected(self,it[1],it[2],1) 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 )
2. Re: Win32lib will not let run Another great Learning Programme ... WHY??
- Posted by DerekParnell (admin) Jun 02, 2010
- 1152 views
I seem to be finding many programmes that do not work with winlib32.
It looks like you are using a very old version of Win32lib.
I thought that one added to a collection to keep all working. Not "change" and so the old no longer work.
But, it would seem that "changes" have made some of the OLD code obsolete.
Are you trying to use Euphoria 3.1 or Euphoria 4-beta?
Namespace a problem
Line 239 is "undeclared".
Why ?
What is 'undeclared'? Is it hitTestLV? If so, you are using an old version of win32lib.
BUT, it will not work in new winlib ????
I really think you are using an old version of the library and not a new version.