同一窗口切换不了图片
本帖最后由 siuchingchow 于 2009-10-19 18:55 编辑如何在单击右键查看时刷新另外一个人的图片,望好心人帮忙,全部文件在压缩包里!
#include <GUIConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <ListViewConstants.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#Include <GuiListView.au3>
#NoTrayIcon
$g_szVersion = "notebook"
If WinExists($g_szVersion) Then Exit ;检查指定的窗口是否存在,不允许运行多个窗口
AutoItWinSetTitle($g_szVersion);修改 AutoIt 窗口的标题名.
$database="vista.mdb";连接数据库
$password=""
$con=ObjCreate("adodb.connection")
$sql=$con.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&$database&";Jet Oledb:Database Password="&$password)
#Region ### START Koda GUI section ### Form=D:\netgame\mynotebook\form.kxf
$Form1 = GUICreate("NoteBook", 409, 446, 254, 138)
GUISetFont(10, 400);设置窗口的默认字体.
$PageControl1 = GUICtrlCreateTab(0, 0, 408, 445)
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)
$tongxunlu = GUICtrlCreateTabItem("通讯录");第一分页:通讯录
$tx_list = GUICtrlCreateListView("", 4, 217, 400, 205)
$tx_menu = GUICtrlCreateContextMenu($tx_list);在指定控件或GUI窗口上创建右键菜单。GUICtrlCreateContextMenu ( [控件ID] )
$tx_view=GUICtrlCreateMenuItem("查看", $tx_menu)
$tx_add=GUICtrlCreateMenuItem("添加", $tx_menu)
$tx_modi=GUICtrlCreateMenuItem("修改", $tx_menu)
$tx_del=GUICtrlCreateMenuItem("删除", $tx_menu)
$tx_flash=GUICtrlCreateMenuItem("刷新",$tx_menu)
;在使用本函数创建右键菜单的主控件之后,即可使用 GUICtrlCreateMenuItem 来创建每个菜单项。
GUICtrlSetStyle($tx_list,BitOR($LVS_NOCOLUMNHEADER,$LVS_SORTASCENDING,$LVS_SINGLESEL,$LVS_LIST))
;$LVS_LIST这个样式指定控件显示为一个列表.$LVS_SINGLESEL只需选中一个项目,同样的项目也会被选中(点一个选一行).$LVS_SORTASCENDING项目索引将使用递增自动排列.
;$LVS_NOCOLUMNHEADER不在报告样式中显示列表头. 默认情况下, 列表头在报告样式的ListView控件中是存在的 .
$Group1 = GUICtrlCreateGroup("详细信息", 4, 23, 400, 190)
$tx_pic = GUICtrlCreatePic("pic\pic1.jpg", 8, 40, 120, 169)
$tx_name =GUICtrlCreateLabel("姓 名:张三", 140, 40, 270,17)
$tx_zhiye = GUICtrlCreateLabel("职 业:网络管理员", 140, 64, 270,17)
$tx_birth = GUICtrlCreateLabel("生 日:198*-8-5", 140, 88, 270,17)
$tx_phone = GUICtrlCreateLabel("电话号码:135320940**", 140, 112, 270,17)
$tx_QQ = GUICtrlCreateLabel("OIQQ号码:275988582", 140, 136, 270,17)
$tx_danwei = GUICtrlCreateLabel("单位地址:中山市", 140, 160, 270,17)
$tx_addr = GUICtrlCreateLabel("家庭住址:广西", 140, 184, 270,17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$tx_toolbar = _GUICtrlStatusBar_Create($Form1)
_GUICtrlStatusBar_SetMinHeight($tx_toolbar, 17)
GUICtrlCreateTabItem("")
_read_tx()
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $tx_view
$tx_name1 = _GUICtrlListView_GetItemText($tx_list, _GUICtrlListView_GetNextItem($tx_list), 0)
$rs=ObjCreate("adodb.recordset")
$rs.activeconnection=$con
$rs.open("select * from txl where tx_name='"&$tx_name1&"'")
while Not $RS.eof And Not $RS.bof
if @error =1 Then ExitLoop
GUICtrlDelete($tx_pic)
$tx_pic1= GUICtrlCreatePic($RS.Fields (1).value, 8, 40, 120, 169)
GUISwitch($tx_pic1)
;GUICtrlSetData($tx_pic1,$RS.Fields (1).value)
GUICtrlSetData($tx_name,"姓 名:"&$RS.Fields (2).value)
GUICtrlSetData($tx_zhiye,"职 业:"&$RS.Fields (3).value)
GUICtrlSetData($tx_birth,"生 日:"&$RS.Fields (4).value)
GUICtrlSetData($tx_phone,"电话号码:"&$RS.Fields (5).value)
GUICtrlSetData($tx_QQ,"OIQQ号码:"&$RS.Fields (6).value)
GUICtrlSetData($tx_danwei,"单位地址:"&$RS.Fields (7).value)
GUICtrlSetData($tx_addr,"家庭住址:"&$RS.Fields (8).value)
$rs.movenext
WEnd
$rs.close
EndSwitch
WEnd
Func _read_tx()
GUICtrlSendMsg($tx_list,$LVM_DELETEALLITEMS, 0, 0);由于listview control在创建时是不可见的,现在我们把它显示出来.还有 要把其中的所有元素(如果有的话)删掉.
$rs=ObjCreate("adodb.recordset")
$rs.activeconnection=$con
$rs.open("select * from txl")
while Not $RS.eof And Not $RS.bof
if @error =1 Then ExitLoop
GUICtrlCreateListViewItem ($RS.Fields (2).value,$tx_list )
$rs.movenext
WEnd
$rs.close
EndFunc 图片控件与TAB同时存在时,应该先画PIC,后画TAB。这样图就可以透过TAB显示出来。
就你这个例子,我建议你不要采用删除、重建PIC控件的办法来替换图片,不是有guictrlsetimage吗? 2# 顽固不化
谢谢你,可以了,不胜感激
页:
[1]