Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Account popup
#1
My idea is to read from an excel file where i do maintain the credentials of my workers.
It would be nice to have a invoke this window or toolbar with a mouse bump.
It should appear near cursor or mouse.
I guess a datagrid should be used for best control, because i think clicking a whole row would paste user and password, while clicking a cell would just insert user or password.

Since i am a little bit rusty with coding qm i need your help.
Please give me some suggestions and maybe a hint which examples to test.

Thanks
pi
#2
Macro Account popup
Code:
Copy      Help
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 224 136 "Accounts"
;3 ListBox 0x54230101 0x200 4 16 108 114 ""
;4 Button 0x54032000 0x0 128 16 80 14 "User"
;5 Button 0x54032000 0x0 128 36 80 14 "Password"
;6 Button 0x54032000 0x0 128 56 80 14 "User && password"
;8 Static 0x54000000 0x0 4 4 48 10 "Users"
;7 Button 0x54020007 0x0 120 4 96 78 "Paste"
;END DIALOG
;DIALOG EDITOR: "" 0x2040308 "*" "" "" ""

str controls = "3"
str lb3

Database db.Open(db.CsExcel("$documents$\book1.xls"))
ARRAY(str) a; int c
;note: data starts from row 2. Row 1 must be column names: User, Password.
db.QueryArr("SELECT User FROM [Sheet1$]" a)
for(c 0 a.len) lb3.addline(a[0 c])

if(!ShowDialog(dd &sub.DlgProc &controls)) ret


#sub DlgProc v
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case [4,5,6]
,str u p
,int i=LB_SelectedItem(id(3 hDlg) u)
,if(i<0) ret
,if wParam!=4
,,db.QueryArr(F"SELECT Password FROM [Sheet1$] WHERE User='{u}'" a 1)
,,p=a[0]
,;out F"{u} {p}"
,;paste u and/or p
,act
,sel wParam
,,case 4 paste u
,,case 5 paste p
,,case 6 AutoPassword u p
ret 1
#3
Can you please provide your book1.xls too?
pi
#4
User, Password
u1, p1
u2, p2
#5
Error (RT) in <open ":3512: /599">Account popup: 0x80040E37,
[Microsoft][ODBC Excel Driver] Das Microsoft Jet-Datenbankmodul konnte das Objekt 'Sheet1$' nicht finden

I renamed Tabelle1 to Sheet1.

So it would be nice to have your xls to see if there is something wrong with my german windows.
pi
#6
.


Attached Files
.zip   Book1.zip (Size: 1.9 KB / Downloads: 245)
#7
Thanks.
With your one it works.
pi
#8
Amazing.
pi
#9
is it possible to open the dialog editor from your example code?
pi
#10
In QM 2.4.3.8 - toolbar button between Icons and Options.
In older versions - menu File -> New -> New dialog -> Edit this dialog.

Or line 1 =
Macro Account popup
Code:
Copy      Help
;\Dialog_Editor
#11
Cool, i was not aware of the dialog editor button.

how to autosize the dialog height to show all users?
numbers of lines in listbox * fontsize?
pi
#12
int height=SendMessage(id(3 hDlg) LB_GETCOUNT 0 0)*SendMessage(id(3 hDlg) LB_GETITEMHEIGHT 0 0)

or use ListDialog instead

Macro Account popup2
Code:
Copy      Help
Database db.Open(db.CsExcel("$documents$\book1.xls"))
str s; ARRAY(str) a; int c
;note: data starts from row 2. Row 1 must be column names: User, Password.
db.QueryArr("SELECT User FROM [Sheet1$]" a)
for(c 0 a.len) s.addline(a[0 c])

int i=ListDialog(s "" "Accounts")-1; if(i<0) ret
str u p
u.getl(s i)
int j=ShowMenu("4 Paste user[]5 Paste password[]6 Paste user && password[]-[]Cancel"); if(j=0) ret

if j!=4
,db.QueryArr(F"SELECT Password FROM [Sheet1$] WHERE User='{u}'" a 1)
,p=a[0]
;out F"{u} {p}"

;paste u and/or p
act
sel j
,case 4 paste u
,case 5 paste p
,case 6 AutoPassword u p
#13
Sweet!
pi
#14
why is the listbox not at top/left 0px?
seems like the space is reserved for a toolbar.
pi
#15
Space reserved for text, 2-nd parameter.
#16
i don*t need caption, just want to have only the listbox and cancel.
pi
#17
ListDialog does not have this option.


Forum Jump:


Users browsing this thread: 1 Guest(s)