duilib 滑動顯示的視窗實現

2021-07-09 09:14:48 字數 3827 閱讀 6031

經jhgwqp@csdn提醒, 將這事做了.

編譯環境: vs2010 vc++ duilib

效果圖:

**預覽:

建立彈出的滑動對話方塊時, 要以子視窗風格建立, 這樣, 主視窗移動時, 我們就不用負責子視窗的位置移動了.

[cpp]view plain

copy

void

cmaindlg::createdlgslidingshow()  

while

(0);  

}  

在訊息中處理子視窗的滑動顯示, 對duilib的顯示操作, 最好放在訊息中處理, 防止崩潰.

[cpp]view plain

copy

lresult

cdlgslidingshow::wndmessageproc_slidingshow(

uint

umsg, 

wparam

wparam, 

lparam

lparam)  

else

if(m_frate 

m_frate = fratemin;  

}  else

if(edispstatus_disp == m_status)  

else

if(edispstatus_dec == m_status)  

}  // ::getwindowrect(m_powner->gethwnd(), &rtmain);

::getclientrect(m_powner->gethwnd(), &rtmain);  

rtlayout.right = rtmain.right;  

rtlayout.bottom = rtmain.bottom;  

rtlayout.left = rtlayout.right - (m_rtmeorg.right - m_rtmeorg.left);  

rtlayout.top = rtlayout.bottom - (m_rtmeorg.bottom - m_rtmeorg.top);  

rtlayoutrate.left = rtlayout.left;  

rtlayoutrate.right = rtlayout.right;  

rtlayoutrate.bottom = rtlayout.bottom;  

rtlayoutrate.top = rtlayout.bottom - 1.0f * (rtlayout.bottom - rtlayout.top) * m_frate;  

/// 介面庫的限制吧 ? 無法設定成很低的高度, 有最小高度限制...

/// 過載 ongetminmaxinfo 也沒用

/// 通過試驗, 發現最小高度為10左右

/// 作為所有者的非子視窗(~ui_wndstyle_child), 用setwindowpos

/// 如果是非子視窗, 位置也要重新實驗一下, 不能用::getclientrect.

/// 要用::getwindowrect

//         ::setwindowpos(

//             this->gethwnd(), 

//             m_powner->gethwnd(), 

//             rtlayoutrate.left, 

//             rtlayoutrate.top, 

//             rtlayoutrate.right - rtlayoutrate.left, 

//             rtlayoutrate.bottom - rtlayoutrate.top, 

//             swp_showwindow);

/// 作為所有者的子視窗(ui_wndstyle_child), 用movewindow

::movewindow(  

this

->gethwnd(),   

rtlayoutrate.left,   

rtlayoutrate.top,   

rtlayoutrate.right,   

rtlayoutrate.bottom,   

true);  

::showwindow(this

->gethwnd(), m_bplay ? sw_show : sw_hide);  

if(!m_bplay)  

} while

(0);  

return

s_ok;  

}  

2014-03-28 03:23 的備份

[cpp]view plain

copy

void

cfloattextmsgdlg::play()  

else

if(m_frate 

m_frate = fratemin;  

}  else

if(edispstatus_disp == m_status)  

else

if(edispstatus_dec == m_status)  

}  m_powner->gettabviewframeposition(rttabview);  

::getwindowrect(m_powner->gethwnd(), &rtmain);  

rtlayout.left = rtmain.left + rttabview.left;  

rtlayout.right = rtlayout.left + (m_rtmeorg.right - m_rtmeorg.left);  

rtlayout.top = rtmain.top + rttabview.bottom - (m_rtmeorg.bottom - m_rtmeorg.top);  

rtlayout.bottom = rtmain.top + rttabview.bottom;  

rtlayoutrate.left = rtlayout.left;  

rtlayoutrate.right = rtlayout.right;  

rtlayoutrate.bottom = rtlayout.bottom;  

rtlayoutrate.top = rtlayout.bottom - 1.0f * (rtlayout.bottom - rtlayout.top) * m_frate;  

/// 介面庫的限制吧 ? 無法設定成很低的高度, 有最小高度限制...

/// 過載 ongetminmaxinfo 也沒用

/// 通過試驗, 發現最小高度為10左右

::setwindowpos(  

this

->gethwnd(),   

m_powner->gethwnd(),   

rtlayoutrate.left,   

rtlayoutrate.top,   

rtlayoutrate.right - rtlayoutrate.left,   

rtlayoutrate.bottom - rtlayoutrate.top,   

swp_showwindow);  

::showwindow(this

->gethwnd(), m_bplay ? sw_show : sw_hide);  

}  

滑動視窗實現訪問頻率限制

主要思路有兩個 以時間戳為有序集合的成員 每次請求,先使用zremrangebylex命令移除視窗外的成員 使用zrange命令獲取有序集合的成員和相應權重 使用zincrby命令對相應的成員的權重加一 使用expire命令重新設定有序集合有效期 對獲取到的有序集合的成員的權重求和,並判斷是否超過閾...

登入視窗實現

中間視窗的標題欄 中間視窗的內容區 中間視窗的內容區 中間視窗的內容區中間視窗的內容區 中間視窗的內容區中間視窗的內容區 中間視窗的內容區中間視窗的內容區 中間視窗的內容區中間視窗的內容區 中間視窗的內容區中間視窗的內容區 中間視窗的內容區中間視窗的內容區 中間視窗的內容區 中間視窗的內容區 中間視...

duilib 視窗的分層顯示控制

需求中要求,taska的視窗在彈出後,必須前置在其他子視窗上面。剛開始,試驗了2種方法不理想.用setwindowpos改變子視窗的z軸,這 太大了.主視窗的前置和後置的控制和任務視窗的彈出有衝突.將taska建立在最後彈出的視窗上,處理起來繁瑣,不穩定。如果taska的父視窗消失了,但是這時要求t...