DroopyLib

Developed or developing a new product in PureBasic? Tell the world about it.
User avatar
Droopy
Enthusiast
Enthusiast
Posts: 658
Joined: Thu Sep 16, 2004 9:50 pm
Location: France
Contact:

Re: DroopyLib

Post by Droopy »

Sorry I don't understand
So you think your "Timer" is necessary
did you agree if i add the ApiTimer functions with the example code above ?
User avatar
Bisonte
Addict
Addict
Posts: 1305
Joined: Tue Oct 09, 2007 2:15 am

Re: DroopyLib

Post by Bisonte »

Oh :oops:
I misunderstood...

Yes, of course !
PureBasic 6.21 (Windows x64) | Windows 11 Pro | AsRock B850 Steel Legend Wifi | R7 9800x3D | 64GB RAM | RTX 5080 | ThermaltakeView 270 TG ARGB | build by vannicom​​
English is not my native language... (I often use DeepL.)
Korolev Michael
Enthusiast
Enthusiast
Posts: 200
Joined: Wed Feb 01, 2012 5:30 pm
Location: Russian Federation

Re: DroopyLib

Post by Korolev Michael »

Please, add Vista administrator mode request to Droopy Lib installer. Otherwise, it doesn't install with UAC enabled.
Former user of pirated PB.
Now registered user :].
SFSxOI
Addict
Addict
Posts: 2970
Joined: Sat Dec 31, 2005 5:24 pm
Location: Where ya would never look.....

Re: DroopyLib

Post by SFSxOI »

Korolev Michael wrote:Please, add Vista administrator mode request to Droopy Lib installer. Otherwise, it doesn't install with UAC enabled.

did you right click on the installer .exe - choose 'properties' then on the General tab click "unblock" - then right click on the file again and choose "Run As Administrator" ?
The advantage of a 64 bit operating system over a 32 bit operating system comes down to only being twice the headache.
User avatar
Droopy
Enthusiast
Enthusiast
Posts: 658
Joined: Thu Sep 16, 2004 9:50 pm
Location: France
Contact:

Re: DroopyLib

Post by Droopy »

New version avalaible
Regards
13/08/12 : Library 4.61.008
Timer() Undeleted / tweaked by Bisonte
TimerKill() Undeleted / tweaked by Bisonte
SelfDelete() Tweaked (batch now self delete itself too)
PinItem() added
Using PBFastLib 4 : Installer Request Administrator mode for Windows Vista
User avatar
Droopy
Enthusiast
Enthusiast
Posts: 658
Joined: Thu Sep 16, 2004 9:50 pm
Location: France
Contact:

Re: DroopyLib

Post by Droopy »

Hello, new version avalaible :
17/08/12 : Library 4.61.009
ServiceStart() tweaked
ServiceStop() tweaked
ServiceStatus() added
ServiceConfig() added
jassing
Addict
Addict
Posts: 1885
Joined: Wed Feb 17, 2010 12:00 am

Save & restore window position/size

Post by jassing »

Here's a couple of routines I wrote (using droopy registry funcs -- you can add these to droopy lib if you want)

The idea was to make it very simple for me to store the windows position/size on window-close; and then restore it on openwindow()
The "Identifier" should be unique, but if it's missing, it will use the window title; but if you use "" as identifier, and you have multiple windows with the same title, they will all try to use the same registry entry...

Anyway; not rocket science stuff; but simple to use...
(I used the base64 encoder purely to have "one registry entry" per window.)

Code: Select all

#WindowPositionRegistryKey = "HKEY_CURRENT_USER\Software\Windows\Position"

