AChoice GUI ... how ?

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
User avatar
AUGE_OHR
Posts: 2060
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

AChoice GUI ... how ?

Post by AUGE_OHR »

hi,

the benefit of AChoice are 6th Parameter alCanSelect

under Xbase++ i have made a own CLASS FROM and use Ownerdraw for disable Item and hilight possible Device.
AChoice.jpg
AChoice.jpg (31.32 KiB) Viewed 2718 times
now i think about a harbour / HMG Solution but it have no Owerdraw so i search for other Solution.

the Problem is how to make a Row "unselect-able" :idea:
ok i can check it at ON ENTER but i don´t want that User "canselect" e.g. "C:" to eject Device.
"not show" those Device is not a Option ...

so which Control to use ... GRID :idea:
i think ON CHANGE is the point to start and than ...
have fun
Jimmy
franco
Posts: 816
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

Re: AChoice GUI ... how ?

Post by franco »

Jimmy. I think for what you are asking,
I use a browse for scanning and a grid for working in.
I remember on one of your posts you said a grid and browse where the same, they are not.
They use the same functions but react different. Browse is much faster for scanning large tables or arrays.
All The Best,
Franco
Canada
User avatar
AUGE_OHR
Posts: 2060
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: AChoice GUI ... how ?

Post by AUGE_OHR »

franco wrote: Thu Feb 06, 2020 5:39 pm I remember on one of your posts you said a grid and browse where the same, they are not.
They use the same functions but react different. Browse is much faster for scanning large tables or arrays.
have a look into

Code: Select all

C:\hmg.3.4.4\SOURCE\c_browse.c
C:\hmg.3.4.4\SOURCE\c_grid.c
and search for Constant WC_LISTVIEW ( ClassName "SysListView32" )
the "Engine" is the same but it act in different Way.

the fastest Way is IMHO to use VIRTUAL where you "just" tell Window to "reserve Memory" with

Code: Select all

ITEMS aArray       // must be PRIVATE or PUBLIC if change 
ITEMCOUNT LEN( aArray )
---

i got a Solution which can be used

Code: Select all

STATIC PROCEDURE DoAction()
LOCAL nRow   := This.CellRowIndex
LOCAL nType  := VAL( Win_1.Grid_Device.CellEx( This.CellRowIndex, 2 ) )
LOCAL cDrive := aDrives[ nRow ] [ 2 ]

   IF nType = DRIVE_REMOVABLE .OR. nType = DRIVE_CDROM
      EjectMedia( cDrive, .T. )
   ENDIF
RETURN
that is not exact what i want but it work right so it is ok.
hb_Eject.jpg
hb_Eject.jpg (56.6 KiB) Viewed 2637 times
but i can`t release that Tool without "safe-remove"
i still have Problem to include PREVENT_MEDIA_REMOVA Structure
https://docs.microsoft.com/de-de/window ... ia_removal
have fun
Jimmy
User avatar
AUGE_OHR
Posts: 2060
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: AChoice GUI ... how ?

Post by AUGE_OHR »

hi

i found this
https://autohotkey.com/board/topic/2862 ... sh-drive/
; Enables or disables the mechanism that ejects media, for those devices possessing that locking capability.
; Drivers keep track of the lock count, and thereby allow ANY caller to unlock a drive (not just the one that locked it). See more at http://msdn.microsoft.com/en-us/library/ms803649.aspx

Code: Select all

PreventRemovalOfVolume(hVolume, fPreventRemoval)
{
    ; struct PREVENT_MEDIA_REMOVAL is just a single bool
    PMRBuffer := chr(fPreventRemoval ? 1 : 0)

    return DeviceIoControl(hVolume, IOCTL_STORAGE_MEDIA_REMOVAL := 0x2D4804, PMRBuffer, 1)
}
this sample dow not use PREVENT_MEDIA_REMOVAL Structure as "is just a single bool"
as bool can be 0 or 1 -> CHR(0) or CHR(1) :idea:

it seems to work :D but i have to make some more test
have fun
Jimmy
User avatar
danielmaximiliano
Posts: 2611
Joined: Fri Apr 09, 2010 4:53 pm
Location: Argentina
Contact:

Re: AChoice GUI ... how ?

Post by danielmaximiliano »

*´¨)
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`. Harbour/HMG : It's magic !
(¸.·``··*

Saludos / Regards
DaNiElMaXiMiLiAnO

Whatsapp. := +54901169026142
Telegram Name := DaNiElMaXiMiLiAnO
User avatar
AUGE_OHR
Posts: 2060
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: AChoice GUI ... how ?

Post by AUGE_OHR »

hi,
this Article describe how Cache is working but it does not help when "eject" USB Stick "while copy".
USB 3x is very fast so Microsoft have change Way and disable Cache but you still can enable it.

User can "un-plug" USB-Device while copy ... there is no Way to react on it :roll:
but if you have a Software to "eject" it must check if you can do it "now" or try it later

here is my 1st harbour / HMG Version
HBEJECT01.zip
(1.27 MiB) Downloaded 148 times
have fun
Jimmy
User avatar
AUGE_OHR
Posts: 2060
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: AChoice GUI ... how ?

Post by AUGE_OHR »

hi,

here is a Sample what i mean
Prevent_Eject.jpg
Prevent_Eject.jpg (56.18 KiB) Viewed 2491 times
i copy a large file to (slow) USB-Stick.
while copy file i try to "eject" USB-Stick with App and that must "react" and refuse it

my workaround for PREVENT_MEDIA_REMOVAL seem to work ... but it seem "to stay in Memory" ... :roll:
i have to re-start App to "reset" my workaround for next try ...

so i still have to ask how to work with Windows Structure under harbour / HMG. :idea:
this Tool make no sence if it don`t work 100% correct :(
have fun
Jimmy
User avatar
AUGE_OHR
Posts: 2060
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: AChoice GUI ... how ?

Post by AUGE_OHR »

hi

i think i made big success with Thread and PUBLIC Variable :D

Code: Select all

STATIC caItems := {}   // for GRID
STATIC acImage := {}   // for GRID
STATIC aDrives
now i use Field-wide STATIC instead of PUBLIC and i get close to what i want.

attach Sample where you can see that it work even if Form have "no focus" (Tasktray :idea: )
it need some time to detect DBT_DEVICEARRIVAL but it does immediately react on DBT_DEVICEREMOVECOMPLETE
HBEJECT02.zip
(1.28 MiB) Downloaded 147 times
have fun
Jimmy
User avatar
bpd2000
Posts: 1207
Joined: Sat Sep 10, 2011 4:07 am
Location: India

Re: AChoice GUI ... how ?

Post by bpd2000 »

Hi
Eject test om win-7 Ok
BPD
Convert Dream into Reality through HMG
Post Reply