如何作到taskbar的效果(150分)

D

DNChen

Unregistered / Unconfirmed
GUEST, unregistred user!
我想让一个工具条,象任务栏一样,可以以类似align=top<br>或者align=bottom这样的效果依附在屏幕一边,这个怎么实现?<br>或者说,是象拖动icq主窗口时,拉到一边会整个的嵌进去一样的<br>效果,该怎么做呢?<br><br>不要控件,要原理+原程序
 
首先捕捉鼠标事件(setcapture),当鼠标左键按下的时候,开始判断窗体的某一边<br>是否靠近屏幕的边缘(比如如果左边的位置接近0),如果是,则将窗体的大小改变为<br>线壮。同样,当鼠标靠近窗体隐藏的位置时,把窗体还原。
 
要把你的程序注册成为AppBar,就可以在屏幕边上隐藏和浮现
 
怎么个注册法???
 
to 邹光先: <br>没这么简单的,靠边的窗口事实上会独占掉这块区域。<br><br>to pegasus:<br>怎么注册啊,我见过一个tappbar的控件,用他代替tform,可以实现我提到的效果,<br>可惜有BUG,同时我想能够知道真正的实现过程,
 
setclasslong把form的class改成appbar?
 
eyes大哥,我查了setclasslong的帮助,没有appbar呀?<br><br>哎呀,我看错了,原来你后面有个问号啊
 
不是appbar项呀, 是classname改成appbar的<br>具win32.hlp说所有继承自这个class的window都会变掉类型 :)
 
等我好好写一下,这个东西和在TaskBar上面增加Icon差不太多,稍微繁琐一些<br><br>Please wait a minute...
 
AppBar是 Application Desktop Toolbars 的缩写<br>它是类似于任务栏的窗口,锁定在屏幕边缘,一般包含按钮来加速应用程序的访问,<br>Office中就用了这种技术<br><br>在程序中使用AppBar:<br>Windows 提供了API让普通程序能够表现得像TaskBar一样. 系统提供的服务能够<br>让多个这样的程序之间以及和任务栏相处融洽. 系统维护每个AppBar的信息并向<br>它们发送消息通知可能影响它们的大小位置和表现的事件的发生<br><br>发送消息:<br>应用程序使用一组特殊的称为appbar消息来添加和删除AppBar, 设置大小和位置<br>以及获得大小和位置/状态。应用程序必须使用 SHAppBarMessage 函数来发送AppBar<br>消息给系统.<br><br>注册AppBar<br>发送ABM_NEW AppBar消息.<br>撤销AppBar:<br>发送ABM_REMOVE AppBar 消息<br>例子程序:<br>Uses ShellApi;<br>function RegisterAccessBar(hwndAccessBar: HANDLE , bRegister : Boolean):boolean;<br>var<br>&nbsp; abd : APPBARDATA;<br><br>begin<br>&nbsp; &nbsp; // Specify the structure size and handle to the appbar. <br>&nbsp; &nbsp; abd.cbSize := sizeof(APPBARDATA); <br>&nbsp; &nbsp; abd.hWnd := hwndAccessBar; <br>&nbsp;<br>&nbsp; &nbsp; result :=TRUE;<br>&nbsp; &nbsp; <br>&nbsp; &nbsp; if (fRegister) then<br>&nbsp; &nbsp; &nbsp; begin <br>&nbsp; &nbsp; &nbsp; &nbsp; // Provide an identifier for notification messages. <br>&nbsp; &nbsp; &nbsp; &nbsp; abd.uCallbackMessage = APPBAR_CALLBACK; <br>&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; // Register the appbar. <br>&nbsp; &nbsp; &nbsp; &nbsp; if (!SHAppBarMessage(ABM_NEW, &amp;abd)) <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result := false;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end<br>&nbsp; &nbsp; &nbsp; end<br>&nbsp; &nbsp; else<br>&nbsp; &nbsp; &nbsp; begin <br>&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; // Unregister the appbar. <br>&nbsp; &nbsp; &nbsp; &nbsp; SHAppBarMessage(ABM_REMOVE, &amp;abd); <br>&nbsp; &nbsp; &nbsp; end; <br>end;<br><br><br>Appbar 大小和位置:<br>应用程序必须设置AppBar的大小和位置以免和别的AppBar冲突或者和任务栏冲突。<br>AppBar必须锁定在屏幕的某一边,多个AppBar可以锁定在屏幕的同一边.<br>但是如果AppBar和任务栏锁定在同一边,系统会保证任务栏位于最前面。<br><br>为了设置大小和位置,程序需要先把自己想占用的大小和位置通过发送 ABM_QUERYPOS<br>AppBar消息询问系统,系统会根据请求的屏幕位置已经被AppBar或者任务栏占用的情况<br>返回修正后的大小和位置。 然后,应用程序发送 ABM_SETPOS AppBar消息来设置大小<br>和位置. 同样,系统会修正应用程序设定的值。应用程序应当根据 ABM_SETPOS AppBar<br>消息返回的大小和位置设定自己的大小和位置(例如通过MoveWindow API).<br>&nbsp;<br>通过这种两步的方式设定大小和位置,应用程序可以在用户用鼠标拖动AppBar的时候向<br>用户及时反馈AppBar的目标位置和大小。<br><br>应用程序必须在注册了AppBar之后设置它的大小和位置。同样,在接到系统的ABN_POSCHANGED<br>AppBar事件通知消息的时候也要再次设置。<br><br>当AppBar接收到 WM_ACTIVATE 消息的时候, 必须发送 ABM_ACTIVATE AppBar 消息.<br>接收到 WM_WINDOWPOSCHANGED 消息的时候, 必须发送 ABM_WINDOWPOSCHANGED AppBar 消息.<br>这样可以使系统能够自动设置在同一边的其他自动消隐的AppBar的前后顺序. <br><br>应用程序发送 &nbsp;ABM_SETAUTOHIDEBAR AppBar 消息设置自己的自动消隐状态。在屏幕的同一<br>边只能允许一个自动消隐的AppBar. 发送 &nbsp;ABM_GETAUTOHIDEBAR AppBar 消息可以得到自动<br>消隐的AppBar的窗口handler <br><br>自动消隐的AppBar 不必要用 ABM_NEW AppBar消息注册. 没有用ABM_NEW AppBar消息注册的<br>AppBar会在同一边的其他AppBar的前面. <br><br>Appbar 事件通知消息:<br><br>(未完待续,Wuu, 翻译得好累呀!:)
 