ProcedureDLL SaveWindowPosition( hWindow.l, cIdentifier.s="" )
	Protected.RECT iWinInfo
	Protected.l nSize, bSuccess = #False
	Protected.s cKey=#WindowPositionRegistryKey, cCode=Space(30)
  
  If IsWindow_(hWindow)
    If cIdentifier = "" : cIdentifier = GetWindowTitleEx(hWindow) : EndIf
    If cIdentifier <> ""
      If GetWindowRect_(hWindow,@iWinInfo)
        nSize = Base64Encoder(@iWinInfo,SizeOf(RECT),@cCode,30)
        If nSize
          If RegCreateKey(cKey,".")
            If RegSetValue(cKey,cIdentifier,Left(cCode,nSize-2),#REG_SZ,".")
              bSuccess = #True
            EndIf
          EndIf
        EndIf
      EndIf
    EndIf
  EndIf
  ProcedureReturn bSuccess
EndProcedure

ProcedureDLL.l RestoreWindowPosition( hWindow.l, cIdentifier.s = "")
	Protected.RECT iWinInfo
	Protected.l nSize, bSuccess = #False
	Protected.s cKey=#WindowPositionRegistryKey, cCode=Space(30)
  
  If IsWindow_(hWindow)
    If cIdentifier = "" : cIdentifier = GetWindowTitleEx(hWindow) : EndIf
    If cIdentifier <> ""
      cCode = RegGetValue(cKey,cIdentifier,".")+"=="
      If cCode <> "=="
        If Base64Decoder(@cCode,Len(cCode),@iWinInfo,SizeOf(RECT))
          With iWinInfo
          	If SetWindowPos_(hWindow,#HWND_TOP,\left,\top,\right-\left,\bottom-\top,#SWP_SHOWWINDOW);
          		bSuccess = #True
            EndIf
          EndWith
        EndIf
      EndIf
    EndIf
  EndIf
  ProcedureReturn bSuccess
EndProcedure
User avatar
Droopy
Enthusiast
Enthusiast
Posts: 658
Joined: Thu Sep 16, 2004 9:50 pm
Location: France
Contact:

Re: DroopyLib

Post by Droopy »

Hello jassing, nice code.
I already used this type of code for storing window position, using flag functions of the droopylib.

Code: Select all

FlagInit("HKEY_CURRENT_USER\Software\Windows\Position")
; Save position 
FlagSet("x",WindowX(#Window))
FlagSet("y",WindowY(#Window))
User avatar
Droopy
Enthusiast
Enthusiast
Posts: 658
Joined: Thu Sep 16, 2004 9:50 pm
Location: France
Contact:

Re: DroopyLib

Post by Droopy »

Hello, new version avalaible
04/09/12 : Library 4.61.010
Between() bug fixed
EditDefaultUserRegistry help added
FastHash() added
WindowsEnum() New example
FunctionAndPointer Tips added
IsWindowEx() Function added
WebgadgetDisableScriptError() Function added
GetWebgadgetSource() Function added
MultiWindow Tips added
SendStringInit() Function added
SendString() Function added
GetPidFromHandle() Function added
Windows Example added
SeregaZ
Enthusiast
Enthusiast
Posts: 628
Joined: Fri Feb 20, 2009 9:24 am
Location: Almaty (Kazakhstan. not Borat, but Triple G)
Contact:

Re: DroopyLib

Post by SeregaZ »

dear Droopy, have you any FileSearchStop commands? i mean when user is not want to wait when search is end, press cancel button and search is stop.
User avatar
Droopy
Enthusiast
Enthusiast
Posts: 658
Joined: Thu Sep 16, 2004 9:50 pm
Location: France
Contact:

Re: DroopyLib

Post by Droopy »

@SeregaZ

No i don't have this, perhaps calling SearchFilesInit() in a thread ?
User avatar
Zebuddi123
Enthusiast
Enthusiast
Posts: 796
Joined: Wed Feb 01, 2012 3:30 pm
Location: Nottinghamshire UK
Contact:

Re: DroopyLib

Post by Zebuddi123 »

@SeregaZ

do the file search via a thread. then when the user cancels the search kill the thread and release anything allocated

Zebuddi. :lol:
malleo, caput, bang. Ego, comprehendunt in tempore
SeregaZ
Enthusiast
Enthusiast
Posts: 628
Joined: Fri Feb 20, 2009 9:24 am
Location: Almaty (Kazakhstan. not Borat, but Triple G)
Contact:

Re: DroopyLib

Post by SeregaZ »

already do, but i think killing the thread not safe. hard disk drive in this moment very active, i heard noise how it work. who knows how this killing can affect to hdd...
this code will work?

Code: Select all

Global FileSearchStop = #False

Procedure SearchFiles(Path.s,Mask.s)
  
  ;- Fill the LinkedList with the files found
  
  ; Add \ to Path if missing
  If Right(Path,1)<>"\" : Path+"\":EndIf
  
  ; Apply Structure
  lpFindFileData.WIN32_FIND_DATA
  
  ; Add Filter *.*
  Recherche.s=Path+Mask
  
  ; Initiate the Search
  Handle.l = FindFirstFile_(Recherche, @lpFindFileData)
  
  ; If search succeeds
  If Handle <> #INVALID_HANDLE_VALUE
    
    Repeat
      
      ; Trouve = File or Directory Found
      Trouve.s=PeekS(@lpFindFileData\cFileName)
      
      ; This is a not a directory
      If lpFindFileData\dwFileAttributes & #FILE_ATTRIBUTE_DIRECTORY =#False
        
        ; Display File found
        AddElement(Fichiers.s())
        Fichiers()=Path+Trouve
        ;Debug "--> "+Path+Trouve
        
      EndIf
      
      ; Exit when there is no more files
    Until FileSearchStop = #True Or FindNextFile_(Handle, @lpFindFileData)= #False
    
    ; Close the Api search Function
    if Handle
      FindClose_(Handle)
    Endif
    
  EndIf
  
  
EndProcedure
Global FileSearchStop = #False
***
Until FileSearchStop = #True Or FindNextFile_(Handle, @lpFindFileData)= #False

; Close the Api search Function
if Handle
FindClose_(Handle)
Endif
of course for applying and avoid conflict with droopy library i need to change name of fuctions. it will stop search process without killing thread?
and for SearchDirectory(Path.s,Mask.s) too.



and one more question - can GetSpecialFolderLocation shows path to "Programm Files (86)" in 64bits windows system? when my programm will be launch on 64bit - it will start wrong iexplorer - 64bit, but i need to start 32bit iexplorer when system is 64bit.
User avatar
Droopy
Enthusiast
Enthusiast
Posts: 658
Joined: Thu Sep 16, 2004 9:50 pm
Location: France
Contact:

Re: DroopyLib

Post by Droopy »

For FileSearchStop looking this in the next release.

For PFx86 you can use

Code: Select all

GetEnvironmentVariable("ProgramFiles(x86)")
Or 'Known Folders' (SHGetKnownFolderPath) can do this : see http://msdn.microsoft.com/en-us/library ... s.85).aspx
SeregaZ
Enthusiast
Enthusiast
Posts: 628
Joined: Fri Feb 20, 2009 9:24 am
Location: Almaty (Kazakhstan. not Borat, but Triple G)
Contact:

Re: DroopyLib

Post by SeregaZ »

i cant see function for webshortcut. if you not have it - maybe my is fit?

Code: Select all

ProcedureDLL CreateWebShortcut(Path.s,WebLink.s)
  
  If CreateFile(0, Path)
    WriteStringN(0, "[InternetShortcut]")
    WriteStringN(0, "URL="+WebLink)
    CloseFile(0)
    Result = 1
  EndIf
  
  ProcedureReturn Result
EndProcedure

CreateWebShortcut("c:\PureBasic site.url","http://www.purebasic.fr")
web shortcut have hot key option too, but i dont know what key what code...
Hotkey=1617 for example is Ctrl + Alt + Q


and i have some problem with Windows 7. my install makes shortcut in start menu - programs. in XP all looks fine. on W7 - in big first menu fine, in programs looks like my shortcut not have ico:
Image

so if i see properties, and press the change icon button, but i am nothing change, just press OK - in this start menu starting show normal with icon, like it must show.
Post Reply