maxscript編寫帶有登入功能的外掛程式

2022-03-31 19:18:00 字數 2351 閱讀 7398

踩到的坑:

1.在rollout裡面關閉當前dialog 直接寫在裡面無效

rollout floater2 "登入"

(label lbl_username "使用者名稱:" align:#left across:2

edittext txt_username "" width:100 height:20 align:#right arcoss:2

label lbl_password "密碼:" align:#left across:2

edittext txt_password "" width:100 align:#right across:2 

global objectusername = ""

global objectpassword = ""

on txt_username entered txt do(

objectusername = txt

txt_username.text = txt

destroydialog floater

)on txt_password entered txt do (

objectpassword = txt

txt_password.text = txt))

2..連線資料庫 無法連線,老是說不能訪問

testconn=createoleobject "adodb.connection"

testconn.open "driver=; server=servername; database=databasename;user=username;password=password"

recordset = createoleobject "adodb.recordset"

selectstring = "select * from tablename where username='"+username+"' and password='"+password+"'"

recordset.open selectstring testconn -- standard sql request in ""

recordset.getrows()

解決方案:

問題1:將dialog的建立放到函式中去

fn makedialog =

(rollout floater "登入資訊"

(label lbl_username "使用者名稱:" align:#left across:2

edittext txt_username "" width:100 height:20 align:#right arcoss:2

label lbl_password "密碼:" align:#left across:2

edittext txt_password "" width:100 align:#right across:2

button btn_loginbottom "登入" width:60 align:#center

global objectusername = ""

global objectpassword = ""

on txt_username entered txt do(

objectusername = txt

txt_username.text = txt

)on txt_password entered txt do (

objectpassword = txt

txt_password.text = txt

)on btn_loginbottom pressed do

(--驗證登入資訊是否正確

result = fn_validateuser objectusername objectpassword

print 2222

print result

print (result == "fail")

if result =="success" then (destroydialog floater) else (print "fail")))

createdialog floater width:200 height:100

setfocus floater.txt_username

)問題2:參考

根據自己的電腦(32位還是64位)選擇安裝mysql-connector-odbc-3.51.30

單擊開始-控制面板-管理工具

雙擊資料來源(odbc)

單擊切換到系統dsn選項卡,單擊新增

雙擊mysql odbc 3.51 driver,如圖2所示,填寫data source name,tcp/ip server:,user:,password: ,database: .點選ok儲存,確定.   

MAXScript外掛程式編寫 初步建立BOX物件

運算與c類似。字串賦值 mystr my string 繪製乙個box物件。mybox box length 20 width 20 height 20 box長寬高 mybox.wirecolor 111,33,2 box顏色rgbmybox.pos 10,0,10 box位置 mybox.siz...

python編寫登入介面

要求如下 已鎖定使用者 檔案形式如下 使用者名稱和密碼 檔案形式如下 python 如下 usr bin env python coding utf 8 import sys retry limit 3 retry count 0 account file accounts.txt lock fil...

2019 11 7 登入介面編寫

1 聚焦順序設定 控制項w下方edit tab order 2 qlineedit 屬性echomode password密碼模式 3 目錄檔案 a pro 解決方案 qt core gui 所需要包含的模組 greaterthan qt major version,4 qt widgets tar...