HMG_aChoice
Moderator: Rathinagiri
Re: HMG_aChoice
sweet laziness at Croatia coast, hahaha
Re: HMG_aChoice
Hello Rathi,
Thanks a lot, today Swapan also wanted something like this in one of my projects
I like both of your programs. For my purpose I like 1st program more. Because:
1. Better user interface (IMHO ) to find and search.
2. Mouse pointer hides in the list window in 2nd program.
Thank you again
Thanks a lot, today Swapan also wanted something like this in one of my projects
I like both of your programs. For my purpose I like 1st program more. Because:
1. Better user interface (IMHO ) to find and search.
2. Mouse pointer hides in the list window in 2nd program.
Thank you again
With best regards,
Sudip
Sudip
- Rathinagiri
- Posts: 5471
- Joined: Tue Jul 29, 2008 6:30 pm
- DBs Used: MariaDB, SQLite, SQLCipher and MySQL
- Location: Sivakasi, India
- Contact:
Re: HMG_aChoice
I had improved this hmg_achoice version (which I had replaced in the first post of this thread too.) This time I have saved some keystrokes.
Kindly check and give your suggestions!.
Kindly check and give your suggestions!.
Code: Select all
#include <hmg.ch>
Function Main
private aCountries := HB_ATOKENS( MEMOREAD( "Countries.lst" ), CRLF )
public aVar := 1
set navigation extended
define window sample at 0,0 width 800 height 600 main
define label label1
row 10
col 10
width 100
value "Name"
end label
define textbox textbox1
row 10
col 110
width 100
end textbox
define label label2
row 40
col 10
width 100
value "Country"
end label
define textbox textbox2
row 40
col 110
width 100
on gotfocus HMG_AChoice( 10, 300, , , aCountries,,.f.)
end textbox
define label label3
row 70
col 10
width 100
value "City"
end label
define textbox textbox3
row 70
col 110
width 100
end textbox
end window
sample.center
sample.activate
Return
function HMG_Achoice(nTop,nLeft,nBottom,nRight,aList,nDefault,lAnyWhere)
local nRow := thiswindow.row
local nCol := thiswindow.col
local nWindowWidth := thiswindow.width
local nWindowHeight := thiswindow.height
local nWidth := 0
local nHeight := 0
local nFound := 0
local i := 0
local cInit := this.value
private _aItems := aclone(aList)
private _nSelected := 0
private lAnyWhereSearch := .f.
private cParentForm := thiswindow.name
private cThisControl := this.name
default lAnyWhere := .f.
default nDefault := 0
default nBottom := thiswindow.height - 10
default nRight := thiswindow.width - 10
lAnyWhereSearch := lAnyWhere
nWidth := iif(nRight < nWindowWidth, nRight - nLeft,nWindowWidth - nLeft - 10)
nHeight := iif(nBottom < nWindowHeight, nBottom - nTop,nWindowHeight - nTop - 10)
if .not. iswindowdefined(_HMG_AChoice)
DEFINE WINDOW _HMG_aChoice AT nRow+nTop, nCol+nLeft ;
WIDTH nWidth ;
HEIGHT nHeight ;
TITLE '' ;
MODAL ;
NOCAPTION;
NOSIZE
define textbox _edit
row 5
col 5
width nWidth - 10
ON CHANGE _aChoiceTextChanged( lAnyWhere )
ON ENTER _aChoiceSelected( )
end textbox
define listbox _list
row 30
col 5
width nWidth - 10
height nHeight - 50
items aList
on change _achoicelistchanged()
ON DBLCLICK _aChoiceSelected( )
end listbox
end window
ON KEY UP OF _HMG_achoice ACTION _aChoiceDoUpKey()
ON KEY DOWN OF _HMG_achoice ACTION _aChoiceDoDownKey()
ON KEY ESCAPE OF _HMG_achoice ACTION _aChoiceDoEscKey()
_hmg_sysdata[296] := {||_aChoiceselected()}
if len(_aItems) > 0
if nDefault > 0
_HMG_aChoice._list.value := nDefault
_HMG_aChoice._edit.value := _aItems[nDefault]
else
if len(alltrim(cInit)) > 0
nFound := ascan(_aItems,cInit)
if nFound > 0
_HMG_aChoice._list.value := nFound
_HMG_aChoice._edit.value := cInit
endif
endif
endif
endif
_HMG_Achoice.activate
_hmg_sysdata[296] := nil
inserttab()
else
_hmg_sysdata[296] := nil
inserttab()
endif
return nil
STATIC PROC _aChoiceTextChanged( lAnyWhere )
LOCAL cCurValue := _HMG_aChoice._edit.value
LOCAL nItemNo := 0
local lFound := .f.
FOR nItemNo := 1 TO LEN(_aitems)
IF lAnyWhere
IF AT(UPPER(cCurValue),UPPER(_aItems[nItemNo])) > 0
_HMG_aChoice._list.value := nItemNo
lFound := .t.
exit
ENDIF
ELSE
IF UPPER( LEFT( _aitems[ nItemNo ], LEN(cCurValue))) == UPPER(cCurValue)
_HMG_aChoice._list.value := nItemNo
lFound := .t.
exit
ENDIF
ENDIF
NEXT nItemNo
if .not. lFound
_HMG_aChoice._list.value := 0
endif
RETURN
function _aChoiceselected
if _HMG_aChoice._List.value > 0
setproperty(cParentForm,cThisControl,"VALUE",_HMG_aChoice._List.item(_HMG_aChoice._List.value))
else
setproperty(cParentForm,cThisControl,"VALUE","")
endif
release window _HMG_aChoice
return nil
function _aChoiceDoUpKey()
IF _HMG_aChoice._List.value > 1
_HMG_aChoice._List.value := _HMG_aChoice._List.value - 1
_HMG_aChoice._edit.value := _HMG_aChoice._List.item(_HMG_aChoice._List.value)
textboxeditsetsel("_HMG_aChoice","_Edit",0,-1)
ENDIF
return nil
function _aChoiceDoDownKey()
IF _HMG_aChoice._List.value < _HMG_aChoice._List.ItemCount
_HMG_aChoice._List.value := _HMG_aChoice._List.value + 1
_HMG_aChoice._edit.value := _HMG_aChoice._List.item(_HMG_aChoice._List.value)
textboxeditsetsel("_HMG_aChoice","_Edit",0,-1)
ENDIF
return nil
function _aChoiceDoEscKey()
setproperty(cParentForm,cThisControl,"VALUE","")
release window _HMG_aChoice
return nil
function _achoicelistchanged
if upper(this.name) == "_EDIT" .and. upper(thiswindow.name) == "_HMG_ACHOICE" .and. .not. lAnyWhereSearch
_HMG_aChoice._edit.value := _HMG_aChoice._List.item(_HMG_aChoice._List.value)
textboxeditsetsel("_HMG_aChoice","_Edit",0,-1)
endif
return nil
function textboxeditsetsel(cParent,cControl,nStart,nEnd)
local nHandle := GetControlHandle (cControl,cParent)
textboxsetsel(nHandle,nStart,nEnd)
return nil
#pragma BEGINDUMP
#include <windows.h>
#include <commctrl.h>
#include "hbapi.h"
#include <wingdi.h>
HB_FUNC ( TEXTBOXSETSEL )
{
HWND hWnd1;
hWnd1 = (HWND) hb_parnl (1);
SendMessage((HWND) hWnd1,EM_SETSEL, (WPARAM)(int) hb_parni(2),(LPARAM) (int) hb_parni(3));
}
#pragma ENDDUMP
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
South or North HMG is worth.
...the possibilities are endless.
- esgici
- Posts: 4543
- Joined: Wed Jul 30, 2008 9:17 pm
- DBs Used: DBF
- Location: iskenderun / Turkiye
- Contact:
Re: HMG_aChoice
Thanks Rathi
Good improvement
By the way, inserttab() is very nice ( both function itself and usage by you ); SSE (short, simple and effective)
Regards
--
Esgici
Good improvement
By the way, inserttab() is very nice ( both function itself and usage by you ); SSE (short, simple and effective)
Regards
--
Esgici
Viva INTERNATIONAL HMG
- Rathinagiri
- Posts: 5471
- Joined: Tue Jul 29, 2008 6:30 pm
- DBs Used: MariaDB, SQLite, SQLCipher and MySQL
- Location: Sivakasi, India
- Contact:
Re: HMG_aChoice
Yes!
While seeing HMG's source I found this function usage by Roberto. (That's the reason for SSE!)
While seeing HMG's source I found this function usage by Roberto. (That's the reason for SSE!)
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
South or North HMG is worth.
...the possibilities are endless.
Re: HMG_aChoice
Hi Rathi,
Thanks a lot
I downloaded (copied) it. I shall test and send you feedback.
Thanks a lot
I downloaded (copied) it. I shall test and send you feedback.
With best regards,
Sudip
Sudip
Re: HMG_aChoice
Tested. Runs fine
Thanks
BTW, how can I use this or CSB with Grid?
Thanks in advance.
Thanks
BTW, how can I use this or CSB with Grid?
Thanks in advance.
With best regards,
Sudip
Sudip