不好意思:从VC翻译程序的时候出了错:<br>&nbsp; &nbsp; &nbsp; &nbsp; // Register the appbar. <br>&nbsp; &nbsp; &nbsp; &nbsp; if (!SHAppBarMessage(ABM_NEW, &amp;abd)) <br>^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^<br>&nbsp; &nbsp; &nbsp; &nbsp; if (SHAppBarMessage(ABM_NEW, @abd)&lt;&gt;0) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
 
不好意思:从VC翻译程序的时候出了错:<br>&nbsp; &nbsp; &nbsp; &nbsp; // Register the appbar. <br>&nbsp; &nbsp; &nbsp; &nbsp; if (!SHAppBarMessage(ABM_NEW, &amp;abd)) <br>^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^<br>&nbsp; &nbsp; &nbsp; &nbsp; if (SHAppBarMessage(ABM_NEW, @abd)&lt;&gt;0) then &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br>
 
我有一个Task Bar的Delphi类,我们的财务软件控制中心就是用这个东东。<br>要的人可以3天内留下Email. 3天后一并寄出。<br>原理pegaus说的很对,不过实际做起来有一定难度。
 
哈哈!<br>要!!<br>xiaxin@990.net<br><br>借Dnchen的问题问一下,如何复制tray呢???<br>即自己建一个toolbar,同时想把tray上的图表转移到toolbar上。<br>对Toolbar上的图标操作和对tray上的图标操作达到一样的效果。<br>???<br><br>呵呵!提问不用自己给分,不亦乐乎!!<br>:p<br>
 
翻译的程序还有不少错误,基本都修正了,只有APPBAR_CALLBACK<br>不知道怎么改。<br>那个类也顺便送我的email吧tocdn@pchome.net,不过没有分拿的哦,:cool:<br>我说过这个问题只讨论程序实现,不用控件。<br><br>Uses ShellApi;<br>function RegisterAccessBar(hwndAccessBar: HWND ; bRegister : Boolean):boolean;<br>var<br>&nbsp; abd : tAPPBARDATA;<br><br>begin<br>&nbsp; &nbsp; // Specify the structure size and handle to the appbar.<br>&nbsp; &nbsp; abd.cbSize := sizeof(TAPPBARDATA);<br>&nbsp; &nbsp; abd.hWnd := hwndAccessBar;<br><br>&nbsp; &nbsp; result :=TRUE;<br><br>&nbsp; &nbsp; if (bRegister) then<br>&nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; // Provide an identifier for notification messages.<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; abd.uCallbackMessage := APPBAR_CALLBACK;<br>&nbsp; &nbsp; &nbsp; &nbsp; // Register the appbar.<br>&nbsp; &nbsp; &nbsp; if (SHAppBarMessage(ABM_NEW, abd)&lt;&gt;0) then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result := false;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end<br>&nbsp; &nbsp; &nbsp; end<br>&nbsp; &nbsp; else<br>&nbsp; &nbsp; &nbsp; begin<br><br>&nbsp; &nbsp; &nbsp; &nbsp; // Unregister the appbar. <br>&nbsp; &nbsp; &nbsp; &nbsp; SHAppBarMessage(ABM_REMOVE, abd); <br>&nbsp; &nbsp; &nbsp; end; <br>end;<br><br>
 
是这样的:<br>APPBar_CALLBACK是用户自定义的一条消息,系统会通过这条消息通知<br>AppBar应用程序各种事件,具体情况等我把剩下的部分翻译完成就明白<br>了。<br>
 
各位,看过没有李维的书,里面不是有完整的APPBAR的程序例子,<br>APPBARS,是定义一个结构,注册数据,将FORM设置为没有TITILE<br>就行了,不过,我还是希望有个控件了,所以留下E-MAIL<br>&nbsp; &nbsp;shermanxie@126.com
 
不就是d4里面的dock吗?
 
to delphi: 给我一份: cakk2000@163.net
 
sherman,我弄不到李唯的书啊,你有电子版的吗?
 

Similar threads

顶部